Lesson 7
Fitted values and residuals
Big question
How do we compare what the model predicts with what actually happened?
Lesson progress
Complete checkpoints as you learn
Learning objectives
- Explain fitted values and residuals in plain language.
- Use fitted value correctly in an interpretation.
- Connect the lesson idea to a formula, graph, Python result, or real example.
Simple explanation
A fitted value is the model's predicted y for a specific observation. A residual is the actual y minus the fitted value. Residuals show whether an observation is above or below the fitted line.
Key terms
- Fitted value
- The predicted value from the estimated regression line, written y-hat.
- Residual
- The difference between actual y and fitted y for an observation.
- Prediction error
- Another name for the gap between actual and predicted values.
- Residual plot
- A chart showing residuals against x or fitted values.
Residual
Actual minus fitted equals residual.
Example
The model predicts $27.18 for one worker with 16 years of education. If the worker earns $24.20, the residual is -$2.98.
Interactive visual
Actual, fitted, residual
Vertical gaps between dots and the fitted line are residuals.
Residual examples
| education | actual wage | fitted wage | residual |
|---|---|---|---|
| 12 | 18.5 | 17.86 | 0.64 |
| 16 | 24.2 | 27.18 | -2.98 |
| 18 | 31.8 | 31.85 | -0.05 |
| 14 | 21.1 | 22.52 | -1.42 |
Live notebook
Run this lesson as a notebook
Open an editable notebook cell-by-cell, run Python in the browser, and download the `.ipynb` file for later.
Interactive activity
Residual calculator
Residual = actual y - predicted y.
Residual = -2.98. The model overpredicted.
Try it yourself
Calculate the residual when actual wage is 24.20 and predicted wage is 27.18.
Common mistakes
Check these before you move on.
The error term is unobserved in the population model. The residual is calculated after estimating the model.
Quick quiz
If actual y is 24.20 and fitted y is 27.18, what is the residual?
Quick quiz
What does a positive residual mean?
Key takeaway
Residuals are the observation-by-observation gaps that show where the model underpredicts or overpredicts.