The Least-Squares Regression Line
Of all the lines you could draw through a scatter plot, the regression line is the one whose vertical misses, squared and added up, are as small as possible. It always runs through the center point , and its slope is just the correlation converted into the units of and .
What the symbols mean
- Predicted y
What the line predicts for a given x.
- Slope
Predicted change in y for each 1-unit increase in x.
- Intercept
Predicted y when x = 0 (meaningful only if x = 0 makes sense).
Explanation
The regression line is simply the best straight line through a scatter plot, the one you'd use to predict from . The odd name comes from Francis Galton, who noticed that tall fathers' sons tend to be less tall, "regressing" toward the average; the word stuck to the whole method. The formulas are short: (an ordinary line, with the hat meaning "predicted"), (the slope, which is the correlation rescaled into real units) and (the intercept, chosen so the line passes through the averages). Three small formulas, and you've got your line.
Least squares. For any line, the residuals are the vertical misses. The regression line minimizes . Why squared? For the same reason as in the standard deviation: misses above and below the line shouldn't cancel, and squaring also punishes big misses more than small ones. Calculus gives the slope , which equals . There's a picture further down where each squared miss is drawn as an actual square.
Why ? Think in z-scores, as in the last lesson. In z-score units the best line has slope exactly : one standard deviation up in predicts standard deviations up in . To convert back to real units, multiply by (to get 's units) and divide by (to undo 's). That's all the formula is.
Interpreting the slope: "each additional hour of study is associated with more points, on average." Associated, not caused, unless the data come from an experiment.
Regression toward the mean. Since , an x value 2 standard deviations above average predicts a y value only standard deviations from average. That's Galton's tall fathers: unless the correlation is perfect, extreme values of predict less extreme values of .
A common mistake. It's tempting to read the intercept as meaningful every time. It's only the prediction at , and often is far outside the data (a house with 0 square feet, a car with negative age). Then the intercept is just where the line happens to cross the axis.
See it
Worked examples
Find the regression line for , , , , .
- 1
We already have the sums from the correlation example: .
Practice
Type your answer and check it. Solve them all to complete the lesson.
Find the slope of the regression line for , , , , .
Find the intercept.
Use the line to predict at .
If , and , find the slope.
The regression line always passes through:
A dealership's data give the regression line for a car's price after years. Predict the price of a 4-year-old car.
In the picture, the total squared error for slope is . Which slope minimizes it?
The hardest one here. Get it, and you've got this lesson.
Fathers' and sons' heights both have mean 175 cm and standard deviation 7 cm, with correlation 0.5. Predict the height of a son whose father is 189 cm tall.
Where it's used
Regression predicts house prices from size, crop yields from rainfall and sales from ad spending, and it's the first model every data scientist fits.