math.wiki
Statistics › Bivariate data › Residuals › Making and reading residual plots
Open on the map
Algebra 1 · S.ID.B.6B

Making and reading residual plots

A line has been fitted to some data and the dots sit close to it. How can you tell whether a straight line was the right shape to fit at all?

Where you are 3 in Residuals

When you reach for it

Technology has given you the least-squares line for a scatter plot (the line of best fit it computes), and you want to know whether a line was a fair choice. The scatter plot alone often cannot tell you: when the dots climb across a wide range, a gentle bend hides inside them. A residual is actual minus predicted, y - \hat{y}, positive when the dot is above the line and negative when it is below.

A residual plot puts one dot at (x,\ y - \hat{y}) for every case, with a horizontal line at 0. It is the scatter plot with the fitted line laid flat and the gaps stretched to fill the picture, so what the line missed is the only thing left to see. Reach for it whenever you must decide whether a line describes the data or whether to choose another family. A correlation near 1 or -1 does not settle that: the correlation coefficient measures how tightly the dots hug a line, and Example 2 has r close to 1 and a curve all the same.

The procedure

Making one. For each case, put its x into the line to get the prediction \hat{y}, then subtract: the residual is y - \hat{y}. A table with columns x, y, \hat{y} and y - \hat{y} keeps each actual value next to its prediction. Then plot each pair (x,\ y - \hat{y}), with x across as before and residuals up the side, and draw the horizontal line at residual 0. That line stands for the fitted line itself, since a dot exactly on the fitted line has residual 0.

One check comes free. The residuals from a least-squares line always add to 0: the line sits so that the amounts above and below it balance. If yours add to something clearly not 0 (allowing a little for rounded coefficients), a prediction has been miscalculated. The check belongs to the least-squares line only; a line drawn by eye, or a curve fitted another way, need not balance.

Reading one. Look at the shape the dots make.

  • No pattern: dots above and below 0, mixed along the whole range, about equally spread. The line has caught the trend and what remains looks like chance. A line is a fair model.
  • A curve: a U (positive at both ends, negative in the middle) or an arch (the reverse). The data bend and the line cuts across the bend: a U means the data bend upward away from the line, an arch that they bend downward, as when growth levels off. A line is the wrong shape, however straight the scatter plot looked.
  • A fan: residuals spreading wider as x grows. The line follows the center, but predictions are less sure for larger x, where actual values stray further from it.
  • One dot far from the rest: that case does not follow the pattern. Check it for a slip. It may also have pulled the line toward itself, which shows as the other residuals leaning to one side.

To compare two models, make a residual plot for each and prefer the one that leaves no pattern.

Worked examples

Example 1

Making a residual plot: lengths of cord

Fulvio cuts six lengths of cord and weighs each (made-up data), giving pairs (length in meters, mass in grams): (2, 93), (4, 166), (6, 252), (8, 329), (10, 407), (12, 493). Technology gives the least-squares line \hat{y} = 40x + 10. Make the residual plot and say whether a line is a fair model.

Solution

Each prediction comes from putting the length into the line. For x = 2, \hat{y} = 40(2) + 10 = 90, so the residual is 93 - 90 = 3. The same for every cord:

xy\hat{y} = 40x + 10y - \hat{y}
293903
4166170-4
62522502
8329330-1
10407410-3
124934903

The residuals add to 3 - 4 + 2 - 1 - 3 + 3 = 0, as they must. Plotting (2, 3), (4, -4) and the rest gives the lower panel.

0 2 4 6 8 10 12 14 0 100 200 300 400 500 length (m) mass (g) 0 2 4 6 8 10 12 14 −6 −3 0 3 6 length (m) residual (g)
Figure 1Fulvio’s cord (made-up data). The residual plot is the scatter plot with the line laid flat.

The dots sit above and below 0 with no bend and no widening. Every cord is within 4 grams of its prediction, small beside masses of 90 to 490 grams. A line is a fair model.

Example 2

A curve the scatter plot hides: pizza prices

