1
$\begingroup$

I plotted my data on a natural log-log scale and I seem to get a okay fit to the data with y=1.19 - 0.116x with Rsq = 0.29

enter image description here

I want to use the parameters but plot the row data with an exponential curve. Using my knowledge of exponents, I exponentiated both sides and tried to plot a curve of y ~ (-1.12 x) + 3.2 ...but I did not get a fit. I played around with some more functions, and the only fit I could get to work was this

enter image description here

    ggplot(data=df,aes(x=x.number,y=y.size)) + geom_point() + 
           stat_smooth(method="nls", formula =  y~(a*exp(-x*b) + 
           c),method.args=list(start=c(a=10, b=0.05, c=3)), se=F, 
           color="red") + stat_smooth(method="lm", formula =  
           y~a*exp(-x*b) + c , se=F, color="blue")

The formulae seems to require additional terms and the starting values are vastly different. I am trying to reconcile with the fits and I'm not sure how to go about it

$\endgroup$
3
  • 1
    $\begingroup$ 1. Please clarify log10 or natural log, to make sure the antilog transform is correct. 2. How did you transform the line to generate the curve that you said didn't work. The linear fit on the log log axes will be a curve on the back-transformed axes. $\endgroup$ May 3, 2021 at 15:59
  • $\begingroup$ 1. I used natural log 2. I exponentiated on both sides of the linear log-log equation. So exp^(1.19 - 0.116 log(x))) which is exp(1.19) - exp(0.116 log(x)) which is 3.18 - 1.12 x ---> which is a linear line?? Am I doing something extremely stupid? $\endgroup$
    – slicer
    May 3, 2021 at 17:07
  • 2
    $\begingroup$ Your knowledge of logs and exponentials is incorrect. In particular, $\exp(1.19-0.116\log(x))=\exp(1.19)x^{0.116}.$ $\endgroup$
    – whuber
    May 3, 2021 at 18:08

1 Answer 1

1
$\begingroup$

For this response, I will the base-2 logarithm. If you obtained the regression parameters

  • slope: -0.116
  • intercept: 1.19

after transforming $(x,y)$ to $(\log_2(x),\log_2(y))$, then we have the following model $$\log_2(y) = 1.19 - 0.116\log_2(x) + \epsilon$$ which can be rewritten as $$y = \frac{2^{1.19}\cdot2^\epsilon}{x^{0.116}}$$

The log-log transform is often called the power model because it estimates a power-relationship between the $x$ and $y$ variables.

With regards to fitting the untransformed data to the original points, you must take into account the $2^\epsilon$ factor which models the error of the estimation. In the linear regression, the residual standard error gives the spread of the error term, the distribution of $\epsilon$. It is centered at zero (which transforms to a multiplicative factor of $2^0=1$), and we assume a normal distribution. This means the "error" scaling factor would range from $2^{-2\epsilon}$ and $2^{2\epsilon}$ (for roughly the "middlemost" 95% of the values).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.