Linear regression and residuals, explained
Linear regression fits a straight line through data to describe and predict a relationship between two quantitative variables. Residuals tell you how well that line fits. Both appear on every AP Statistics exam.
On this page
- The least-squares regression line
- Interpreting the slope and intercept
- Residuals
- Residual plots
- Correlation r and r²
- Reading computer output
- Conditions for using the line
- Outliers, influential points and extrapolation
- Common mistakes
- Practice questions
- Frequently asked questions
- Key takeaways
- Related guides
The least-squares regression line
The least-squares regression line (LSRL) is the line that makes the sum of the squared residuals as small as possible. It is written
ŷ = a + bx
where ŷ (“y-hat”) is the predicted value of y, b is the slope and a is the y-intercept. The slope can be calculated from summary statistics: b = r (sy/sx), and the line always passes through the point of means (x̄, ȳ), so a = ȳ − b x̄.
Interpreting the slope and intercept
AP questions almost always ask for interpretations in context. Use these templates:
- Slope: “For each additional 1 [unit of x], the predicted [y] increases (or decreases) by b [units of y].”
- Intercept: “When [x] is 0, the predicted [y] is a [units].” Add a comment if x = 0 is outside the data and the intercept has no practical meaning.
The word “predicted” matters. The line describes a trend, not a rule every data point follows.
Example 1: building the line
Hours studied (x) and test score (y): x̄ = 5, sx = 2, ȳ = 70, sy = 15, r = 0.8. Find the LSRL.
- b = 0.8 × 15/2 = 6.
- a = 70 − 6 × 5 = 40.
- ŷ = 40 + 6x: for each extra hour studied, the predicted score rises by 6 points, as in the diagram.
Residuals
A residual is the difference between an actual value and the value the line predicts:
residual = y − ŷ (actual minus predicted)
A positive residual means the point is above the line: the model underestimated. A negative residual means it is below the line: the model overestimated. The residuals from a least-squares line always add up to zero, which is a handy check when you calculate several by hand.
Example 2: a residual
Using ŷ = 40 + 6x, a student who studied 6 hours scored 81. Find and interpret the residual.
- Predicted: 40 + 36 = 76. Residual = 81 − 76 = 5.
- The student scored 5 points higher than the model predicted.
Residual plots
A residual plot shows residuals against x (or against ŷ). It is the best way to check whether a linear model is appropriate.
- Random scatter with no pattern, evenly spread above and below zero: a linear model is appropriate.
- A curved pattern, such as a U shape: the relationship is not linear, so a curved model would be better.
- A fan shape, where residuals spread out as x increases: predictions are less reliable for larger x.
Correlation r and r²
The correlation coefficient r measures the strength and direction of a linear relationship. It lies between −1 and 1, has no units, and is not changed by switching x and y or changing units. r near ±1 is strong; near 0 is weak.
The coefficient of determination r² tells you the proportion of the variation in y that is explained by the linear model. Interpretation template: “About [r² as a %] of the variation in [y] is accounted for by the linear relationship with [x].”
The standard deviation of the residuals, s, gives the typical prediction error: “The actual [y] typically differs from the predicted value by about s [units].”
Example 3: interpreting r² and s
A regression has r² = 0.64 and s = 6.2 points. Interpret both.
- About 64% of the variation in test scores is accounted for by the linear relationship with hours studied.
- Actual scores typically differ from predicted scores by about 6.2 points.
Reading computer output
AP questions often show regression output from software. The “Constant” row gives the intercept a, and the row named after the explanatory variable gives the slope b, both in the “Coef” column. The output also lists R-sq (r²) and S (the standard deviation of the residuals). To find r, take the square root of r² and give it the sign of the slope.
Conditions for using the line
Before trusting predictions from a regression line, check four things. The scatterplot should show a roughly linear form. The residual plot should show no pattern. There should be no extreme outliers or influential points distorting the line. And predictions should stay within the range of the data. When all four hold, the line gives a useful summary and reasonable predictions; when they fail, say so in your answer, because AP readers reward that judgement.
Outliers, influential points and extrapolation
- An outlier has a large residual: it lies far from the line.
- A high-leverage point has an x-value far from the others.
- An influential point changes the slope, intercept or r substantially when removed. High-leverage points are often influential.
- Extrapolation, predicting outside the range of the data, is unreliable because the pattern may not continue.
And always remember: correlation does not prove causation. Only a well-designed experiment, with random assignment to treatments, can show cause and effect.
Common mistakes
- Interpreting the slope without the word “predicted” or without context.
- Calculating residuals as predicted minus actual instead of actual minus predicted.
- Concluding a linear model is good just because r is high, without checking the residual plot.
- Interpreting r² as the percentage of points on the line.
- Claiming causation from observational data.
Practice questions
Try each one before opening the answer.
Q1. ŷ = 12 + 3.5x. Find the predicted y when x = 4.
Show answer
Q2. Using the same line, a point has x = 4 and y = 22. Find the residual.
Show answer
Q3. r² = 0.81 and the slope is negative. Find r.
Show answer
Q4. A residual plot shows a clear U shape. What does that mean?
Show answer
Frequently asked questions
Is regression on the AP Statistics exam?
Yes. It is in Unit 2 (exploring two-variable data), and inference for the slope appears in Unit 9. A regression question is very common on the free-response section.
Do I need to calculate the LSRL by hand?
Usually you use a calculator or given output, but you should know b = r(sy/sx) and that the line passes through (x̄, ȳ), because questions test these facts directly.
Key takeaways
- ŷ = a + bx, with b = r(sy/sx) and the line through (x̄, ȳ).
- Residual = actual − predicted.
- Random residual plots support a linear model.
- r² is the proportion of variation in y explained by the model.
- Avoid extrapolation; correlation is not causation.