Gertrud lists the price of a plain pizza at one shop by its diameter (made-up data), as pairs (diameter d in centimeters, price in dollars): (20, 6.75), (25, 8.25), (30, 9.5), (35, 12), (40, 14.5), (45, 18.25), (50, 21.75). Technology gives \hat{y} = 0.5d - 4.5. Make the residual plot and decide whether a line is a fair model.

Solution

Predict, then subtract. For d = 20, \hat{y} = 0.5(20) - 4.5 = 5.5 and the residual is 6.75 - 5.5 = 1.25.

dy\hat{y}y - \hat{y}
206.755.51.25
258.2580.25
309.510.5-1
351213-1
4014.515.5-1
4518.25180.25
5021.7520.51.25

They add to 0.

20 25 30 35 40 45 50 0 5 10 15 20 25 diameter (cm) price (dollars) 20 25 30 35 40 45 50 −2 −1 0 1 2 diameter (cm) residual (dollars)
Figure 2Gertrud’s pizza prices (made-up data). The scatter plot looks straight; the residual plot shows a U.

In the scatter plot every dot is within 1.25 dollars of the line on a scale running past 20, and the correlation is r \approx 0.98. The residual plot stretches those small gaps over its whole height, and a U appears: above at both ends, below through the middle. The prices curve upward more steeply than any line can. That matches how pizza is sold: you pay for the amount of pizza, its area, which grows with the square of the diameter. The line under-predicts the smallest and largest pizzas and over-predicts the middle ones, so a curved model would serve better.

Example 3

A fan: seeds that sprout

Gaia sows trays of seeds, two trays at each count, and records how many sprout (made-up data), as pairs (sown, sprouted): (10, 9), (10, 7), (20, 18), (20, 14), (30, 27), (30, 21), (40, 37), (40, 27), (50, 46), (50, 34). Technology gives \hat{y} = 0.8x. Make the residual plot and say what it means for predictions.

Solution

The line predicts 0.8 \times 10 = 8 sprouts from 10 seeds, and so on.

x\hat{y}yy - \hat{y}
1089, 71, -1
201618, 142, -2
302427, 213, -3
403237, 275, -5
504046, 346, -6
0 10 20 30 40 50 60 −8 −4 0 4 8 seeds sown residual (seeds)
Figure 3Gaia’s seed trays (made-up data). The residuals fan out as more seeds are sown.

There is no bend: at every count the residuals balance about 0, so the line follows the center of the data. But the spread widens from \pm 1 at 10 seeds to \pm 6 at 50, a fan. A prediction for 10 seeds is likely within about 1 sprout; one for 50 seeds could be 6 out.

Example 4

One point far from the rest: song files

Gottfried notes the length and file size of seven songs (made-up data), as pairs (minutes, megabytes): (2, 1.5), (3, 3), (4, 7.5), (5, 4.75), (6, 6), (7, 7.25), (8, 8.5). Technology gives \hat{y} = x + 0.5. Make the residual plot and read it.

Solution

Predict, then subtract:

xy\hat{y}y - \hat{y}
21.52.5-1
333.5-0.5
47.54.53
54.755.5-0.75
666.5-0.5
77.257.5-0.25
88.58.50

The residuals add to 0.

0 1 2 3 4 5 6 7 8 9 −2 −1 0 1 2 3 4 length (minutes) residual (MB)
Figure 4Gottfried’s song files (made-up data). One song stands far from the rest.

One dot, the 4-minute song at 3, stands far from the rest, which all lie between -1 and 0. Every other residual is 0 or negative: that one song has pulled the line up toward itself and left the others below it. Gottfried should check that song. If it was saved at a higher quality setting, it does not belong with the others and the line should be refitted without it; if the size was written down wrongly, it should be corrected.

Example 5

Line or exponential: water fern on a pond

