% This program does a linear fit to the germination rate data.  To
% recalculate a fit, enter the appropriate file in line 21 of the code and
% rename it to "f1".  Note that the "amy*.mat" files are the wgom isolate
% data (Amy Bronzino sent the files my way).  These files contain arrays
% named lgt2, lgt4, lgt6, lgt8 and drk2, drk4, drk6, drk8 depending on the
% data in each file.  The egom files are simply text files.
%
% Only data with a germination potential under <= 90% and <= 75 days after the 
% beginning of the experiment were used in order to isolate the increasing 
% portion of the curve.
%
% This routine was also used for fluorescence
%
% Charlie Stock
% cstock@alum.mit.edu
%

clear all

% load in germination data and give data a generic name
load ../data/amy2d;
f1 = drk2;

% set x and y for regression w/all points
x1 = f1(:,1);
y1 = f1(:,2);

% limit yourself to points under 90% germinations and < 75 days after the
% start of the experiment.
aa = find(y1 <= 90 & x1 <= 75);
datsize = size(aa,1);

% Model: y = X*b, y is observations, X is the days out,
% and b is the slope/intercept parameters.  A column of ones
% is included in X for the intercep.
x(1:datsize,1) = 1;
x(1:datsize,2) = x1(aa);
y(1:datsize,1) = y1(aa);

% calculate slope, intercept and uncertainty.
% interval width = endpoint - bint(2,1)
[b,bint] = regress(y,x,0.10);
% b(1) is the intercept, b(2) is the slope
b
% calculate the width of the 90% confidence interval
int = b(2) - bint(2,1)
