Ceteris LabInteractive Econometrics

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

0% complete0 checkpoint streak
Big question
Concept
Activity
Quiz

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

u^i=yiy^i\hat{u}_i = y_i - \hat{y}_i

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.

wage_sample.csv
12141618201824303612 years education, $18.50 wage16 years education, $24.20 wage18 years education, $31.80 wage14 years education, $21.10 wage16 years education, $28.40 wage13 years education, $19.70 wage20 years education, $35.60 wage15 years education, $26.90 wage14 years education, $22.30 wage17 years education, $30.10 wage12 years education, $17.90 wage18 years education, $33.40 wageEducationWage

Residual examples

1218.5017.860.64
1624.2027.18-2.98
1831.8031.85-0.05
1421.1022.52-1.42
1628.4027.181.22
eduactualfittedresid.
Selected fitted values and residuals from wage_sample.csv
educationactual wagefitted wageresidual
1218.517.860.64
1624.227.18-2.98
1831.831.85-0.05
1421.122.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.