Math problem: How do i find the slope of a best-fit-line (ie linear regression)?

abeal2

Senior member
Oct 7, 2004
208
0
0
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,601
167
111
www.slatebrookfarm.com
least squares regression.
google it... should be able to find a decent source that explains exactly how to do it.

If you have a TI83 or better graphing calculator, it should do it for you.
 

Born2bwire

Diamond Member
Oct 28, 2005
9,840
6
71
Fit the data using an interpolation algorithm and take the derivative of the algorithm. Then use the algorithm to find the points you want. I would suggest something like Neville's Algorithm, rather easy to do.
 

TheChort

Diamond Member
May 20, 2003
4,203
0
76
isn't this solvable with high school level math?
IE, plot the best fit line yourself by a best guess fit. Take two points from that line and find the slope.
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,601
167
111
www.slatebrookfarm.com
Again, google how to do a least squares regression manually...

Once upon a time, a long time ago (at least 15 or 20 years), we weren't allowed to use calculators to do least squares regression. It was a typical high school problem, and not a difficult one at that. Google how to do it...
 

b0mbrman

Lifer
Jun 1, 2001
29,470
1
81
Originally posted by: DrPizza
Again, google how to do a least squares regression manually...

Once upon a time, a long time ago (at least 15 or 20 years), we weren't allowed to use calculators to do least squares regression. It was a typical high school problem, and not a difficult one at that. Google how to do it...

Nope, not difficult at all. Out of those Google Results, I would start with the one from Tufts.edu
 

Kevin1211

Golden Member
Dec 14, 2004
1,582
0
0
take two points on the best fit line. The more farther away the two are, the better.. and simply take the change in y/change in x... thats how i learned to do it in physics when we had data
 

TheoPetro

Banned
Nov 30, 2004
3,499
1
0
doing a least squares fit on a set of data by hand blows. If I remember part of the equation involves partial differentiation and some matricies. All I remember is it sucking hardcore and taking forever. (Tedious not hard)
 

chuckywang

Lifer
Jan 12, 2004
20,133
1
0
Originally posted by: abeal2
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?

Linear least squares method.
 

WildHorse

Diamond Member
Jun 29, 2003
5,006
0
0
Originally posted by: abeal2
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?

If your line is straight then it's change in y divided by change in x, like Kevin1211 & FallenHero said [on a straight line it doesn't matter how far apart the 2 points are, slope is the same regardless];
(y2 - y1) / (x2 - x1).

If your line is curved then it's the 1st derivative of the line's equation.
 

DrPizza

Administrator Elite Member Goat Whisperer
Mar 5, 2001
49,601
167
111
www.slatebrookfarm.com
Originally posted by: scott
Originally posted by: abeal2
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?

If your line is straight then it's change in y divided by change in x, like Kevin1211 & FallenHero said [on a straight line it doesn't matter how far apart the 2 points are, slope is the same regardless];
(y2 - y1) / (x2 - x1).

If your line is curved then it's the 1st derivative of the line's equation.

Except, unless the equation of the line is known (in which case, it'd be silly to calculate the slope manually by picking two points), if the points are relatively close together, a small error in measuring either point will lead to a larger error on the slope. i.e. lines in the real world, based on data, rarely go through "nice" points like they did in algebra class. Points farther apart will result in less uncertainty for the actual slope.
 

WildHorse

Diamond Member
Jun 29, 2003
5,006
0
0
Originally posted by: DrPizza
Originally posted by: scott
Originally posted by: abeal2
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?

If your line is straight then it's change in y divided by change in x, like Kevin1211 & FallenHero said [on a straight line it doesn't matter how far apart the 2 points are, slope is the same regardless];
(y2 - y1) / (x2 - x1).

If your line is curved then it's the 1st derivative of the line's equation.

Except, unless the equation of the line is known (in which case, it'd be silly to calculate the slope manually by picking two points), if the points are relatively close together, a small error in measuring either point will lead to a larger error on the slope. i.e. lines in the real world, based on data, rarely go through "nice" points like they did in algebra class. Points farther apart will result in less uncertainty for the actual slope.


Text
 

chuckywang

Lifer
Jan 12, 2004
20,133
1
0
Originally posted by: abeal2
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?

It all depends on what you mean by "best fit".

As with any mathematical question, you have to be precise in your problem description.
 

WildHorse

Diamond Member
Jun 29, 2003
5,006
0
0
Originally posted by: chuckywang
Originally posted by: abeal2
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?

It all depends on what you mean by "best fit".

As with any mathematical question, you have to be precise in your problem description.

Text
 

chuckywang

Lifer
Jan 12, 2004
20,133
1
0
Originally posted by: scott
Originally posted by: chuckywang
Originally posted by: abeal2
if i have a bunch of data where they are scattered but will fit in a best fit line, how do i find the slope of it?

It all depends on what you mean by "best fit".

As with any mathematical question, you have to be precise in your problem description.

Text

What? It's an essential question if he wants to solve this problem.
 

WildHorse

Diamond Member
Jun 29, 2003
5,006
0
0
Originally posted by: chuckywang
< words cut >
What? It's an essential question if he wants to solve this problem.
As you know, "best fit line" is a term of art in mathemagic land.

That is to say, it has a specially defined and very precise meaning.

His "best fit line" equation defines his entire situation exactly.

All he needs is to learn how to go about teasing the info he wants out of it.