Ceteris LabInteractive Econometrics

Lesson 8

Ordinary Least Squares intuition

Big question

How does OLS choose the fitted line?

Lesson progress

Complete checkpoints as you learn

0% complete0 checkpoint streak
Big question
Concept
Activity
Quiz

Learning objectives

  • Explain ordinary least squares intuition in plain language.
  • Use ordinary least squares correctly in an interpretation.
  • Connect the lesson idea to a formula, graph, Python result, or real example.

Simple explanation

Ordinary Least Squares chooses the intercept and slope that make the sum of squared residuals as small as possible. Squaring makes positive and negative residuals count as errors and gives larger misses extra weight.

Key terms

Ordinary Least Squares
The method that chooses the fitted line by minimizing the sum of squared residuals.
Squared residual
A residual multiplied by itself.
Sum of squared residuals
The total of all squared residuals for a fitted line.
Best fit
The fitted line selected by the chosen criterion.

OLS objective

minβ^0,β^1i=1n(yiy^i)2\min_{\hat{\beta}_0,\hat{\beta}_1}\sum_{i=1}^{n}(y_i-\hat{y}_i)^2

Example

A line that is too flat underpredicts high-education wages and overpredicts low-education wages. OLS balances these misses by minimizing squared residuals.

Interactive visual

Find the least-squares line

Try nearby slopes and compare the residual sum of squares.

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

Least-squares target

Sum of squared residuals

20.88

The OLS slope near 2.33 gives the smallest total squared residuals for this teaching sample.

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

OLS best-line intuition

OLS chooses the line that makes these vertical misses as small as possible after squaring them.

Education (years)Hourly wage
Slope: 2.33
Intercept: -10.10
R-squared: 0.949

OLS line challenge

Adjust the line, then compare your sum of squared residuals with the OLS line.

Your line compared with the data

Each dot is one observation. The fitted line summarizes the relationship between Education and Wage.

Your trial lineEducationWage
Slope: 1.50
Intercept: 0.00
OLS R-squared: 0.949

Your SSR: 157.28

OLS SSR: 20.88

Try it yourself

Write one plain-English sentence explaining the main idea from this lesson.

Common mistakes

Check these before you move on.

A regression coefficient describes a pattern unless the assumptions or research design support a causal interpretation.

Quick quiz

What does OLS minimize?

Quick quiz

Why are residuals squared in OLS?

Key takeaway

OLS chooses the line with the smallest total squared prediction errors.