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,+
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.

  • $\begingroup$ in which language? $\endgroup$ Feb 16, 2014 at 11:00
  • $\begingroup$ R would be nice. $\endgroup$ Feb 16, 2014 at 11:00
  • $\begingroup$ for example it may help in R language r.789695.n4.nabble.com/R-exponential-regression-td1009449.html $\endgroup$ Feb 16, 2014 at 11:00
  • $\begingroup$ 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. $\endgroup$ Feb 16, 2014 at 11:13
  • $\begingroup$ 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! $\endgroup$ Feb 16, 2014 at 14:02

2 Answers 2


My results, with all détails :

enter image description here

  • $\begingroup$ Looks interesting. Can you post a code? $\endgroup$ Feb 16, 2014 at 13:00
  • $\begingroup$ There is no code : All is on the sheet. This is the screen copy of what is done with mathcad, nothing more. You just have to rewrite the equations, sums, matrix, ... in any other computer language that you want. And you can check each step with the values show on the sheet. $\endgroup$
    – JJacquelin
    Feb 16, 2014 at 14:24

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$.

  • $\begingroup$ 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) $\endgroup$ Feb 16, 2014 at 13:09
  • $\begingroup$ @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. $\endgroup$ Feb 16, 2014 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .