I would like to fit an exponential decay function: y=A*exp(b*x)
I thought the best method would be to use the "nl" command, as in:
nl (y={A}*(exp({b}*x)))
But an alternative method should be to take the log of y first and the run a simple linear regression.
Because
ln(y)=ln(A*exp(b*x))
ln(y)=ln(A)+ln(exp(b*x))
ln(y)=ln(A)+b*x
Therefore, using
gen ln_y=ln(y)
reg ln_y x
should get me the same result.
But I don't get the same estimates of "b" under both approaches.
I am not very familiar with the "nl" command. So maybe I am not using it correctly?
Thanks
I thought the best method would be to use the "nl" command, as in:
nl (y={A}*(exp({b}*x)))
But an alternative method should be to take the log of y first and the run a simple linear regression.
Because
ln(y)=ln(A*exp(b*x))
ln(y)=ln(A)+ln(exp(b*x))
ln(y)=ln(A)+b*x
Therefore, using
gen ln_y=ln(y)
reg ln_y x
should get me the same result.
But I don't get the same estimates of "b" under both approaches.
I am not very familiar with the "nl" command. So maybe I am not using it correctly?
Thanks
Comment