Fitting power law with loglog or exponential?

337 Views Asked by At

I have $x$- and $y$-data, and I want a power-law fit ($y=ax^b$). I always fit $\log(x)$ and $\log(y)$ by $p_1x+p_2$ (Matlab poly1), but when I fit $x$ and $y$ with $p_1x^{p_2}$, I did not get exactly the same result. Why?!

And what is the best way for doing this? First take logs then linear fit??

1

There are 1 best solutions below

2
On

Almost as Count Iblis commented, when you use least-squares methods, you want to minimize $$SSQ_1=\sum_{i=1}^n \left(y_i^{(calc)}-y_i^{(exp)} \right)^2$$ When you linearized the model, you minimize $$SSQ_2=\sum_{i=1}^n \left(\log\left(y_i^{(calc)}\right)-\log\left(y_i^{(exp)}\right) \right)^2$$ $$\log\left(y_i^{(calc)}\right)-\log\left(y_i^{(exp)}\right)=\log\left(\frac{y_i^{(calc)} }{y_i^{(exp)} } \right)=\log\left(1+\frac{y_i^{(calc)} -y_i^{(exp)}}{y_i^{(exp)} } \right)$$ If the errors are "small", using $\log(1+\epsilon)\sim \epsilon$, you then have $$\log\left(y_i^{(calc)}\right)-\log\left(y_i^{(exp)}\right) \sim \frac{y_i^{(calc)} -y_i^{(exp)}}{y_i^{(exp)} }$$ which means that $$SSQ_2 \sim \sum_{i=1}^n \left(\frac{y_i^{(calc)} -y_i^{(exp)}}{y_i^{(exp)} } \right)^2$$ which means that, using linearization and $SSQ_2$, you minimize more or less the sum of the squares of the relative errors while, using $SSQ_1$ you minimize the sum of the squares of the absolute errors.

For illustration purposes, let us consider the following data set $$ \left( \begin{array}{cc} x & y \\ 1 & 15 \\ 2 & 30 \\ 3 & 52 \\ 4 & 80 \\ 5 & 125 \\ 6 & 200 \end{array} \right)$$ and for simplicity use the model $y=e^{a+bx}$. If we take logarithms and perform the linear regression we shall get $$\log(y)=2.32851+0.504671 x\tag 1$$ to which will correspond $SSQ_2=0.03665$.

Using the nonlinear regression, we shall get $$y=\exp({2.49690+0.467135 x})\tag 2$$ which, as you noticed, shows different values for the parameters.

Now, let us perform the nonlinear regression using $$SSQ_3=\sum_{i=1}^n \left(\frac{y_i^{(calc)} -y_i^{(exp)}}{y_i^{(exp)} } \right)^2$$ We shall obtain $$y=\exp({2.30824+0.507829 x})\tag 3$$ Observe how close are the parameters in $(1)$ and $(3)$. Moreover, $SSQ_3=0.03676$ so close to $SSQ_2$ !

In any manner, when you face nonlinear regression prolems, you need stimates of the parameters to be tuned. Linearization (when possible) is the way to go. But, when you have the estimates, you must continue with the nonlinear regression since what is measured is $y$ and not any of its possible transforms.