How to derive the least squares line of best fit formula

  • Level: Undergrad 
  • Thread starter Thread starter sutupidmath
  • Start date Start date
  • Tags Tags
    Fit Line
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
3 replies · 4K views
sutupidmath
Messages
1,629
Reaction score
4
Well, i am taking a first course in elementary statistics, so we do not actually prove anything at all. So i was wonderign how does one determine the line of best fit?
y=mx+b, where m is the slope of the line of best fit,
I know that the slope is equal to

m=SS(xy)/SS(x), where SS(x) is the sum of square of x, while SS(xy) the sum of the squares of x,y. also

b=[SUM(y)-m*SUM(x)]/n but i have no idea how one would come up with these expressions.
Can somebody show a proof for this, or just point me to the right direction?
 
Physics news on Phys.org
The proof reqires a knowledge of elementary calculus. Basic idea is to assume a straight line fit with m and b unknown. Set up the expression for the sum of the squares of the distances of the points from the line. Find m and b which minimize the expression.
 
Let μ and β be the least squares estimators of m and b in y = mx + b.

The estimated equation is then y[t] = β + μ x[t] + u[t] where u is the residual error and t indexes "data row" (e.g., observation).

u[t] = y[t] - (β + μ x[t])

u[t]^2 = (y[t] - (β + μ x[t]))^2

Sum over t:
Σt u[t]^2 = Σt (y[t] - (β + μ x[t]))^2

Now minimize with respect to μ and β by differentiating Σt u[t]^2 with respect to μ and β separately, setting each derivative to zero, then solving for μ and β that satisfy these two equations simultaneously:

∂Σt u[t]^2/∂μ = ∂Σt u[t]^2/∂β = 0.
 
Last edited:
EnumaElish said:
Let μ and β be the least squares estimators of m and b in y = mx + b.

The estimated equation is then y[t] = β + μ x[t] + u[t] where u is the residual error and t indexes "data row" (e.g., observation).

u[t] = y[t] - (β + μ x[t])

u[t]^2 = (y[t] - (β + μ x[t]))^2

Sum over t:
Σt u[t]^2 = Σt (y[t] - (β + μ x[t]))^2

Now minimize with respect to μ and β by differentiating Σt u[t]^2 with respect to μ and β separately, setting each derivative to zero, then solving for μ and β that satisfy these two equations simultaneously:

∂Σt u[t]^2/∂μ = ∂Σt u[t]^2/∂β = 0.

Thankyou for your replies! I totally forgot to let you know that i had managed to get to the result i wanted, my approach was almost identical with what u did, with the exception of notation, but i got to the result!

thnx both of you!