Residual plots
Learn to build and read residual plots for Year 12 General Mathematics in Queensland (QCAA). A least-squares line can be drawn through any scatterplot, but that does not make it a good model. Downloads of a new app, for example, can climb faster and faster, and a straight line will miss that curve even when \(r\) looks strong.
You will calculate each residual as actual minus predicted, explain what a positive or negative residual says about a point, and plot the residuals against \(x\). Random scatter around zero means a linear model fits; a curve or other pattern means it does not. Next, you will interpret the slope and intercept of a line that passes this test.
Theory
A residual plot shows how far each point sits above or below a least-squares line. This guide for Year 12 General Mathematics in Queensland shows how to calculate residuals, construct the plot, and use the pattern to decide whether a linear model is appropriate.
When a least-squares line \(y = mx + c\) is fitted to data, each data point has a predicted value (from the line) and an actual value (from the data). The residual is the difference: actual value minus predicted value.
A positive residual means the point lies above the line, so the line under-predicted. A negative residual means the point lies below the line, so the line over-predicted. A residual of zero means the point is on the line. For a least-squares line, the residuals always add to zero.
A residual plot graphs each residual (vertical axis) against the explanatory variable \(x\) (horizontal axis), with a horizontal line at zero. It shows whether a straight line is a good model for the data. A single residual much larger in size than all the others marks a possible outlier: the point furthest from the line.
The residual for each data point:
The predicted value comes from substituting \(x\) into the least-squares line:
For a least-squares line, the residuals always balance out:
Constructing and reading a residual plot
- Predict. Substitute each \(x\)-value into \(y = mx + c\) to get the predicted value.
- Subtract. Residual \(=\) actual \(-\) predicted. Keep the sign. As a check, the residuals should add to zero (or very close, after rounding).
- Plot. Put \(x\) on the horizontal axis and the residual on the vertical axis. Draw the zero line.
- Judge. Random scatter with no pattern means a linear model is appropriate. A curve or other clear pattern means it is not.
Find the predicted value from the line, then subtract it from the actual value.
| \(\text{predicted}\) | \(=\) | \(0.6 \times 40 + 14\) |
| \(\text{predicted}\) | \(=\) | \(24 + 14\) |
| \(\text{predicted}\) | \(=\) | \(38 \text{ L}\) |
| \(\text{residual}\) | \(=\) | \(\text{actual} - \text{predicted}\) |
| \(\text{residual}\) | \(=\) | \(36.5 - 38\) |
| \(\text{residual}\) | \(=\) | \(-1.5 \text{ L}\) |
The residual is \(-1.5\) L. It is negative, so this point lies below the line: the line over-predicted the fuel used by \(1.5\) L.
| Lessons, \(x\) | 2 | 4 | 6 | 8 | 10 | 12 |
|---|---|---|---|---|---|---|
| Time, \(y\) (s) | 35.5 | 35 | 32.5 | 27 | 26 | 21 |
For each \(x\), the predicted time is \(-1.5x + 40\). Then residual \(=\) actual \(-\) predicted:
| \(x\) | actual | predicted | residual |
|---|---|---|---|
| \(2\) | \(35.5\) | \(37\) | \(-1.5\) |
| \(4\) | \(35\) | \(34\) | \(1\) |
| \(6\) | \(32.5\) | \(31\) | \(1.5\) |
| \(8\) | \(27\) | \(28\) | \(-1\) |
| \(10\) | \(26\) | \(25\) | \(1\) |
| \(12\) | \(21\) | \(22\) | \(-1\) |
| \(\text{sum of residuals}\) | \(=\) | \((-1.5) + 1 + 1.5 + (-1) + 1 + (-1)\) |
| \(\text{sum of residuals}\) | \(=\) | \(0\) |
The residuals are scattered randomly above and below zero with no pattern, so a linear model is appropriate.
| Week, \(x\) | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Downloads, \(y\) (thousand) | 2 | 3 | 5 | 8 | 12 | 18 |
Predicted \(= 3.14x - 3\). Then residual \(=\) actual \(-\) predicted:
| \(x\) | actual | predicted | residual |
|---|---|---|---|
| \(1\) | \(2\) | \(0.14\) | \(1.86\) |
| \(2\) | \(3\) | \(3.28\) | \(-0.28\) |
| \(3\) | \(5\) | \(6.42\) | \(-1.42\) |
| \(4\) | \(8\) | \(9.56\) | \(-1.56\) |
| \(5\) | \(12\) | \(12.7\) | \(-0.7\) |
| \(6\) | \(18\) | \(15.84\) | \(2.16\) |
The residuals are positive, then negative, then positive again: a clear U-shaped pattern. A linear model is not appropriate, even though \(r = 0.96\) is strong. The downloads are growing faster each week, so the data are curved.
(a) Find the fifth residual.
(b) The fifth point has \(x = 15\). Find its actual \(y\)-value.
(a) Least-squares residuals add to zero. (b) Rearrange: actual \(=\) predicted \(+\) residual.
| \(1.3 + (-0.8) + 2.1 + (-1.9) + r\) | \(=\) | \(0\) |
| \(0.7 + r\) | \(=\) | \(0\) |
| \(r\) | \(=\) | \(-0.7\) |
| \(\text{predicted}\) | \(=\) | \(1.2 \times 15 + 5\) |
| \(\text{predicted}\) | \(=\) | \(23\) |
| \(\text{actual}\) | \(=\) | \(23 + (-0.7)\) |
| \(\text{actual}\) | \(=\) | \(22.3\) |
(a) The fifth residual is \(-0.7\). (b) The actual value is \(y = 22.3\), just below the line.
Common pitfalls
Frequently asked questions
What is a residual in statistics?
A residual is the actual value of the response variable minus the value predicted by the least-squares line. Positive means the point is above the line; negative means it is below.
How do you construct a residual plot?
Work out the predicted value for each x using y = mx + c, subtract it from the actual y-value to get the residual, then plot each residual against its x-value with a horizontal line at zero.
What does a good residual plot look like?
The residuals are scattered randomly above and below the zero line, with no curve, trend or other pattern. That shows a linear model is appropriate for the data.
What does a curved pattern in a residual plot mean?
It means the relationship between the variables is not linear, so a straight line is not an appropriate model, even if the correlation coefficient is strong.
Why do the residuals add up to zero?
The least-squares line passes through the mean point and balances the points above it against the points below it, so the positive and negative residuals always cancel out.
Can r be close to 1 when a linear model is not appropriate?
Yes. Curved data that rise steadily can give r above 0.9. The residual plot, not r, tells you whether the form of the data is linear.