Gabor measures the area of a pond covered by water fern, y square meters, at the start of each week x (made-up data): (0, 1.9), (1, 3.1), (2, 4.5), (3, 6.9), (4, 10), (5, 15.2), (6, 22.8). Technology fits the line \hat{y} = 3.3x - 0.7 and the exponential model \hat{y} = 1.981(1.504)^x. Use residual plots to choose between them.

Solution

Work out both sets of residuals. For the line:

xy\hat{y} = 3.3x - 0.7y - \hat{y}
01.9-0.72.6
13.12.60.5
24.55.9-1.4
36.99.2-2.3
41012.5-2.5
515.215.8-0.6
622.819.13.7

For the exponential, to two decimal places:

xy\hat{y} = 1.981(1.504)^xy - \hat{y}
01.91.98-0.08
13.12.980.12
24.54.480.02
36.96.740.16
41010.14-0.14
515.215.24-0.04
622.822.93-0.13
0 1 2 3 4 5 6 −3 −2 −1 0 1 2 3 4 week residual from the line (m²) 0 1 2 3 4 5 6 −3 −2 −1 0 1 2 3 4 week residual from the exponential (m²)
Figure 5Gabor’s water fern (made-up data). The line leaves a U; the exponential leaves almost nothing.

The line’s residuals add to 0 and form a clear U: the fern grows faster and faster, and the line cannot bend with it. The exponential’s residuals are all within 0.16 of 0, with signs mixed and no shape. (They add to -0.09, not 0: the balance belongs to least-squares lines, and this curve is not one.) The exponential model fits: each week the area is multiplied by about 1.5. Fitting both models is covered in Fitting linear and exponential models with technology.

Boundaries

  • A residual plot judges a model only over the x values in the data. No pattern there says nothing about x values beyond them; see Predicting with a regression line, and extrapolation.
  • With few points a pattern can appear by chance, and a real one can hide. Four or five dots give a weak verdict.
  • The residuals of a least-squares line add to exactly 0 when its coefficients are unrounded; rounded coefficients leave a sum near 0. Other models need not balance at all (Example 5).
  • No pattern means a line describes the data fairly. It does not mean x causes y, and it does not mean predictions are close: the size of the residuals, read off the vertical scale, says how close.
  • A curved pattern says a line is the wrong shape, not which curve is right. Compare the residual plots of the candidate models, as in Example 5. Re-expressing data so that a curve becomes straight is Transforming to linearity: logs and exponential models.

Where this goes next

The residual plot is the working check behind every regression decision that follows. The typical size of the residuals, and the share of the variation a line accounts for, become numbers of their own in r squared and the standard deviation of the residuals. Before drawing conclusions about a whole population from a sample, Conditions for regression inference reads the same plot for a straight trend (no curve) and an even spread (no fan). And when a residual plot shows a curve, the next move is to fit another family with technology, or to straighten the data with a transformation.

Exercises

Making residual plots

  1. Finnian times five bike rides (made-up data), as pairs (kilometers, minutes): (5, 18), (10, 36), (15, 49), (20, 62), (25, 80). Technology gives \hat{y} = 3x + 4. Find each residual and check that they add to 0.
  2. Sketch the residual plot for Exercise 1 and decide whether a line is a fair model.
  3. Six residuals from a least-squares line are 1.2, -0.7, 0.4, -1.5, 0.9, and one more that has been smudged. What is the missing residual?

Matching scatter plots to residual plots

A B C D 1 2 3 4
Figure 6Scatter plots A to D, and the residual plots of their least-squares lines in a shuffled order (made-up data).
  1. Which residual plot belongs to scatter plot A?
  2. Which belongs to scatter plot B?
  3. Which belongs to scatter plot C?
  4. Which belongs to scatter plot D?

