STEM-TutorLearn • Practice • ExcelBook Free DemoFree demo

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
  1. The least-squares regression line
  2. Interpreting the slope and intercept
  3. Residuals
  4. Residual plots
  5. Correlation r and r²
  6. Reading computer output
  7. Conditions for using the line
  8. Outliers, influential points and extrapolation
  9. Common mistakes
  10. Practice questions
  11. Frequently asked questions
  12. Key takeaways
  13. Related guides
hours studiedscoreŷ = 40 + 6x
A scatterplot with a least-squares regression line. The slope (6) is the predicted change in score for each extra hour studied.

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:

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.

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.

Residual plots

A residual plot shows residuals against x (or against ŷ). It is the best way to check whether a linear model is appropriate.

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.

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

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

Practice questions

Try each one before opening the answer.

Q1. ŷ = 12 + 3.5x. Find the predicted y when x = 4.

Show answer
26.

Q2. Using the same line, a point has x = 4 and y = 22. Find the residual.

Show answer
22 − 26 = −4: the model overestimated.

Q3. r² = 0.81 and the slope is negative. Find r.

Show answer
r = −0.9.

Q4. A residual plot shows a clear U shape. What does that mean?

Show answer
The relationship is not linear; a linear model is not appropriate.

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