# Find parameters for curve fitting (simple linear regression involved?)

I would like to fit data in g~t scatterplot, where

g <- c(1.038459504,1.019448815,1.017729187,1.010076583,1.00895011,1.007841198,+
+1.006566597,1.009939696,1.003751382)
t <- c(3,4,5,6,7,8,9,10,11)


with g=exp(a+b*t) curve. How can I estimate a and b using linear regression?

The solution from handbook is a=-2.390289, b=-0.326016, R^2 = 0.88644 and g = 1 + exp(-2.390289 - 0.326016*t), which gives fairly good estimations (you can see on this graph that this curve seems to be good at fitting data above).

I have not a clue how they compute a and b and why it is g=1+exp(a+b*t) now. Any idea? I suppose it has something to do with transformation into (ln g) = a + b*t in order to regress the data.

PS: I did ask quite a similar question yesterday, but now it should be more clear what I want to figure out.

• in which language? – dato datuashvili Feb 16 '14 at 11:00
• R would be nice. – emil zatopek Feb 16 '14 at 11:00
• for example it may help in R language r.789695.n4.nabble.com/R-exponential-regression-td1009449.html – dato datuashvili Feb 16 '14 at 11:00
• I specified model as ´f <- function(x,a,b) {exp(a+b*x)}´ but I'm getting different values of a and b, by far. – emil zatopek Feb 16 '14 at 11:13
• You should probably rewrite your first definition of g; it should indicate the required constant 1: $g=1+\exp(a+b*t)$ - otherwise one gets completely different coefficients! – Gottfried Helms Feb 16 '14 at 14:02

There is no reason for this extra $1$. Just start again : you want to fit $g=e^{a+b x}$ which non linear. You properly make the transform $\log (g)=a+b x$ which is linear. So, a linear regression provides the value of $a$ and $b$ for the linearized model. Use these values as initial estimates for the fit of $g=e^{a+b x}$ starting from scratch.
May be they changed the model to $g=1+e^{a+b x}$ because all your numbers are close to $1$. If this is the case, then the linear model should be $\log (g-1)=a+b x$.
• For problems like this I think it should always be mentioned that this optimizes the error for the transformed values $a+bx$ but not really for $g$. So there might be different $a,b$ for which the sum-of-squared-error for the estimate of $g$ is smaller. There are (demo-) versions of software online available which provide true nonlinear fit (I think I had "prism" or "graphprism" sometimes downloaded and the manual explained this very well) – Gottfried Helms Feb 16 '14 at 13:09
• @GottfriedHelms. I totally agree with you. In any manner, the parameters obtained from a linearized model are nothing except resonable estimates for the real model. I never saw any measurement of $log(Z-1)$, $Z$ being any physical property. You are totlly right when you address the point of the sum of squares in the linearized model vs the sum of squares in the true model. Cheers. – Claude Leibovici Feb 16 '14 at 13:14