From the Regression Line to a Residual
A residual calculation sometimes starts with a prediction already provided. Other times, you must first use the regression equation to find the predicted response for the observed case. This tutorial focuses on that second situation: calculate \(\hat{y}\) from the line at the case’s \(x\)-value, then subtract \(\hat{y}\) from the observed response \(y\).
In “Defining a Residual as Observed Minus Predicted,” we established that a residual is \(y-\hat{y}\). Here, the main calculation step is making sure that \(\hat{y}\) comes from the correct input: the observed predictor value for that same case. The equation and data point need to use matching variables and units.
The equation’s \(a\) and \(b\) are the intercept and slope, as in “Reading the Equation of a Regression Line.” The value \(x\) is the predictor for the case; \(y\) is its observed response; and \(\hat{y}\) is the response predicted by the line at that \(x\). The residual has the same units as \(y\), not the units of \(x\) or the slope.
A reliable habit is to write the prediction as a separate line before calculating the residual. This makes it easier to catch a wrong input, an arithmetic slip, or a subtraction in the wrong order. Keep the value of \(\hat{y}\) unrounded until the residual is calculated, unless the problem tells you to round earlier.
A Hand-Calculation Routine
Use this sequence whether the slope is positive or negative. Substitution comes before subtraction; do not subtract the observed \(x\)-value from the observed \(y\)-value. Those are values of different variables and generally have different units.
Record its predictor value \(x\) and its observed response \(y\), with their units.
Replace \(x\) in \(\hat{y}=a+bx\) with the case’s predictor value. Use parentheses around the substituted value.
Multiply the slope by \(x\), then add the intercept. Keep the response units with \(\hat{y}\).
Calculate \(y-\hat{y}\), keeping the sign and response units.
Add the residual to the prediction. Since \(y-\hat{y}+\hat{y}=y\), the sum should recover the observed response.
The final check is especially useful when the residual is negative: a negative residual added to the prediction should bring the value down to the observation. This check does not replace the definition, but it can reveal a subtraction error. As discussed in “Prediction Rounding and Units,” report a sensible level of precision and use the response variable’s units.
Worked Example: Delivery Time
Worked Example: Delivery Time
A fictional delivery service models delivery time from route distance. Let \(x\) be distance in kilometers and \(y\) be the observed delivery time in minutes. The fitted line is \(\hat{y}=6+3.2x\). For a delivery on a 7-kilometer route, the observed time is 31.6 minutes. Calculate and interpret the residual.
State. This case has \(x=7\) kilometers and observed response \(y=31.6\) minutes. The fitted line gives the predicted delivery time for a 7-kilometer route.
Plan. Substitute 7 for \(x\) to calculate \(\hat{y}\). Then apply the residual definition, observed response minus predicted response, and report the result in minutes.
Do. First calculate the predicted time:
The multiplication can be checked as \(3.2(7)=32(7)/10=224/10=22.4\). Now calculate the residual:
Conclude. The delivery took 3.2 minutes more than the fitted line predicted for a 7-kilometer route. Check the subtraction by adding the residual to the prediction: \(28.4+3.2=31.6\) minutes, the observed time.
Worked Example: A Line With a Negative Slope
Worked Example: A Line With a Negative Slope
In a fictional test of a rechargeable lantern, a line models battery charge from the number of hours the lantern has been on. Let \(x\) be operating time in hours and \(y\) be the observed charge in percent. The fitted line is \(\hat{y}=98-3.6x\). At \(x=10\) hours, the observed charge is \(58\%\). Find the residual.
State. The observed response is \(y=58\%\), and the predictor value is \(x=10\) hours. The prediction must be evaluated at those same 10 hours.
Plan. Substitute 10 into the equation, keeping the minus sign in the slope term. Then subtract the predicted charge from the observed charge.
Do. The fitted line predicts:
To check the multiplication, \(3.6(10)=36\), so subtracting 36 from 98 gives 62. The residual is:
Conclude. The observed battery charge is 4 percentage points less than the fitted line’s prediction at 10 hours. The subtraction check gives \(62+(-4)=58\%\), recovering the observed charge. The residual is measured in percentage points because it is a difference between two charge percentages.
This example also shows why it is important to use the equation as written. The negative slope is part of the prediction calculation: at 10 hours, the slope term is subtracted from the intercept. The residual calculation still follows the same order, \(y-\hat{y}\), regardless of the slope’s sign.
Worked Example: Decimal Predictor and Response
Worked Example: Decimal Predictor and Response
A fictional file-transfer system uses a fitted line to predict the amount of data transferred from the time elapsed. Let \(x\) be time in minutes and \(y\) be the observed amount transferred in megabytes. The fitted line is \(\hat{y}=1.2+2.75x\). At \(x=4.8\) minutes, the system transfers \(14.0\) megabytes. Calculate and interpret the residual.
State. The case has predictor value \(x=4.8\) minutes and observed response \(y=14.0\) megabytes.
Plan. Substitute \(4.8\) into the line, calculate the predicted amount, and then subtract that prediction from \(14.0\) megabytes. Keep the decimal values through the calculation.
Do. First evaluate the line:
The product is \(2.75(4.8)=2.75(48)/10=132/10=13.2\). Now calculate the residual:
Conclude. The observed amount transferred is 0.4 megabytes less than the line’s prediction for 4.8 minutes. As a check, \(14.4+(-0.4)=14.0\) megabytes. The negative sign belongs to the residual; it should not be dropped from the numerical answer.
Common Mistakes and AP Exam Tips
A complete hand calculation makes the prediction and the residual easy to distinguish. On an AP response, showing both steps is useful even when the arithmetic is simple: it makes clear that you used the right observed case and the defined order of subtraction.
- Subtracting before finding the prediction. When the line is given, first evaluate \(\hat{y}=a+bx\) at the case’s \(x\). The residual is not \(y-x\), and it is not the difference between the observed response and the intercept.
- Putting the wrong value into the equation. Use the observed predictor value for the case whose residual is requested. Do not use \(y\) as the input just because it is the observed value, and do not use an \(x\)-value from another case.
- Handling a negative slope incorrectly. Preserve the sign in the equation. For example, \(98-3.6(10)\) equals 62, not \(98+3.6(10)\). Parentheses around the substituted \(x\)-value help make the multiplication clear.
- Reversing the residual subtraction. The definition is observed minus predicted, \(y-\hat{y}\), not predicted minus observed. Reversing the order changes the sign.
- Mixing up units. The residual is a difference in response values. If \(y\) is measured in minutes, the residual is in minutes; it is not measured in kilometers or minutes per kilometer.
- Rounding too soon. Keep the prediction at full calculator precision until you subtract, then round the final answer to a reasonable precision for the context. If the equation and data are given to tenths, a final residual in tenths is often appropriate.
- Reporting only a number without identifying what it measures. Include response units and a sentence connecting the result to the observed case. A numerical residual alone may not show which observation or model you used.
A strong response usually writes the substitution, the predicted response, the residual subtraction, and a concise statement in context. For example: “The line predicts \(28.4\) minutes for a 7-kilometer route, so the residual is \(31.6-28.4=3.2\) minutes. This delivery took 3.2 minutes more than predicted.” The context sentence describes this observed case; it does not claim the fitted line guarantees an individual outcome.
Check Your Understanding
For each item, calculate the prediction first when a fitted line is provided, then find the residual using observed minus predicted.
- A model is \(\hat{y}=5+2.5x\). For an observed case with \(x=6\) and \(y=22\), calculate \(\hat{y}\) and the residual. Include the response units if \(y\) is measured in minutes.
- A fitted line is \(\hat{y}=80-4x\). At \(x=7\), an observed response is \(y=49\). Find the prediction and residual, then check that the prediction plus residual equals the observation.
- A line predicts \(18.6\) liters for an observed case whose response is \(17.9\) liters. Calculate the residual and state the subtraction you used.
- For the equation \(\hat{y}=3.4+1.5x\), an observed case has \(x=2.4\) and \(y=7.0\). Find \(\hat{y}\) and the residual, keeping the decimal values through the calculation.
- What quick arithmetic check can help identify whether a calculated residual is consistent with the observed response?