Educerie

Educerie · AP · Statistics

AP Statistics 5.4

Residuals

How can we describe the relationship between two quantitative variables, and how well can one be used to predict the other?

What you will learn

  • Understand that a residual is the observed response minus the predicted response for the same x
  • Know that a positive residual means the model underpredicts and a negative residual means it overpredicts
  • Understand that a residual plot graphs residuals against predicted values or explanatory values
  • Know that random scatter supports a linear model and that curvature suggests a linear model is not the most appropriate

You must be able to

  1. Calculate a residual from an equation, an x-value and an observed value
  2. Interpret a positive or negative residual in context
  3. Find an observed value from a residual and a regression equation
  4. Read a residual plot and decide whether a linear model is appropriate
  5. Describe the pattern in a residual plot, such as an arch or random scatter
  6. Explain why a high r does not replace a residual plot

In the exam. Section I asks you to calculate a residual, to go from a residual and an equation back to an observed value, to say what a positive or negative residual means, or to read a residual plot. A residual is usually one question of the regression set of three. In Section II, a free-response question can ask you to calculate and interpret a residual in context, or to say from a residual plot whether a linear model is appropriate.

1Calculating a residual

For each individual in the data, the line gives a predicted value y^\hat{y}, and the individual has an observed value yy. The residual is the gap between them.

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

Look at the used-car model from 5.3: y^=23.34−1.667x\hat{y} = 23.34 - 1.667x, with xx the age in years and yy the asking price in thousands of dollars. Figure 1 shows the 12 cars and the line. The vertical segment from each dot to the line is that car's residual.

Figure 1. Asking price against age with the fitted line: the vertical gap from each dot to the line is that car's residual; dots above the line have positive residuals and dots below have negative ones 2 4 6 8 10 5 10 15 20 25 0 Asking price ($ thousands) Age (years) Fitted line +1.4 (underpredicted) −1.1 (overpredicted)
Figure 1 · Residuals of the 12 used cars: a dot above the line has a positive residual, and a dot below it a negative one

Worked example 1. A car aged 3 years has an asking price of 18.9 thousand dollars.

