Predicting and residuals
What this lesson covers
- Residual = actual − predicted.
- Interpolation is inside the data range.
- Extrapolation beyond it is risky.
Using y = 47.7 + 4.1x
- Predict for 2.5 hours.
- y = 47.7 + 4.1 × 2.5
- y = 57.95 marks
A residual
- The student at x = 3 scored 61.
- predicted = 60
- residual = 61 − 60 = 1
Going too far
- Predict for x = 20.
- y = 47.7 + 82 = 129.7
- That is above 100, so the model has failed
Statistics explorer
Seeing residuals
- A residual is the vertical gap from a point to the line. Points above the line have positive residuals.
Try it: residuals and the residual plot
Seeing extrapolation
- The line carries on for ever. The students do not, and full marks stops at 100.
Try it: predicting too far
Try it: predict, residual, too far
Common mistakes
- Taking predicted − actual.Residual is actual − predicted.
- Trusting a prediction far outside the data.State the range the model was built on.
Your turn
For y = 10 + 2x, predict y when x = 6.
The actual value at x = 6 is 25. Find the residual.
A point has a positive residual. Where is it?
Data covers x from 1 to 5. Predicting at x = 8 is what?
A student wrote residual = predicted − actual = 30 − 34 = −4. What is the correct residual?
Point A has residual +5 and point B has residual −8. Which is true?
For y = 5 + 3x, a point at x = 4 has residual −2. What is its actual y value?
Marks out of 100 fit y = 47.7 + 4.1x for 1 to 5 hours of study. Predict for 15 hours. What should you conclude?
Show answer
1. 22 2. 25 − 22 = 3 3. Above the line 4. Extrapolation 5. 4. Residual = actual − predicted, so 34 − 30 = 4. 6. B is further from the line, below it: the size 8 is bigger than 5, and a negative residual means below the line. 7. 15. Predicted = 5 + 3 × 4 = 17, and actual = predicted + residual = 17 − 2 = 15. 8. 109.2 marks, so the model fails here: 47.7 + 4.1 × 15 = 109.2, which is above 100 and far outside the data.
Sample question: Achieved
A Mount Maunganui dairy records the noon temperature x (°C) and ice blocks sold y on six days: (16, 40), (18, 52), (20, 58), (22, 71), (24, 80), (26, 87). The least squares line is y = −34.9 + 4.74x. Predict the sales on a 21 °C day. On the 22 °C day, 71 ice blocks were sold: find the residual and say what it means.
Hint
Substitute x into the line to predict. Residual = actual − predicted.
Answer
About 65 ice blocks at 21 °C (64.64). Residual at 22 °C = 71 − 69.38 = 1.62: the dairy sold about 1.6 more ice blocks than the model predicted.
Step by step
- To predict, substitute the temperature into the line.
- At 21 °C: y = −34.9 + 4.74 × 21 = −34.9 + 99.54 = 64.64, so about 65 ice blocks.
- 21 °C is inside the data range of 16 to 26 °C, so this is interpolation and is reasonable.
- For the residual, first find the predicted value at 22 °C: −34.9 + 4.74 × 22 = −34.9 + 104.28 = 69.38.
- Residual = actual − predicted = 71 − 69.38 = 1.62.
- Classic mistake: predicted − actual, which gives −1.62 and the wrong side of the line.
- A positive residual means the point is above the line: the dairy sold about 1.6 more than the model expected.
- Check: 69.38 + 1.62 = 71, the actual sales.
Full working
- y = −34.9 + 4.74 × 21 = 64.64x = 21
- predicted at 22: −34.9 + 104.28 = 69.38
- residual = 71 − 69.38 = 1.62actual − predicted
- About 65 at 21 °C; residual +1.62, above the line
Sample questions: Merit
A Mount Maunganui dairy records the noon temperature x (°C) and ice blocks sold y on six days: (16, 40), (18, 52), (20, 58), (22, 71), (24, 80), (26, 87). The least squares line is y = −34.9 + 4.74x. Calculate all six residuals. Which day is furthest from the line? Do the residuals support using a straight line?
Hint
Work out the predicted value for each temperature, then actual − predicted. Then look at the signs in order of x.
Answer
Residuals: −0.94, 1.58, −1.90, 1.62, 1.14, −1.34. The 20 °C day is furthest (1.90 below the line). The residuals are small, with no curve or trend in their signs, so a straight line is a good model.
Step by step
- For each day, predicted = −34.9 + 4.74x, then residual = actual − predicted.
- 16 °C: predicted 40.94, residual 40 − 40.94 = −0.94. 18 °C: predicted 50.42, residual 52 − 50.42 = 1.58.
- 20 °C: predicted 59.90, residual 58 − 59.90 = −1.90. 22 °C: predicted 69.38, residual 71 − 69.38 = 1.62.
- 24 °C: predicted 78.86, residual 80 − 78.86 = 1.14. 26 °C: predicted 88.34, residual 87 − 88.34 = −1.34.
- Furthest from the line means the largest residual in size, ignoring the sign. That is −1.90, on the 20 °C day.
- Classic mistake: picking 1.62 as the largest because it is the biggest positive number. Size matters, not sign.
- Pattern: in order of x the signs go −, +, −, +, +, −. They bounce around with no curve, such as all positive at the ends and negative in the middle.
- The residuals are all under 2 ice blocks, small compared with sales of 40 to 87.
- So a straight line suits this data.
- Check: the residuals add to 0.16, close to 0. They are not exactly 0 only because the line's numbers were rounded.
Full working
- predicted: 40.94, 50.42, 59.90, 69.38, 78.86, 88.34
- residuals: −0.94, 1.58, −1.90, 1.62, 1.14, −1.34actual − predicted
- largest size 1.90 at 20 °Cbelow the line
- signs −, +, −, +, +, − with no curverandom scatter
- Residuals small and patternless; the 20 °C day is furthest; a line fits well
A Mount Maunganui dairy records the noon temperature x (°C) and ice blocks sold y on six days: (16, 40), (18, 52), (20, 58), (22, 71), (24, 80), (26, 87). The least squares line is y = −34.9 + 4.74x. Use the line to predict sales at 23 °C and at 35 °C. Which prediction is more reliable? Also find what the line predicts on a 5 °C day, and explain what this shows.
Hint
Check each temperature against the data range, 16 to 26 °C. Inside is interpolation; outside is extrapolation.
Answer
23 °C: about 74 ice blocks, reliable (interpolation). 35 °C: about 131, unreliable (extrapolation 9 °C beyond the data; stock or demand may level off). 5 °C: −11.2, impossible, which shows the line cannot be used far outside the data.
Step by step
- First note the data range: temperatures from 16 to 26 °C.
- 23 °C: y = −34.9 + 4.74 × 23 = −34.9 + 109.02 = 74.12, about 74 ice blocks.
- 23 is inside 16 to 26, so this is interpolation. The line fits well there, so it is reliable.
- 35 °C: y = −34.9 + 4.74 × 35 = −34.9 + 165.9 = 131.0, about 131 ice blocks.
- 35 is 9 °C above the hottest day in the data. This is extrapolation: we do not know if the straight line carries on.
- On a very hot day the dairy might run out of stock, or people might stay home, so sales may level off. So 131 is unreliable.
- 5 °C: y = −34.9 + 4.74 × 5 = −34.9 + 23.7 = −11.2. Negative sales are impossible.
- Classic mistake: trusting a prediction just because the line is strong. A strong fit inside the data says nothing about outside it.
- The line hits zero at about x = 34.9 ÷ 4.74 ≈ 7.4 °C, so below that it gives nonsense. This shows why extrapolation is risky.
- Conclusion: the 23 °C prediction is the more reliable one.
Full working
- data range 16 to 26 °C
- x = 23: −34.9 + 109.02 = 74.12interpolation, reliable
- x = 35: −34.9 + 165.9 = 131.0extrapolation, unreliable
- x = 5: −34.9 + 23.7 = −11.2impossible
- about 74 at 23 °C is reliable; 131 at 35 °C is not; −11.2 shows the line fails outside the data
Sample questions: Excellence
A driving instructor measures stopping distance d (m) at speeds v (km per hour): (20, 8), (40, 22), (60, 42), (80, 68), (100, 100). The least squares line is d = −21 + 1.15v, with r = 0.988. Find the residuals, and use them to evaluate the line. Predict the stopping distance at 120 km per hour and say whether the prediction is likely to be too high or too low.
Hint
Find actual − predicted for each speed, then look at the order of the signs. A curve in the residuals means a line is the wrong shape.
Answer
Residuals 6, −3, −6, −3, 6: positive at both ends and negative in the middle, a U shape, so the relationship is curved and a line is not the right model even though r = 0.988. The line predicts −21 + 1.15 × 120 = 117 m at 120 km per hour, which is likely too low, because the data curve upward and the residuals are already positive at the top end.
Step by step
- Predicted values from d = −21 + 1.15v: 20 gives 2, 40 gives 25, 60 gives 48, 80 gives 71 and 100 gives 94.
- Residuals, actual − predicted: 8 − 2 = 6, 22 − 25 = −3, 42 − 48 = −6, 68 − 71 = −3, 100 − 94 = 6.
- In order of speed the signs are +, −, −, −, +. Big positive at both ends and negative in the middle: a U shape.
- A good straight line leaves residuals scattered at random. A U shape means the data bend, here upward, and the line cuts across the curve.
- Classic mistake: deciding the line is great because r = 0.988. A curved relationship can still have r close to 1. The residual plot shows the problem.
- In context: stopping distance grows faster than speed, because braking distance depends on speed squared. So a curve makes sense.
- Prediction at 120 km per hour: d = −21 + 1.15 × 120 = −21 + 138 = 117 m.
- At the top of the data (100 km per hour) the actual distance was already 6 m above the line, and the curve keeps bending up.
- So the true distance at 120 km per hour is probably well above 117 m. The line underestimates it.
- 120 is also outside the data, so it is extrapolation as well as using the wrong shape. That is a dangerous mix for a safety question.
- Conclusion: use a curved model (for example a quadratic) for stopping distances, and do not trust the line beyond the data.
Full working
- predicted: 2, 25, 48, 71, 94
- residuals: 6, −3, −6, −3, 6actual − predicted
- +, −, −, −, + is a U shapecurved relationship
- r = 0.988 does not show the curveuse the residuals
- d(120) = −21 + 138 = 117 mextrapolation
- Residuals show a curve; 117 m is likely too low
For a city marathon's women's race, the winning time y (minutes) against x, years since 1990, fits the line y = 152 − 0.38x, using races from 1990 to 2020. The 2020 winning time was 147.1 minutes, run in unusual heat. Find the 2020 residual and comment on it. Predict the 2030 winning time, find the year in which the model predicts a winning time of zero, and evaluate how the model should be used.
Hint
For 2020 use x = 30, and for 2030 use x = 40. For zero, solve 152 − 0.38x = 0.
Answer
2020: predicted 140.6, residual +6.5 minutes, slower than the model, which fits the heat. 2030: about 136.8 minutes, a modest extrapolation. Zero at x = 400, the year 2390, which is impossible, so the line only describes the 1990 to 2020 period and should be used for a few years ahead at most.
Step by step
- 2020 is x = 30. Predicted: 152 − 0.38 × 30 = 152 − 11.4 = 140.6 minutes.
- Residual = actual − predicted = 147.1 − 140.6 = 6.5 minutes.
- A positive residual for a time means a slower race than the model expected. The heat gives a reason, so it is a one-off, not a sign the trend has changed.
- 2030 is x = 40. Predicted: 152 − 0.38 × 40 = 152 − 15.2 = 136.8 minutes.
- 2030 is 10 years past the data, so this is extrapolation. It is reasonable only if the improvement of 0.38 minutes a year continues.
- Zero: 152 − 0.38x = 0, so x = 152 ÷ 0.38 = 400. That is 1990 + 400 = 2390.
- A winning time of zero is impossible. Human times cannot keep falling at a steady rate; they must level off.
- Classic mistake: treating the line as a law of nature. It only summarises the years it was built from.
- So the model is useful for describing 1990 to 2020, and perhaps a rough guide a few years ahead.
- Long-range predictions, like 2390, show the line breaking down. Even 2030 should be given with a warning.
- Weather, course changes and who enters also move the winning time, as the 2020 residual shows.
Full working
- 2020: x = 30, predicted 152 − 11.4 = 140.6
- residual = 147.1 − 140.6 = 6.5slower, heat
- 2030: x = 40, predicted 152 − 15.2 = 136.8extrapolation
- 152 − 0.38x = 0 gives x = 400year 2390
- zero time is impossiblethe line must fail far ahead
- Residual +6.5; 2030 ≈ 136.8 min; zero in 2390 shows the model only suits the data years and a short way beyond
What to take away
- Stay inside the data.
- Residual = actual − predicted.
Challenge
A Tauranga bakery fits a least squares line to five weeks of data: advertising spend x (hundreds of dollars) and sales y (hundreds of dollars). The spends were 3, 5, 7, 9 and 11. The analyst's notes survive only in part: at x = 5 sales were 46 with residual +6; at x = 9 sales were 60 with residual −4; at x = 3 and x = 7 the residuals were −3 and −1. Find the equation of the line, the sales in the week with x = 11, and check your answer using the point of means.
Hint
Actual − residual gives the predicted value, and predicted values lie on the line. For the last week, remember a fact about the residuals from any least squares line.
Answer
y = 10 + 6x; sales of 78 (hundred dollars, so $7,800) in the x = 11 week. Check: the means are (7, 52), and 10 + 6 × 7 = 52.
Step by step
- Predicted = actual − residual, so the line gives 46 − 6 = 40 at x = 5 and 60 + 4 = 64 at x = 9.
- Slope = (64 − 40) ÷ (9 − 5) = 6, and 40 = a + 6 × 5 gives a = 10.
- Residuals from a least squares line add to 0, so the x = 11 residual is −(−3 + 6 − 1 − 4) = 2.
- At x = 11 the line predicts 10 + 66 = 76, so the actual sales were 76 + 2 = 78.
- For the check, find the other sales: at x = 3 the line gives 28, so sales were 25; at x = 7 it gives 52, so sales were 51.
- Check: ȳ = (25 + 46 + 51 + 60 + 78) ÷ 5 = 52 and x̄ = 7, and the line gives 52 at x = 7, as it must.
Full working
- x = 5: predicted = 46 − 6 = 40actual − residual
- x = 9: predicted = 60 − (−4) = 64actual − residual
- b = (64 − 40) ÷ 4 = 6, a = 40 − 30 = 10y = 10 + 6x
- −3 + 6 − 1 − 4 + e = 0, so e = 2residuals add to zero
- x = 11: 10 + 66 + 2 = 78predicted + residual
- x = 3: 28 − 3 = 25; x = 7: 52 − 1 = 51other sales
- ȳ = 260 ÷ 5 = 52 = 10 + 6 × 7line passes through (x̄, ȳ)
- y = 10 + 6x; week 11 sales 78 hundred dollars
Eight houses sold in one suburb: floor area x (m²) and price y ($ thousands): (80, 445), (100, 495), (120, 570), (140, 610), (160, 700), (180, 720), (200, 765), (220, 895). The least squares line is y = 200 + 3x. Find all eight residuals and describe the pattern in them. Predict the price of a 110 m² house and of a 210 m² house. Both predictions are interpolation: are they equally trustworthy? Is a straight line still a sensible model?
Hint
Look at the size of the residuals as x increases, not only their signs. A residual plot can show a pattern in the spread as well as a curve.
Answer
Residuals 5, −5, 10, −10, 20, −20, −35, 35. They have no curve, but their size grows with floor area (a fan shape). Predictions: $530,000 at 110 m² and $830,000 at 210 m². The 110 m² prediction is more trustworthy: nearby small houses sit within about $5,000 to $10,000 of the line, but nearby large ones are up to $35,000 away. A straight line still describes the trend well; only its precision falls for large houses.
Step by step
- Predicted values are 200 + 3x: 440, 500, 560, 620, 680, 740, 800, 860.
- Residual = actual − predicted gives 5, −5, 10, −10, 20, −20, −35, 35, which add to 0 as they should.
- The signs do not show a curve such as a U shape, so the trend is linear. But the residuals get bigger as x grows: the scatter fans out.
- At 110 m²: 200 + 330 = 530, so about $530,000. At 210 m²: 200 + 630 = 830, so about $830,000.
- Both are inside 80 to 220 m², yet the fan means large houses vary much more about the line, so the 210 m² prediction could easily be $35,000 out, while the 110 m² one is likely within about $5,000 to $10,000.
- So keep the straight line for the trend, but report that predictions for large houses are much less precise.
Full working
- predicted: 440, 500, 560, 620, 680, 740, 800, 860200 + 3x
- residuals: 5, −5, 10, −10, 20, −20, −35, 35actual − predicted
- sum = 0; sizes 5, 5, 10, 10, 20, 20, 35, 35spread grows with x
- x = 110: 200 + 3 × 110 = 530$530,000
- x = 210: 200 + 3 × 210 = 830$830,000
- near 110: residuals of size 5 to 10; near 210: size 35fan shape
- Fan-shaped residuals; $530,000 is more trustworthy than $830,000; the line suits the trend but is less precise for large houses
For five points (1, 7), (2, 6), (3, 10), (4, 14), (5, 18), Ana claims her line y = 3.5 + 2.5x is the least squares line "because its residuals add to zero". Ben claims his line y = 4.25 + 2.75x is the least squares line "because it goes exactly through the first and last points, so those residuals are zero". Evaluate both claims, find the true least squares line, and compare the sums of squared residuals of all three lines.
Hint
Find each line's residuals. Then ask: is "residuals add to zero" enough to make a line least squares? Every line through the point (x̄, ȳ) has some property. Find the true line with b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)².
Answer
Both claims are wrong. Ben's residuals add to −7.5, not 0, so his line cannot be least squares. Ana's add to 0 because her line passes through (3, 11), but so does every line through the means. The least squares line is y = 2 + 3x. Sums of squared residuals: least squares 10, Ana 12.5, Ben 21.875.
Step by step
- Ben's residuals are 0, −3.75, −2.5, −1.25, 0. They add to −7.5, and least squares residuals always add to 0, so his line is not least squares. Passing through two data points means nothing.
- Ana's residuals are 1, −2.5, −1, 0.5, 2, which add to 0. That only shows her line passes through (x̄, ȳ) = (3, 11). Any slope through that point gives a zero sum, so this cannot decide the slope.
- True line: deviations of x are −2, −1, 0, 1, 2 and of y are −4, −5, −1, 3, 7. The top is 8 + 5 + 0 + 3 + 14 = 30 and the bottom is 10, so b = 3 and a = 11 − 9 = 2.
- Its residuals are 2, −2, −1, 0, 1, with squares adding to 10. Ana's squares add to 12.5 and Ben's to 21.875.
- So the least squares line y = 2 + 3x has the smallest sum of squares, as it must. A zero sum of residuals is necessary but not enough.
Full working
- x̄ = 3, ȳ = 55 ÷ 5 = 11means
- Ben: residuals 0, −3.75, −2.5, −1.25, 0; sum −7.5not zero, so not least squares
- Ana: residuals 1, −2.5, −1, 0.5, 2; sum 03.5 + 2.5 × 3 = 11, through the means
- Σ(x − x̄)(y − ȳ) = 8 + 5 + 0 + 3 + 14 = 30, Σ(x − x̄)² = 10slope formula
- b = 3, a = 11 − 3 × 3 = 2y = 2 + 3x
- least squares: 4 + 4 + 1 + 0 + 1 = 10sum of squared residuals
- Ana: 1 + 6.25 + 1 + 0.25 + 4 = 12.5; Ben: 0 + 14.0625 + 6.25 + 1.5625 + 0 = 21.875both larger
- Both claims wrong; least squares line y = 2 + 3x with sum of squares 10 (Ana 12.5, Ben 21.875)
Practise this
Report a mistake
More in AS 91581
Is your child on track?
Take the free placement test


