What Is a Regression Line?
People usually mean one of two things here: the line on a scatter plot that sums up a trend, or the equation behind it. The short answer is that it is the single straight line that comes closest to all your dots at once. Close is measured by squaring the vertical gaps between each dot and the line, then adding them up. The line that makes that total as small as possible wins. That is why stats folks call it the least squares line.
What does the regression line formula mean?
The line is written as y = mx + b. Here m is the slope, which tells you how much y changes when x goes up by one. The b is the intercept, the value of y when x is zero. Swap in stats notation and it shows up as y = a + bx, which is the same thing wearing a different hat.
How do you find the regression line?
For a simple line you need the slope and the intercept:
- Slope m = (n times the sum of xy minus the sum of x times the sum of y) divided by (n times the sum of x squared minus the sum of x, squared).
- Intercept b = (sum of y minus m times the sum of x) divided by n.
- n is just how many data points you have.
Doing that by hand is fine for small sets. A calculator handles it faster, which is why the site has one.
Regression line example
Say you track hours studied and test scores for five students:
| Hours (x) | Score (y) |
|---|---|
| 1 | 50 |
| 2 | 55 |
| 3 | 65 |
| 4 | 70 |
| 5 | 80 |
Run the numbers and you get a slope of about 7.5 and an intercept of about 42.5, so the line is y = 7.5x + 42.5. Study 4 hours and the line predicts a score near 72.5.
What does the regression line not tell you?
It shows a pattern, not a cause. Two things can move together without one making the other happen. It also only describes the range of your data. Predicting far outside that range is a stretch. A famous version of this is Anscombe's quartet, four datasets that look nearly identical in summary numbers but plot very differently. The lesson: always look at the dots.
Do the math: open the regression calculator