y^=23.34−1.667(3)=18.339the predicted price\hat{y} = 23.34 - 1.667(3) = 18.339 \qquad \textcolor{#838c91}{\text{the predicted price}}residual=18.9−18.339=0.561observed minus predicted\text{residual} = 18.9 - 18.339 = 0.561 \qquad \textcolor{#838c91}{\text{observed minus predicted}}

The residual is about +0.56+0.56 thousand dollars, or about 560 dollars. It is positive, so the dot is above the line.

Worked example 2. A car aged 5 years has an asking price of 13.9 thousand dollars.

y^=23.34−1.667(5)=15.005\hat{y} = 23.34 - 1.667(5) = 15.005residual=13.9−15.005=−1.105\text{residual} = 13.9 - 15.005 = -1.105

The residual is about −1.1-1.1 thousand dollars. It is negative, so the dot is below the line. Figure 1 marks this car, and one at age 1 whose residual is +1.4+1.4.

The order matters. The residual is observed minus predicted, never the other way round. Reversing it flips the sign, and a flipped sign flips your interpretation. The units of a residual are the units of yy.

2Interpreting a residual

A residual says how the real value compares with the model's prediction for that individual.

  • Positive residual. The observed value is above the predicted value. The model underpredicts (underestimates) the response.
  • Negative residual. The observed value is below the predicted value. The model overpredicts (overestimates) the response.
  • Zero residual. The dot lies on the line.

Worked interpretation. For the 5-year-old car in example 2: the asking price of this car, 13.9 thousand dollars, was about 1.1 thousand dollars lower than the 15.0 thousand dollars the model predicts for a 5-year-old car. The model overpredicts the price of this car.

Good wording names the individual, the variable, the size, the direction and the model's prediction. "The residual is negative" alone is not an interpretation. Do not say a negative residual is a "bad" car or a "mistake" by the owner. It is a statement about the model.

3Working backwards

The exam may give you the residual and the equation, and ask for the observed value. Rearrange the definition.

y=y^+residualy = \hat{y} + \text{residual}

Worked example. For a car aged 4 years the residual is +0.8+0.8 thousand dollars. Find the observed asking price.

y^=23.34−1.667(4)=16.672predicted price first\hat{y} = 23.34 - 1.667(4) = 16.672 \qquad \textcolor{#838c91}{\text{predicted price first}}y=16.672+0.8=17.472observed = predicted + residualy = 16.672 + 0.8 = 17.472 \qquad \textcolor{#838c91}{\text{observed = predicted + residual}}

The asking price is about 17.5 thousand dollars. A positive residual means the observed value is above the prediction, so you add it. A negative residual is subtracted.

4Residual plots

Residual plot = a scatterplot of the residuals (on the vertical axis) against the predicted response values, or against the explanatory variable values (on the horizontal axis).

Either version is accepted. This note uses the explanatory variable. A horizontal line at 0 marks the line of the model: dots above it have positive residuals.

A residual plot takes away the slope. The line is turned flat, so any pattern that the line misses stands out. That makes it better than the scatterplot for judging whether a line is a good shape.

What to look for.

  • Random scatter, with no pattern, around the 0 line. This supports the linear form. A simple linear regression model is appropriate for the data.
  • Curvature: an arch, a bowl or any clear bend. This suggests the linear model is not the most appropriate. The association has a non-linear form.

Figure 2 is the residual plot for the used cars.

Figure 2. Used-car data: the scatterplot with its line on the left and the residual plot on the right; the residuals scatter randomly around zero with no pattern, so a linear model is appropriate (a) Scatterplot and line 2 4 6 8 10 5 10 15 20 25 0 Price ($ thousands) Age (years) Figure 2. Used-car data: the scatterplot with its line on the left and the residual plot on the right; the residuals scatter randomly around zero with no pattern, so a linear model is appropriate (b) Residual plot 0 2 4 6 8 10 −2 0 2 Residual ($ thousands) Age (years)
Figure 2 · Used-car data: the scatterplot with its line, and the residual plot, which shows random scatter

The residuals of the cars have no pattern. They are positive and negative in no order, and they are about the same size at every age. A linear model is appropriate.

Figure 3 is a different data set.

Figure 3. Seedling data: the scatterplot with its line on the left and the residual plot on the right; the residuals form an arch, negative then positive then negative, which is curvature, so a linear model is not the most appropriate (a) Scatterplot and line 2 4 6 8 10 4 8 12 0 Height (cm) Weeks after planting Figure 3. Seedling data: the scatterplot with its line on the left and the residual plot on the right; the residuals form an arch, negative then positive then negative, which is curvature, so a linear model is not the most appropriate (b) Residual plot 0 2 4 6 8 10 −2 0 2 Residual (cm) Weeks after planting
Figure 3 · Seedling height against weeks: a line fitted to a curve leaves an arch-shaped residual plot

Example (invented): a seedling is measured each week for 10 weeks. The scatterplot rises quickly and then levels off, and the fitted line is y^=4.70+0.891x\hat{y} = 4.70 + 0.891x. The residual plot is not random. The residuals are negative for the first two weeks, positive for weeks 3 to 7 and negative again after that. The arch means the line is too high at both ends and too low in the middle. A linear model is not the most appropriate here.

5Putting it together

A scatterplot, rr and a residual plot answer three questions.

ToolQuestion it answers
ScatterplotDoes the pattern look linear?
Correlation rrHow strong is the linear association?
Residual plotDoes the line fit without a leftover pattern?

rr alone cannot show that a line is right. In the seedling data, rr is high (0.89, 5.2), but the residual plot shows curvature. The residual plot is the final check.

Apparent randomness supports a linear model. It does not prove it. Say "supports", "suggests" or "is appropriate", and not "proves".

Practice questions

30 questions on this note, from easy to hard. Each one you get right lights a star of this topic's constellation.