01 / 20

Regression
Diagnostics

Master leverage, influence, and residual structure to validate your linear models and detect hidden problems in your data.

Statistics

Why Run Diagnostics?

A regression equation that looks great on paper can be driven by a single observation or violate key assumptions without you realizing it. Diagnostics are the tools that let you look under the hood of your fitted model.

Leverage
How far an observation's \( x \)-values are from the center of the predictor space.
Influence
How much a single observation changes the fitted regression when removed.
Residual Structure
Patterns in residuals that reveal violations of linearity, constant variance, or normality.

Understanding Leverage

Leverage measures how unusual an observation's predictor values are. In simple linear regression, the leverage of observation \( i \) is:

Key properties: \( 1/n \leq h_{ii} \leq 1 \). The mean leverage is always \( p/n \) where \( p \) is the number of parameters. An observation with \( h_{ii} > 2p/n \) is conventionally flagged as high leverage.

Leverage in the Predictor Space

\( x \)
\( y \)
\( \bar{x} \)
High leverage
\( x_i - \bar{x} \) is large

Measuring Influence: Cook's Distance

Influence combines leverage and residual size. Cook's distance quantifies how much all fitted values change when observation \( i \) is deleted:

A common rule of thumb: observations with \( D_i > 1 \) deserve close inspection. Alternatively, compare \( D_i \) against the 50th percentile of \( F_{p,\, n-p} \).

Other Influence Measures: DFFITS & DFBETAS

DFFITS
Measures how much \( \hat{y}_i \) changes when observation \( i \) is removed: $$ \mathrm{DFFITS}_i = \frac{\hat{y}_i - \hat{y}_{i(i)}}{s_{(i)}\sqrt{h_{ii}}} $$ Flag if \( |\mathrm{DFFITS}_i| > 2\sqrt{p/n} \).
DFBETAS
Measures how each coefficient \( \hat{\beta}_j \) changes: $$ \mathrm{DFBETAS}_{j(i)} = \frac{\hat{\beta}_j - \hat{\beta}_{j(i)}}{s_{(i)}\sqrt{(\mathbf{X}^\top \mathbf{X})^{-1}_{jj}}} $$ Flag if \( |\mathrm{DFBETAS}| > 2/\sqrt{n} \).

Leverage vs. Influence: The Key Distinction

A High leverage, low influence B High leverage, high influence Line tilts toward B

The Hat Matrix

All leverage values come from the hat matrix \( \mathbf{H} \). In ordinary least squares:

1
\( \mathbf{H} \) is idempotent: \( \mathbf{H}^2 = \mathbf{H} \), and symmetric.
2
\( h_{ii} \) is the \( i \)-th diagonal: it measures how much \( \hat{y}_i \) depends on \( y_i \) itself.
3
\( \mathrm{tr}(\mathbf{H}) = p \): the sum of all leverages equals the number of parameters.

Types of Residuals

Raw
\( e_i = y_i - \hat{y}_i \). Simple but has non-constant variance even under correct model.
Standardized
\( r_i = \dfrac{e_i}{s\sqrt{1 - h_{ii}}} \). Divides by estimated standard error; approximately \( t \)-distributed.
Studentized
\( t_i = \dfrac{e_i}{s_{(i)}\sqrt{1 - h_{ii}}} \). Uses leave-one-out MSE \( s_{(i)}^2 \); follows \( t_{n-p-1} \) exactly.

Reading Residual Plots

Good: Random scatter Fitted values Bad: Funnel (heteroscedasticity) Fitted values Bad: Curve (nonlinearity) Fitted values What to look for Random scatter = assumptions OK Funnel = heteroscedasticity Curve = nonlinearity

Step-by-Step Diagnostic Checklist

1
Fit the model and compute residuals \( e_i = y_i - \hat{y}_i \).
2
Plot residuals vs. fitted values. Look for non-random patterns: curves, funnels, or clusters.
3
Check leverage: extract \( h_{ii} \) from the hat matrix. Flag any \( h_{ii} > 2p/n \).
4
Compute Cook's distance \( D_i \). Investigate observations with \( D_i > 1 \) or \( D_i > 4/n \).
5
Examine studentized residuals. Any \( |t_i| > 3 \) suggests a potential outlier.
6
Normal Q-Q plot of residuals. Deviations from the diagonal indicate non-normality.

Example 1: Computing Leverage

A dataset has \( n = 5 \) observations with \( x \)-values: \( 1, 2, 3, 4, 10 \). We fit a simple linear regression (\( p = 2 \)). Compute the leverage for the 5th observation.

Example 2: Cook's Distance Calculation

Continuing from Example 1: suppose observation 5 has a raw residual \( e_5 = 3.2 \), \( \mathrm{MSE} = 2.5 \), \( h_{55} = 0.92 \), and \( p = 2 \).

Example 3: Interpreting a Residual Plot

Fitted values Residuals U-shaped pattern detected

Common Mistakes

✕ Deleting all outliers
High-influence points may carry real information. Investigate why they deviate before removing them.
✕ Confusing leverage with influence
High leverage alone does not mean the point distorts the fit. Only points with both high leverage and large residuals are influential.
✕ Using raw residuals for outlier tests
Raw residuals have non-constant variance by construction. Use studentized residuals for valid significance testing.

Diagnostic Summary Table

Measure Formula / Source Cutoff
Leverage \( h_{ii} \) Diagonal of \( \mathbf{H} \) \( > 2p/n \)
Cook's \( D_i \) \( \dfrac{e_i^2}{p \cdot \mathrm{MSE}} \cdot \dfrac{h_{ii}}{(1-h_{ii})^2} \) \( > 1 \) or \( > 4/n \)
DFFITS \( \dfrac{\hat{y}_i - \hat{y}_{i(i)}}{s_{(i)}\sqrt{h_{ii}}} \) \( > 2\sqrt{p/n} \)
DFBETAS \( \dfrac{\hat{\beta}_j - \hat{\beta}_{j(i)}}{s_{(i)}\sqrt{(\mathbf{X}^\top\mathbf{X})^{-1}_{jj}}} \) \( > 2/\sqrt{n} \)
Studentized \( t_i \) \( \dfrac{e_i}{s_{(i)}\sqrt{1 - h_{ii}}} \) \( |t_i| > 3 \) (approx.)

Question 1 of 5

In a simple linear regression with \( n = 20 \) and \( p = 2 \), which cutoff is conventionally used to flag high-leverage observations?

Question 2 of 5

An observation has high leverage but its residual is nearly zero. What can you conclude about its influence?

Question 3 of 5

A residual plot of \( e_i \) vs. \( \hat{y}_i \) shows a clear funnel shape (spread increases with fitted values). This pattern most directly suggests a violation of which assumption?

Question 4 of 5

Why are studentized residuals preferred over raw residuals for detecting outliers?

Question 5 of 5

For a model with \( p = 4 \) parameters and \( n = 50 \) observations, what is the DFFITS cutoff for flagging influential observations?