Unit 5 · Topic 5.4 Beta

Residuals

3 min read · freeNot practiced

A regression line gives a prediction for every value of xx, but real points do not sit on the line. How far each one misses, and whether the misses follow a pattern, tells you how good the line is and whether a line was the right shape at all.

What a residual is

For each data point, the residual is the actual value minus the predicted value:

residual=y−y^=actual−predicted.\text{residual} = y - \hat{y} = \text{actual} - \text{predicted}.

On a scatterplot it is the vertical gap between the point and the line. A residual has the units of yy.

  • A positive residual: the point is above the line, so the line underpredicted.
  • A negative residual: the point is below the line, so the line overpredicted.
  • A residual of 0: the point is on the line.

Worked example 1. A cafe's line for predicting iced drinks sold from the day's high temperature is y^=−114.81+3.407x\hat{y} = -114.81 + 3.407x. On an 80°F day it sold 160 drinks. Find and interpret the residual.

Predicted: y^\hat{y}=−114.81= -114.81+3.407(80)+ 3.407(80)=157.75= 157.75 drinks.

Residual: 160−157.75=2.25160 - 157.75 = 2.25 drinks.

Interpretation: on that 80°F day, the cafe sold about 2.25 more iced drinks than the line predicts.

Order matters. Predicted minus actual has the opposite sign and the opposite meaning. Always subtract the prediction from the actual value.

The residual plot

A residual plot graphs each residual against its xx value (some software uses y^\hat{y} instead; the reading is the same). It takes the trend out of the picture. Whatever is left is what the line failed to capture. A horizontal line at 0 marks "exactly predicted".

Top: used car age against price with a regression line; the points bend away from it. Bottom: the residual plot, with residuals positive for the newest cars, negative in the middle and positive again for the oldest, a U shape.
Figure 1. A line fit to curved data, and the U-shaped residual plot that gives it away. LevlPrep original diagram.

Read a residual plot like this:

Residual plotWhat it means
random scatter above and below 0, even spreada line is a reasonable model
a curve (U shape or upside-down U)the relationship is curved; a line is not appropriate
a fan (spread grows or shrinks with xx)predictions are less precise where the spread is larger

Worked example 2. The figure shows 16 used cars, age against price, with a regression line, and the residual plot below it. Is a line appropriate?

The residuals are positive for the newest cars (about 2.5 to 3.8 thousand dollars at 1 year), negative for cars aged 3 to 8, and positive again for the oldest (about 3.6 thousand at 11 years). That U shape is a clear pattern: price drops quickly at first and then levels off, and a line cannot bend to follow it. A line is not an appropriate model.

The pattern also says where the line's predictions go wrong: it underpredicts the newest and oldest cars and overpredicts the middle-aged ones.

Why both signs are not enough

Any line fit through the middle of a cloud of points has some points above and some below, so "the residuals are positive and negative" says nothing. Small residuals are not enough either. The question is whether they form a pattern. Even a correlation near 1 can hide a curve: the car data have rr about −0.94-0.94, a strong linear association by the number, yet the residual plot shows the line is the wrong shape.

Putting it together

A full regression check goes in this order: plot the data and describe it; fit a line; look at the residual plot; then, only if the residuals show no pattern, use the line to predict and interpret its slope. Topic 5.5 adds the last pieces: how the line is chosen and how to measure its typical error.

Spot a mistake on this page?