# The line of best fit. Need help?

1. Feb 22, 2008

### sutupidmath

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?

2. Feb 22, 2008

### mathman

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.

3. Feb 27, 2008

### EnumaElish

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: Feb 27, 2008
4. Feb 27, 2008

### sutupidmath

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!