Solving for least square coefficients of power law

Click For Summary

Discussion Overview

The discussion revolves around the calculation of least square coefficients for a power law model, specifically examining the differences in results obtained through two different methods: one using logarithmic transformation and the other using the original data. The scope includes mathematical reasoning and technical explanation related to least squares fitting.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant presents a derivation for the coefficient A using logarithmic transformation of the power law equation, leading to a specific expression for A.
  • The same participant derives A without logarithmic transformation, resulting in a different expression for A.
  • Another participant points out that the two methods correspond to minimizing different objective functions, suggesting that they are not equivalent problems.
  • A later reply confirms that minimizing the log-transformed residuals does not yield the same coefficients as minimizing the original residuals, unless the data fits perfectly.
  • There is a question about whether a lower residual indicates a better fit, which is affirmed by another participant.

Areas of Agreement / Disagreement

Participants generally agree that the two methods yield different results and that they correspond to different problems. There is no consensus on the implications of these differences beyond the acknowledgment of the distinct approaches.

Contextual Notes

The discussion highlights the dependence on the choice of method for calculating least squares coefficients and the implications of using logarithmic transformations versus original data. The nuances of the mathematical derivations and the conditions under which they may yield similar results are not fully resolved.

Who May Find This Useful

Readers interested in statistical methods for fitting models, particularly in the context of power law relationships, and those exploring the implications of data transformations in regression analysis may find this discussion relevant.

enfield
Messages
20
Reaction score
0
y_i=A{x_i}^b

When I solve for A two different ways I am getting different answers..so somewhere I'm doing something wrong. If someone could point out where I would be grateful :).

Using logs:

y_i=A{x_i}^b
ln(y_i)=ln(A)+b*ln(x_i)
ln(y_i)-(ln(A)+b*ln(x_i))=r_i for least squares we want to minimize: S=\sum_i^{n}{r_i}^2 which means the gradient has to be zero. I only care about finding A right now so I only have to deal with the partial with respect to A:
\frac{\partial S}{\partial A}\sum_i^{n}{r_i}^2 =2 \sum_i^{n}{r_i}\frac{\partial r_i}{\partial A}= 2\sum_i^{n}(ln(y_i)-ln(A)-b*ln(x_i))\frac{1}{A}=0

The numerator inside the sum has to be zero, and we can ignore the 2, so:

\sum_i^{n}(ln(y_i)-ln(A)-b*ln(x_i))=0
\sum_i^{n}ln(y_i)-n*ln(A)-b\sum_i^{n}ln(x_i)=0
ln(A)=\frac{\sum_i^{n}ln(y_i)-b\sum_i^{n}ln(x_i)}{n}

(this is the derivation that I think is correct).
But when i solve for A without taking the logs of each side first I get something else:

y_i - A{x_i}^b = r_i\frac{\partial S}{\partial A}\sum_i^{n}{r_i}^2 =2 \sum_i^{n}{r_i}\frac{\partial r_i}{\partial A}= 2\sum_i^{n}(y_i - A{x_i}^b)*-{x_i}^b=0

\sum_i^{n}(-{x_i}{y_i} + A{x_i}^{2b})=0

-\sum_i^{n}{x_i}{y_i}+A\sum_i^{n}{x_i}^{2b}=0
A=\frac{\sum_i^{n}{x_i}{y_i}}{\sum_i^{n}{x_i}^{2b}}

And if you take the ln of it to compare it with what we got before you get:

ln(A)= ln(\frac{\sum_i^{n}{x_i}{y_i}}{\sum_i^{n}{x_i}^{2b}}) =ln(\sum_i^{n}{x_i}{y_i})-ln(\sum_i^{n}{x_i}^{2b})

Which is not the same as:

ln(A)=\frac{\sum_i^{n}ln(y_i)-b\sum_i^{n}ln(x_i)}{n}

as far as I can tell...
 
Physics news on Phys.org
That's because you solved two different problems.

Minimizing \sum[ln(y_i)-ln(A)-b*ln(x_i)]^2 is not necessarily the same thing as minimizing \sum(y_i - A{x_i}^b)^2. The 2nd method will result in a lower residual unless the data happen to fit the curve exactly (i.e. zero residual), in which case both will yield the same result.
 
Last edited:
Ah, thanks so much. Yeah, I had thought they were maybe different problems, but I couldn't see exactly how.

When you do least squares with the log of the data and function you are fitting to the data you won't get the same coefficients for the function that you would if you just did least squares with the unmodified data/function.

Okay, that makes sense. Does lower residual mean lower mean squared error, so better fit?
 
enfield said:
Does lower residual mean lower mean squared error, so better fit?
.

Yes. Two different words for the same thing.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
4K
  • · Replies 42 ·
2
Replies
42
Views
6K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
3K
  • · Replies 19 ·
Replies
19
Views
3K