I don't remember how to calculate the least squares regression line

SaturnX

Diamond Member
Jul 16, 2000
3,415
0
76
Wow, I just had a course on numerical methods... dry, but interesting nonetheless...

--Mark
 

silverpig

Lifer
Jul 29, 2001
27,703
12
81
Basically you define a line and then calculate the difference between your line and all of your data points and square those differences, sum them up. You keep trying different values for slope and y-intercept until you get a least-squares fit.
 

SaturnX

Diamond Member
Jul 16, 2000
3,415
0
76
Oh, well I didn't realize you were looking for how to actually do it... all you do, define a Vandermonde matrix with the data and solve the linear system.

--Mark
 

chuckywang

Lifer
Jan 12, 2004
20,133
1
0
You want to find the least squares solution x such that Ax ~= b where '~=' means 'least squres equal to'. That solution is:
x=(A'A)^(-1)*(A'b) where A' is the transpose of A.

Of course if you meant total least squares, than that's something else entirely.
 

chuckywang

Lifer
Jan 12, 2004
20,133
1
0
Originally posted by: SaturnX
Oh, well I didn't realize you were looking for how to actually do it... all you do, define a Vandermonde matrix with the data and solve the linear system.

--Mark

A Vandermonde matrix spans the space of all polynomials. He just wants to do least squares on linear functions.
 

chuckywang

Lifer
Jan 12, 2004
20,133
1
0
Originally posted by: RaynorWolfcastle
It's been a while since I looked at it, but isn't this just a simple projection problem?

Yes, it is. The least squares projection problem is a generalization of the linear regression line.
 

SaturnX

Diamond Member
Jul 16, 2000
3,415
0
76
Originally posted by: chuckywang
Originally posted by: SaturnX
Oh, well I didn't realize you were looking for how to actually do it... all you do, define a Vandermonde matrix with the data and solve the linear system.

--Mark

A Vandermonde matrix spans the space of all polynomials. He just wants to do least squares on linear functions.

Yeah, you can define a vandermonde for whatever degree you want... if you want a linear interpolation of it, simply compose a matrix of the linear values.. ie:

V = [x 1]

so you have a (n x 2) matrix, where n is the number of points you have.

--Mark

 

dannybek2

Senior member
Apr 12, 2005
213
0
0
Chi square and Cramers V....... ahhhhh Social stats, got an A in the class and I forgot everything I learned. Good luck with your crosstabs and multiple regression stuff.
 

dannybek2

Senior member
Apr 12, 2005
213
0
0
Anywho the formula is y=a+bx. Leave the x alone if you want it in equation form. Remember that a = the y-intercept b is the slope, x is the independent variable and y is the dependent.