Xyius
- 501
- 4
So I am learning how to use the method of least squares to find the best fit straight line and there is this one part in the derivation I do not fully understand and I was wondering if anyone could help me out.
So basically we start out with the residuals of the equation of a straight line..
y_i-mx_i-c
And now we take the root mean square of these residuals and try to find the minimum points of m and c by taking the partial derivatives.
\Sigma (y_i-mx_i-c)^2
\frac{\partial S}{\partial m}=-2\Sigma x_i(y_i-mx_i-c)=0
\frac{\partial S}{\partial c}=-2\Sigma (y_i-mx_i-c)=0
Now from the second equation it is easy to see that
c=\overline{y}-m\overline{x}
since
\overline{y}=\frac{1}{n}\Sigma y_i
and
\overline{x}=\frac{1}{n}\Sigma x_i
Solving the first equation for m we get..
m=\frac{\Sigma x_i y_i -c\Sigma x_i}{\Sigma x_i ^2}
The part I do not understand is the book says that m is equal to..
m=\frac{\Sigma (x_i-\overline{x})y_i}{\Sigma (x_i-\overline{x})^2}
I feel like I must be missing something simple due to the books lack of explanation. Can anyone help me get this formula from the one I got for m? Why did the x_i's turn into (x_i-\overline{x})'s?? Did they made c=0 for some reason? Any help would be appreciated!
So basically we start out with the residuals of the equation of a straight line..
y_i-mx_i-c
And now we take the root mean square of these residuals and try to find the minimum points of m and c by taking the partial derivatives.
\Sigma (y_i-mx_i-c)^2
\frac{\partial S}{\partial m}=-2\Sigma x_i(y_i-mx_i-c)=0
\frac{\partial S}{\partial c}=-2\Sigma (y_i-mx_i-c)=0
Now from the second equation it is easy to see that
c=\overline{y}-m\overline{x}
since
\overline{y}=\frac{1}{n}\Sigma y_i
and
\overline{x}=\frac{1}{n}\Sigma x_i
Solving the first equation for m we get..
m=\frac{\Sigma x_i y_i -c\Sigma x_i}{\Sigma x_i ^2}
The part I do not understand is the book says that m is equal to..
m=\frac{\Sigma (x_i-\overline{x})y_i}{\Sigma (x_i-\overline{x})^2}
I feel like I must be missing something simple due to the books lack of explanation. Can anyone help me get this formula from the one I got for m? Why did the x_i's turn into (x_i-\overline{x})'s?? Did they made c=0 for some reason? Any help would be appreciated!