Residuals and Diagnostics
Least squares will happily fit a line to anything, so check what it leaves behind. Residual plots show curvature and fanning, says how much of the variation the line explains, and leverage and Cook's distance catch the single points that are quietly steering the whole fit.
What the symbols mean
- Total sum of squares
Σ(yᵢ − ȳ)²: how much the responses vary in all.
- Regression sum of squares
Σ(ŷᵢ − ȳ)²: the part of that variation the line reproduces.
- Error sum of squares
Σ(yᵢ − ŷᵢ)²: what the line leaves unexplained.
- Coefficient of determination
The fraction of the variation in y explained by the fit.
What the symbols mean
- Leverage
How strongly point i pulls the fitted line toward itself, between 1/n and 1. Points far from x̄ have high leverage.
- Residual
yᵢ − ŷᵢ, the vertical miss at point i.
What the symbols mean
- Standardized residual
The residual in units of its own standard deviation: beyond ±2 is unusual, beyond ±3 suspect.
- Cook's distance
How far the fitted values move, all together, when point i is deleted. Above about 1 the point is influential.
- Number of coefficients
2 for a straight line.
Explanation
Regression diagnostics are simply the checks you run after fitting a line to make sure you should believe it. You already met residuals and in the intro course; the new ideas here are about single points. Leverage (how far a point's sits from the others, which decides how hard it can pull on the line) and Cook's distance (how much the whole fit would move if you deleted that one point). The formulas have a few pieces, but each one answers a plain question: does a line fit, and is any one point running the show?
The scene. A test engineer measures how far a spring deflects under loads of 1 to 5 N, and the points line up beautifully. Then she adds one test at 12 N, where the coils touch ("coil bind") and the spring can't deflect any further. With that one point the fitted slope drops by two-thirds. Nothing in the fitted equation warns you; the diagnostics do.
Residual plots: what the line missed. Plot the residuals against (or against ). A good fit leaves a patternless band around zero. Two patterns matter most:
- Curvature (a U or an arch): the relationship isn't straight. Add an term or transform the variables.
- Fanning (spread growing with ): the noise is proportional to the size of the reading, as in many flow meters and chemical assays. The line is still sensible, but , the intervals and the tests are wrong. A log transform or weighted least squares fixes it.
A normal probability plot of the residuals checks the normality that t intervals rely on.
Why . Split each deviation: . Square and add. The cross term is , because the normal equations force the residuals to be uncorrelated with . So the total variation splits cleanly into explained plus unexplained, and is the explained share. For a line it equals , the squared correlation.
is not a fit test. A curved relationship can have and still be the wrong model, and a fanning one can have a high with badly wrong intervals. In calibration, says nothing about whether is small enough for the job.
Leverage: where the line is pinned. The fitted value at point is a weighted sum of all the responses:
The weight on its own response, , is its leverage. The leverages add to 2, one per coefficient, so the average is , and is flagged as high.
Leverage hides errors. Let be what the other points predict at . If happened to equal , adding point wouldn't change the fit at all. And moves by for every unit moves. Together:
A point with drags the line 90% of the way to itself, so its residual shows only a tenth of its real miss. That's why residuals are standardized by , and why bad high-leverage points don't show up as big raw residuals.
Influence is leverage times surprise. Cook's distance multiplies the two: a point is influential when it is both far out in (large ) and off the trend (large ). A far-out point that agrees with the rest is valuable: it pins the slope. Investigate influential points instead of deleting them. The 12 N test was telling the truth about coil bind, just not about the linear range.
See it
Worked examples
For the pressure-transmitter calibration (, , , residuals mV, mV), find , then check the 60 kPa standard, which has the largest residual: its leverage, standardized residual and Cook's distance.
- 1
, so .
Practice
Type your answer and check it. Solve them all to complete the lesson.
A flow-meter calibration uses reference flows. The total sum of squares of the readings is and the residual standard deviation is . Find to 3 decimal places.
For the pressure-transmitter calibration (standards kPa, so , and ), find the leverage of the 100 kPa standard.
A flow-meter calibration's residual plot is a fan: residuals spread about L/min at low flow and L/min at high flow. What does it mean, and what helps?
A thermocouple fit over 0 to 600 °C has , but its residuals form a clear arch: negative at both ends of the range and positive in the middle. What should the engineer conclude?
In the pressure calibration ( mV, , ), the 20 kPa standard has residual mV. Find its standardized residual, to 2 decimal places.
A fatigue study regresses log life on stress amplitude for specimens. The specimen tested at the highest stress has leverage and standardized residual . Find its Cook's distance, to 2 decimal places. Is it influential?
Residuals from a regression go on a normal probability plot (sorted residuals against z quantiles). The middle points follow a straight line, but the lowest few fall well below it and the highest few well above it. What does that say?
A run far out in has leverage and residual in the full fit. How far is it from the line fitted to all the other runs?
The hardest one here. Get it, and you've got this lesson.
A spring deflects and mm under loads of and N. A sixth test at 12 N reads only mm because the coils bind. For the least-squares line through all six points, find (a) the leverage of the 12 N test, (b) its residual in mm and (c) its Cook's distance, given that the six-point fit has mm. Enter , and .
Where it's used
Calibration labs, test departments and data teams look at residual plots before they believe any fit. Fanning residuals are routine in flow metering and chemical assays and drive the switch to log scales or weighted fits. Leverage and Cook's distance are standard regression output, used to catch the single test at an extreme setting, or the one mislabeled sample, that would otherwise set a design value by itself.