01 / 22

Model Diagnostics
& Residuals

Learn how to evaluate whether a regression model truly fits your data by analyzing residuals, detecting patterns, and interpreting diagnostic plots.

Business Analytics

What Is a Residual?

When we fit a regression line to data, it rarely passes through every point. The residual for each observation is the vertical distance between the actual data point and the predicted value on the line:

A positive residual means the model underpredicted. A negative residual means the model overpredicted.

Visualizing Residuals on a Scatter Plot

\( x \) (predictor)
\( y \) (response)
\( \hat{y} \)
\(-\)
\(+\)
Observed Residual

Why Do Residuals Matter?

Model Validity
Residuals reveal whether a linear model is appropriate for the data or if the relationship is non-linear.
Assumption Checking
Regression assumes constant variance, normality, and independence. Residuals help verify all three.
Prediction Quality
Patterns in residuals signal that predictions may be systematically biased in certain ranges.

The LINE Assumptions

For a linear regression to produce valid inferences, four conditions (remembered by LINE) must hold:

L
Linearity: The relationship between \( x \) and \( y \) is linear.
I
Independence: Residuals are independent of each other (no autocorrelation).
N
Normality: Residuals follow a roughly normal distribution.
E
Equal Variance: The spread of residuals is constant across all \( x \) values (homoscedasticity).

The Residual Plot

A residual plot graphs \( \hat{y} \) (predicted values) on the horizontal axis and \( e_i \) (residuals) on the vertical axis. This is the single most important diagnostic tool.

Predicted \( \hat{y} \)
Residual \( e_i \)
0 ✓ Good: Random Scatter

Good vs. Bad Residual Patterns

Random Scatter
Points spread evenly above and below zero with no visible pattern. Linear model is appropriate.
Curved Pattern
A U-shape or arch means the relationship is non-linear: a linear model misses the true shape.
Fan Shape
Residuals widen (or narrow) as \( \hat{y} \) increases: the equal variance assumption is violated.
Clusters
Groups of points separated by gaps may indicate distinct subpopulations or missing variables.

Detecting Non-Linearity

Predicted \( \hat{y} \)
Residual \( e_i \)
✕ Bad: Curved Pattern

Detecting Heteroscedasticity

Predicted \( \hat{y} \)
Residual \( e_i \)
✕ Bad: Fan Shape (Unequal Variance)

Understanding \( R^2 \) and Residuals

The coefficient of determination \( R^2 \) measures how much of the total variation in \( y \) is explained by the model. It connects directly to residuals:

\( SS_{\text{tot}} \)
Total sum of squares: total variation in \( y \) around its mean \( \bar{y} \).
\( SS_{\text{res}} \)
Residual sum of squares: variation not explained by the model (sum of squared residuals).

Standard Error of the Estimate

While \( R^2 \) is a percentage, the standard error of the estimate (\( s_e \)) gives you a residual measure in the same units as \( y \):

Think of \( s_e \) as the typical size of a residual. If you're predicting revenue in dollars and \( s_e = \$4{,}200 \), your predictions are typically off by about \( \$4{,}200 \).

How to Perform a Residual Analysis

1
Fit the model: Run linear regression and obtain predicted values \( \hat{y}_i \) for each observation.
2
Calculate residuals: Compute \( e_i = y_i - \hat{y}_i \) for every data point.
3
Create a residual plot: Plot \( e_i \) against \( \hat{y}_i \). Look for patterns, curves, or fans.
4
Check normality: Make a histogram or normal probability plot of residuals. They should be roughly bell-shaped.
5
Decide: If assumptions hold, proceed with confidence. If not, consider transforming data or using a different model.

Example 1: Calculating Residuals

A company models advertising spend (\( x \), in thousands) vs. monthly revenue (\( y \), in thousands) and obtains: \( \hat{y} = 12 + 3.5x \). For three months:

Month \( x \) (Ad Spend) \( y \) (Revenue) \( \hat{y} \) \( e_i \)
Jan 4 28 26 +2
Feb 6 32 33 −1
Mar 10 50 47 +3

Example 2: Interpreting a Residual Plot

A business analyst fits a linear model to predict quarterly profit from headcount. The residual plot looks like this:

Predicted Profit (\( \hat{y} \))
Residual \( e_i \)

Example 3: Computing \( R^2 \) from Residuals

Given 5 observations with \( \bar{y} = 20 \):

\( y_i \) \( \hat{y}_i \) \( e_i \) \( e_i^2 \) \( (y_i - \bar{y})^2 \)
1516−1125
1819−114
2021−110
2223−114
2524+1125

Common Mistakes

✕ Ignoring Residual Plots
Relying only on \( R^2 \) without checking residual patterns. A high \( R^2 \) can hide serious model problems.
✕ Incorrect Residual Sign
The residual is \( y_i - \hat{y}_i \), not the reverse. Mixing the order flips the sign of every residual.
✕ Calling Patterns "Random"
Seeing a slight curve but dismissing it as random noise. Even subtle patterns can indicate model misspecification.

Diagnostic Summary

Pattern What It Looks Like What It Means Action
Random scatter Even cloud around zero Assumptions met Proceed with model
U-shape / curve Arching residuals Non-linearity Try polynomial or log model
Fan / cone Spreading residuals Unequal variance Transform \( y \) or use weighted regression
Trend / drift Residuals trend over time Autocorrelation Use time-series methods

Question 1 of 5

If an observation has \( y_i = 45 \) and \( \hat{y}_i = 50 \), what is the residual \( e_i \)?

Question 2 of 5

A residual plot shows a clear U-shaped curve. What does this indicate?

Question 3 of 5

If \( SS_{\text{res}} = 20 \) and \( SS_{\text{tot}} = 100 \), what is \( R^2 \)?

Question 4 of 5

A residual plot shows residuals that fan out (get wider) as the predicted values increase. Which assumption is violated?

Question 5 of 5

Which of the following describes an ideal residual plot for a well-fitting linear model?