Reading residual plots

  1. Fulvio charges a phone and records the battery percentage at 10, 20, \dots, 70 minutes (made-up data). The residuals from the least-squares line are, in order, -5, 0, 3, 4, 3, 0, -5. Describe the pattern and what it says about how the battery fills.
  2. For a restaurant, a least-squares line predicts the bill from the size of the party (made-up data). Its residuals, in dollars, are 3 and -3 for parties of 2; 6 and -6 for parties of 4; 10 and -10 for 6; 15 and -15 for 8. Describe the pattern. Is a prediction surer for a party of 2 or of 8?
  3. Use Gaia’s line in Example 3 to predict the sprouts from 25 seeds, and use the residual plot to say roughly how far off the prediction might be.
  4. A market stall’s least-squares line for six days has residuals 1, 0.5, 1, -6, 2 and 1.5 (made-up data, days 1 to 6). Which day stands apart, and why are all the other residuals positive?
  5. Technology fits a line and an exponential model to the number of fruit flies in a jar over 8 days (made-up data). The line’s residuals are 24, 6, -9, -21, -21, -9, 6, 24; the exponential’s are 2, -3, 1, 4, -2, -1, 3, -4. Which model should be used, and why?
  6. Use Gertrud’s line in Example 2 to predict the price of a 60 cm pizza. Is the true price more likely above or below the prediction? Give two reasons to be wary of it.

Explaining

  1. Can every residual from a least-squares line be positive? Explain.
  2. A residual plot has dots both above and below 0. Explain why that alone does not show that a line fits.
  3. Every dot of a scatter plot lies exactly on the least-squares line. Describe the residual plot.
  4. A friend finds r \approx 0.98 for some data and says that proves a line is the right model. Use Example 2 to answer.
  5. Explain why a residual plot shows a bend more clearly than the scatter plot does.
Answers
  1. Residuals -1, 2, 0, -2, 1. The predictions are 19, 34, 49, 64, 79, and -1 + 2 + 0 - 2 + 1 = 0.
  2. Dots at (5, -1), (10, 2), (15, 0), (20, -2), (25, 1) lie above and below 0 with no bend or widening. A line is a fair model; every ride is within 2 minutes of its prediction.
  3. -0.3. The five known residuals add to 0.3, and all six must add to 0.
  4. Plot 2. A is a straight band, so nothing but scatter is left.
  5. Plot 4. B curves upward away from its line, so the residuals form a U.
  6. Plot 1. C levels off, so the line runs above the ends and below the middle: an arch.
  7. Plot 3. D’s band widens to the right, so the residuals fan out.
  8. An arch: negative at both ends, positive in the middle. The percentage rises quickly at first and then more slowly, leveling off, so a line is the wrong shape.
  9. A fan: the spread grows with party size. A prediction for 2 people is likely within about 3 dollars; one for 8 could be 15 dollars out, so the party of 2 is surer.
  10. \hat{y} = 0.8 \times 25 = 20 sprouts. The residuals near 25 seeds are \pm 2 and \pm 3, so expect roughly 17 to 23.
  11. Day 4, at -6. The residuals add to 0, so that one low day has pulled the line down toward itself, leaving the other five above it. Check day 4 and consider refitting without it.
  12. The exponential. The line’s residuals form a U, so the flies multiply faster than a line allows; the exponential’s are small with mixed signs and no shape.
  13. \hat{y} = 0.5(60) - 4.5 = 25.5 dollars. Likely above: the residuals are positive and rising at the right end of the U. Be wary because the line is the wrong shape, and because 60 cm is outside the data.
  14. No. They add to 0, so if any is positive another must be negative, unless all are 0.
  15. A U or an arch also has dots on both sides (Example 2). What matters is the shape: whether positive and negative residuals are mixed along the whole range or grouped.
  16. Every residual is 0, so every dot lies on the line at 0.
  17. Example 2 has r \approx 0.98 and still shows a U. A high r says the dots hug a line tightly; a gentle curve can do that. Only the residual plot shows whether the shape is straight.
  18. Subtracting \hat{y} moves each dot by the height of the line at its x, laying the line flat and removing the trend. Only the gaps are left, drawn on a scale of a few units instead of the whole range of y, so a bend of 1 unit in 20 fills the picture.
kg1128 · updated 2026-10-10 · CC-BY-SA-4.0