core27 min studyLesson 256 in Mathematics

Leverage, influence, and residual diagnostics

Distinguish unusual predictor geometry, unusual responses, and sensitivity to deleting an observation.

On this page

What you’ll understand

  • Calculate leverage from the hat matrix.
  • Explain how residual size and leverage combine in Cook's distance.
  • Use diagnostic patterns without treating them as proofs of model assumptions.

A point can be unusual in its predictors, surprising in its response, or influential on the fitted model. Those are three different properties. A remote predictor location may follow the fitted trend closely; a large residual near the center may barely change the slope. Diagnostics help locate these situations and investigate model failures. Their role is to expose questions about data collection, mean structure, dependence, and sensitivity, rather than automatically label observations as disposable or certify that a model is correct.

Leverage is a property of the design

In a full-rank fixed design, the diagonal entry hiih_{ii} of the hat matrix measures how strongly response YiY_i contributes to its own fitted value. It depends on the predictor rows, not on the responses. Because H is an orthogonal projection, its diagonal entries lie between zero and one and sum to its rank p. Thus p/n is the average leverage, although a multiple of that average is only a screening guideline and not a universal statistical threshold.

For an intercept and a single nonconstant predictor, leverage is one over n plus the squared distance from the predictor mean divided by the total centered predictor sum of squares. Remote predictor values therefore tend to have high leverage. Under spherical errors the residual variance at observation i is σ2(1−hii)\sigma^2(1-h_{ii}). A high-leverage point can pull the fit toward itself and thereby hide a large response discrepancy behind a relatively small raw residual. Standardizing residuals accounts for that geometry.

hii=xiT(XTX)−1xi,∑i=1nhii=p,Var⁡(ei)=σ2(1−hii)h_{ii}=x_i^{\mathsf T}(X^{\mathsf T}X)^{-1}x_i,\quad \sum_{i=1}^n h_{ii}=p,\quad \operatorname{Var}(e_i)=\sigma^2(1-h_{ii})
Here xᵢ is the transposed predictor row and e=(I−H)Y. The variance equality uses the correct mean and spherical error covariance; the leverage identities are deterministic.↔ Scroll wide equations horizontally.

Influence asks what changes when a point is removed

An influential observation materially changes a fitted quantity when it is removed or perturbed. Cook's distance summarizes the squared change in all fitted values after deleting one observation, scaled by p times the full-model residual variance estimate. In a full-rank least-squares fit with positive residual variance and hii<1h_{ii}<1, it can be calculated from the full residual and leverage. Its formula makes the interaction explicit: a large residual and a leverage close to one can produce a substantial change.

Influence is a sensitivity description, not proof that the observation is wrong. A rare but valid operating condition may be exactly where predictions matter most. Check provenance and units, compare the fit with and without the point, and report the consequences for the target question. Automatic deletion based on a diagnostic threshold can remove scientifically meaningful extremes and make reported uncertainty conditional on an unacknowledged selection procedure. If deleting a point destroys rank, ordinary deletion formulas need special treatment rather than division by zero.

Di=∥y^−y^(i)∥2ps2=ei2ps2hii(1−hii)2D_i=\frac{\|\widehat y-\widehat y_{(i)}\|^2}{p s^2}=\frac{e_i^2}{p s^2}\frac{h_{ii}}{(1-h_{ii})^2}
The deleted-fit vector is evaluated at all original design rows. This identity assumes the original and deleted designs have full rank, s²>0, and hᵢᵢ<1; it is a sensitivity statistic, not a universal rejection test.↔ Scroll wide equations horizontally.

Patterns suggest investigations rather than verdicts

A curved residual pattern can suggest missing mean structure; a changing spread can suggest heteroskedasticity; a run-order pattern can suggest dependence or drift. A normal-quantile plot examines compatibility with a Gaussian shape but cannot establish independence or the correctness of the mean. Ordinary fitted residuals are already correlated through I−H, even when the underlying errors are independent. Interpreting them as a fresh iid sample ignores the fitting operation that created them.

