LINEARIZING AN
EXPONENTIAL REGRESSION

Suppose that 6 observations have been made of the numbers Y of organisms in a culture at times X. The culture would be expected to increase exponentially with time, at least for a while. Plotting the graph of Y versus X is a verification that the family of curves needed to fit the observed data is the family of exponential curves whose generic formula is y = y0*exp(a*x) with parameters y0 and a. The transformation z = ln(y) will transform the data to linear so that the linear regression formulas may be used. Then the inverse transformation y = exp(z) is used to transform the results back to exponential.

> restart:with(stats):with(fit):with(plots):

> `Time x`;X:=[1.1,2.6,3.2,4.3,6.2,8.8];SUMX:=sum(X[i],i=1..6);

[Maple Math]

[Maple Math]

[Maple Math]

> `Number in culture y`;Y:=[998.,2108.,3678.,6087.,22600.,75650.];

[Maple Math]

[Maple Math]

> PAIR:=[seq([X[i],Y[i]],i=1..6)];

[Maple Math]

> plot(PAIR,style=point,symbol=circle,color=blue,title=`Number of organisms y versus time x`,labels=[`x`,`y`]);

[Maple Plot]

> pic1:=%:

> Z:=[seq(ln(Y[i]),i=1..6)];SUMZ:=sum(Z[i],i=1..6);

[Maple Math]

[Maple Math]

> PAIR2:=[seq([X[i],Z[i]],i=1..6)];

[Maple Math]
[Maple Math]

> plot(PAIR2,style=point,symbol=circle,labels=[`x`,`z = ln(y)`],title=`Plot of z = ln(y) versus x`);

[Maple Plot]

> XX:=[seq(X[i]^2,i=1..6)];SUMXX:=sum(XX[i],i=1..6);ZZ:=[seq(Z[i]^2,i=1..6)];SUMZZ:=sum(ZZ[i],i=1..6);XZ:=[seq(X[i]*Z[i],i=1..6)];SUMXZ:=sum(XZ[i],i=1..6);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

> printf(" X Z XX ZZ XZ"); printf("----------------------------------------------------------------------");for j from 1 to 6 do printf("%9.4f %9.4f %9.4f %9.4f %9.4f",X[j],Z[j],XX[j],ZZ[j],XZ[j]);print():od;printf("----------------------------------------------------------------------");printf("%9.4f %9.4f %9.4f %9.4f %9.4f",SUMX,SUMZ,SUMXX,SUMZZ,SUMXZ);print():

     X            Z                XX               ZZ            XZ

----------------------------------------------------------------------

   1.1000        6.9058           1.2100          47.6894        7.5963

   2.6000        7.6535           6.7600          58.5760       19.8991

   3.2000        8.2101          10.2400          67.4061       26.2724

   4.3000        8.7139          18.4900          75.9322       37.4698

   6.2000       10.0257          38.4400         100.5148       62.1594

   8.8000       11.2339          77.4400         126.1999       98.8581

----------------------------------------------------------------------

  26.2000       52.7429         152.5800         476.3185      252.2551

> n:=6:

> m:=(n*SUMXZ-SUMX*SUMZ)/(n*SUMXX-SUMX*SUMX); b:=SUMZ/n-m*SUMX/n;

[Maple Math]

[Maple Math]

> z = m*x + b;

[Maple Math]

> y_hat = exp(z);exp(z)=exp(rhs(%%));

[Maple Math]

[Maple Math]

> y_hat:=unapply(rhs(%),x);

[Maple Math]

> pic2:=plot(y_hat(x),x=0..9):

> display(pic1,pic2);

[Maple Plot]

> printf(" x y y_hat error percent error");print();printf("----------------------------------------------------------------- ");for i from 1 to 6 do

> printf("%6.1f %8.0f %8.0f %8.0f %8.0f" ,X[i],Y[i],y_hat(X[i]),y_hat(X[i])-Y[i],100*(y_hat(X[i])-Y[i])/Y[i]);print();

> od;

    x          y           y_hat         error      percent error

----------------------------------------------------------------- 

   1.1        998          1005             7            1

   2.6       2108          2380           272           13

   3.2       3678          3360          -318           -9

   4.3       6087          6324           237            4

   6.2      22600         18852         -3748          -17

   8.8      75650         84040          8390           11

> y0:=exp(6.2802);

y0 := 533.9

> SSE:=sum((Y[k]-y_hat(X[k]))^2,k=1..6);

[Maple Math]

> DISTANCE:=sqrt(SSE);

[Maple Math]

Best- fitting curve: y = 533.9*exp(0.5749*x)