Model Diagnostics
& Residuals
Learn how to evaluate whether a regression model truly fits your data by analyzing residuals, detecting patterns, and interpreting diagnostic plots.
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
Why Do Residuals Matter?
The LINE Assumptions
For a linear regression to produce valid inferences, four conditions (remembered by LINE) must hold:
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.
Good vs. Bad Residual Patterns
Detecting Non-Linearity
Detecting Heteroscedasticity
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:
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
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:
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 \) |
|---|---|---|---|---|
| 15 | 16 | −1 | 1 | 25 |
| 18 | 19 | −1 | 1 | 4 |
| 20 | 21 | −1 | 1 | 0 |
| 22 | 23 | −1 | 1 | 4 |
| 25 | 24 | +1 | 1 | 25 |
Common Mistakes
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?