A useful diagnostic workflow links each plot to an assumption and an action. Revisit the mean specification when curvature is plausible, inspect collection order when clusters appear, and evaluate robust or covariance-aware uncertainty when variance patterns persist. A visually featureless plot can reflect low power or limited predictor coverage, so it does not verify the model. Diagnostics are strongest when combined with knowledge of how observations were collected and with sensitivity analyses for the actual predictions or contrasts being used.

A modest residual can still matter

Fit an intercept and slope to x=(−1,0,1,2)x=(-1,0,1,2) and y=(0,0,0,1)y=(0,0,0,1). Calculate the last observation's leverage and Cook's distance.

  1. The predictor mean is 1/21/2 and the centered predictor sum of squares is 55. The fitted line is 0.1+0.3x0.1+0.3x, yielding fitted values (−0.2,0.1,0.4,0.7)(-0.2,0.1,0.4,0.7) and residuals (0.2,−0.1,−0.4,0.3)(0.2,-0.1,-0.4,0.3).

  2. SSE is 0.04+0.01+0.16+0.09=0.300.04+0.01+0.16+0.09=0.30. With p=2 and n=4, s2=0.15s^2=0.15. The last leverage is 1/4+(2−1/2)2/5=0.71/4+(2-1/2)^2/5=0.7.

  3. Insert e4=0.3e_4=0.3 into the formula: D4=(0.09/0.30)(0.7/0.09)=7/3D_4=(0.09/0.30)(0.7/0.09)=7/3. Deleting the last point leaves three zero responses and a zero fitted line, directly confirming squared fitted change 0.700.70 and 0.70/0.30=7/30.70/0.30=7/3.

The result

The last response is influential for this fit even though its raw residual is only 0.3. Its leverage and the refit comparison explain the sensitivity; neither establishes that the observation should be discarded.

Explore the model

Interactive lab

Interactive lab · matrix

Inspect directional sensitivity

Pause and Reset; set a=1 and b=0 to obtain the identity matrix. Predict condition number 1. Start a fresh Reset, set a=0.25 and b=2, and inspect the singular-value imbalance. This illustrates why some design directions can be sensitive. The triangular matrix is not a regression design with deletable observations, so its readouts are not leverage, residuals, or Cook's distance.

Inspect directional sensitivityThe selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. Current readings: Area scale · det A: 1.4; Singular values · σmax, σmin: 1.597, 0.876; Condition number · κ₂(A): 1.823. All parameters are adjustable with the labeled controls below.Matrix A with first row 1.4, 0.6 and second row zero, one; display interpolates between identity and A while final determinant remains 1.4.−4−2024−2−1012x · equal geometric scaleyA = [ 1.4 0.6 ; 0 1 ]Display blend: 0% · final values below
Interpolated geometryOriginal unit squareSelected final transform
Area scale · det A
1.4
Singular values · σmax, σmin
1.597, 0.876
Condition number · κ₂(A)
1.823
t = 0 s

The selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forSensitivity requires identifying the quantity and perturbation being compared; a geometry picture alone does not diagnose data quality.

Check your understanding

Which statement about a high-leverage observation is justified?

Try it yourself

In a full-rank fit with p=2, an observation has ei=0.4e_i=0.4, hii=0.2h_{ii}=0.2, and s2=0.8s^2=0.8. Assume deletion retains rank. Calculate Cook's distance and explain why a small value does not certify the mean model.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Keep the squared factor (1−hᵢᵢ)² in the denominator, and distinguish sensitivity to one deletion from all possible model failures.

Compare with the solution

The value is Di=(0.16/(2⋅0.8))(0.2/0.82)=0.1⋅0.3125=0.03125=1/32D_i=(0.16/(2\cdot0.8))(0.2/0.8^2)=0.1\cdot0.3125=0.03125=1/32. This says the fitted values are relatively insensitive to deleting this observation at the stated scale. It does not rule out shared curvature, dependence, selection bias, or failures that affect many observations together.

Take it with you

  • Leverage uses predictor geometry; a residual uses both design and response.
  • Cook's distance combines residual size and leverage to measure deletion sensitivity.
  • Diagnostic checks can contradict assumptions but cannot prove their truth.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.