Lesson 6: Least-Squares Regression — Fitting a Line
When a scatterplot shows a linear association, the natural next step is to summarize it with a line — but which line? The least-squares regression line is the line that makes the total squared vertical distance from the points to the line as small as possible, and it is the standard summary of a linear relationship. Its equation is written ŷ = a + bx, where ŷ is the predicted value of the response variable, b is the slope, and a is the y-intercept. The line is a model: it describes the average response for a given value of the explanatory variable.
The slope and intercept have plain-language meanings that free-response answers must state in context. The slope, b, is the predicted change in the response for a one-unit increase in the explanatory variable, and it is computed as b = r × (sy / sx), linking the line to the correlation and the two standard deviations. The intercept, a, is the predicted response when the explanatory variable is zero, and it is computed as a = ȳ − b x̄, which also tells you that the regression line always passes through the point of the two means, (x̄, ȳ). Be careful: if zero is far outside the observed range of x, the intercept may be a meaningless extrapolation.
A regression line is only as good as the linear pattern it summarizes, and its most basic check is the scatterplot itself. If the points curve, a line is the wrong model no matter how carefully it is fitted, and the correlation will mislead you. Also remember that the line is fitted to the data you have: using it to predict for x-values far outside the observed range is called extrapolation, and it is dangerous because the relationship may change shape beyond the data. Predicting inside the range is interpolation, and it is much safer, though still only an average prediction, not a guarantee for any one individual.
The square of the correlation, r², measures how much of the variation in the response the line explains. If r = 0.8, then r² = 0.64, meaning about 64% of the variation in the response is accounted for by the linear relationship with the explanatory variable, and the remaining 36% is left in the residuals. A high r² does not prove the model is correct — a curved pattern can still have a high r² — and a low r² does not prove there is no relationship, only that a line does not capture it. Always report r² in context, as a percentage of variation explained.
A worked example
Worked example: return to the worked-example study data from the previous lesson, where the mean hours studied is 6.5 with standard deviation about 3.03, the mean score is 76.3 with standard deviation about 12.6, and the correlation is about 0.99. The slope is b = 0.99 × (12.6 / 3.03), about 4.1, so each extra hour of study is associated with a predicted increase of about 4.1 points. The intercept is a = 76.3 − 4.1 × 6.5, about 49.6, so the line is ŷ = 49.6 + 4.1x. For a student who studies 8 hours, the predicted score is about 82.4, and r² is about 0.98, so about 98% of the variation in scores is explained by the linear relationship with hours studied.
In an exam answer, write the regression equation with the variables named, interpret the slope in context with units, and say whether the intercept is meaningful. If the intercept corresponds to an x-value of zero that makes no sense — zero hours studied might be plausible, but zero height is not — say so rather than inventing an interpretation. And never use the line to predict far beyond the data: a line fitted to study times of 2 to 11 hours says nothing reliable about 40 hours of study. The next lesson shows how to check the line's fit by examining what it leaves behind.
Key Terms
- Least-squares regression line
- The line minimizing the sum of squared vertical distances from the points; written ŷ = a + bx.
- Slope (b)
- The predicted change in the response for a one-unit increase in the explanatory variable.
- Intercept (a)
- The predicted response when the explanatory variable is zero; a = ȳ − b x̄.
- Extrapolation
- Predicting outside the observed range of the explanatory variable; unreliable.
- r² (coefficient of determination)
- The proportion of variation in the response explained by the linear relationship with x.
Discussion Questions
- Why does the regression line always pass through the point of the two means?
- A slope is 2.5. Does that mean the response increases by exactly 2.5 for every one-unit increase in x?
- When would you refuse to interpret the intercept?
Practice Questions
- A regression line is ŷ = 10 + 3x. Predict y when x = 5.
- If r = 0.6, what percentage of the variation in y is explained by the linear relationship with x?
- The slope of a regression line is −0.8. Interpret it in words.
- Data on x run from 10 to 30. A student uses the line to predict y at x = 100. What is this called, and why is it risky?
- If the correlation is 0, what is the slope of the regression line?
Show answers
- ŷ = 10 + 3 × 5 = 25.
- r² = 0.36, so about 36%.
- Each one-unit increase in x is associated with a predicted decrease of 0.8 units in y.
- Extrapolation. The relationship may not stay linear outside the observed range.
- 0, since b = r × (sy / sx) and r = 0, so the line is flat at ŷ = ȳ.