Learning
LESSON 09 / 12 · TOPIC 5.5

Why does the best-fitting line minimize squared errors?

You will be able to: Explain least squares and compare candidate lines using squared residuals.

Graphs, tables and mathematical reasoningFree study resourceReview editionTeacher review pending

Why does the best-fitting line minimize squared errors?

Two lines can both pass near a class’s quiz scores. We need a consistent rule for deciding which line predicts these data with less error.

A useful starting point: How can errors reveal that a line is the wrong shape? →

Words and symbols before equations

Squared residual e²
The residual multiplied by itself, so positive and negative errors both contribute nonnegative amounts.
SSE
Sum of squared residuals across all observed pairs.
Least-squares regression line
The line with the smallest SSE among all candidate intercepts and slopes.
Parameter surface
A plot showing how SSE changes as the candidate intercept and slope change.
Observed pairs, fitted line and vertical residualsPaired observations: practice and quiz scores051015200123456Practice time x (hours)y (points)P1P2P3P4P5
Read this model snapshot. Candidate ŷ=2 + (2)x; SSE=14 points². Best: ŷ=2+2x, SSE=14. Excess squared error=0 points². Dashed segments are vertical residuals.
What this picture assumes

Fixed synthetic data: (1,5),(2,4),(3,10),(4,8),(5,13), in hours and points. The best fit is intercept 2 and slope 2 with SSE=14 points squared. The 3D height is SSE, not a third measured variable. Axes stay fixed: intercept 0–4, slope 1–3, SSE 0–160. No motion runs automatically.

Read the picture in three steps

  1. Read the axes and labels first. Identify what each symbol and line represents. Read the units and fixed conditions before comparing quantities.
  2. Candidate ŷ=2 + (2)x; SSE=14 points². Best: ŷ=2+2x, SSE=14. Excess squared error=0 points². Dashed segments are vertical residuals.
  3. Check what the picture assumes below. Use the Explore task to predict one change before moving a control.

Connect the picture to the mathematics

Adding signed errors can hide poor predictions because positive and negative errors cancel. Squaring prevents cancellation and gives larger errors a greater contribution. SSE has squared response units; it is not an average error in points.

For the five pairs (1,5),(2,4),(3,10),(4,8),(5,13), the least-squares line is ŷ=2+2x. Its residuals are 1,−2,2,−2,1 and SSE=1+4+4+4+1=14 points squared.

The candidate line ŷ=1+2x has residuals 2,−1,3,−1,2 and SSE=19. Moving both intercept and slope changes the fit. The optional 3D surface uses these two parameters as horizontal directions and SSE as height, making the minimum visible. It is a parameter landscape, not a scatterplot of three measured variables.

A worked example, step by step

Compare ŷ=2+2x with ŷ=1+2x on the five stated pairs.

  1. Calculate predictions for the first line: 4,6,8,10,12.
  2. Subtract to get residuals 1,−2,2,−2,1; square and sum to obtain 14.
  3. For the second line predictions are 3,5,7,9,11, giving residuals 2,−1,3,−1,2 and SSE=19.
  4. The first has smaller SSE; technology confirms it is the global least-squares fit for these data.
Common mix-up

Least squares minimizes squared vertical residuals, not the signed sum or perpendicular distances.

CHECK THE IDEA

Why not minimize the sum of signed residuals?

Compare with an explanation

Large positive and negative errors could cancel even when predictions are poor.

Now investigate one change Explore →

Predict. Change one thing. Explain.

Start with intercept 2 and slope 2. Change one at a time, then both. Compare SSE with the best fit and inspect the optional 3D minimum; camera rotation must not change the numbers.

On narrow screens, swipe or scroll diagrams sideways to read all labels.

Observed pairs, fitted line and vertical residualsPaired observations: practice and quiz scores051015200123456Practice time x (hours)y (points)P1P2P3P4P5

Candidate ŷ=2 + (2)x; SSE=14 points². Best: ŷ=2+2x, SSE=14. Excess squared error=0 points². Dashed segments are vertical residuals.

Paired input values and model calculations (display rounded)
Studentx (hours)y (points)ŷ (points)e=y−ŷ (points)e² (points²)
P115411
P2246-24
P3310824
P44810-24
P55131211
2D alternative to 3D: SSE (points²) for candidate intercepts and slopes. The central minimum is 14.
Slope b (points/hour) ↓ / Intercept a (points) →01234
1149104694429
1.577.7547.7527.7517.7517.75
23419141934
2.517.7517.7527.7547.7577.75
3294469104149

Fixed synthetic data: (1,5),(2,4),(3,10),(4,8),(5,13), in hours and points. The best fit is intercept 2 and slope 2 with SSE=14 points squared. The 3D height is SSE, not a third measured variable. Axes stay fixed: intercept 0–4, slope 1–3, SSE 0–160. No motion runs automatically.

Explain what you noticed: Answer the investigation prompt above. State one observation and explain it using the paired observations, predictions, residuals, graph scales or model assumptions. Identify what the representation cannot tell you.

Apply the idea to a fresh problem Practice →

Show what you understand.

Two original questions are a starting check, not proof of mastery. Explain your choice before revealing the answer.

1. Residuals −2 and 3 contribute SSE…

Show answer and reasoning

13. (−2)²+3²=4+9=13.

2. A lower SSE on the same data indicates…

Show answer and reasoning

Smaller total squared vertical errors. Least squares is a fit criterion, not a causal or extrapolation guarantee.

Original written challenge

4 points · self-check · not an official AP question

On the same three observations, line A has residuals 1,−1,2 and line B has residuals 0,0,3. Compare their SSE and explain the criterion.

This response is not submitted or saved. Copy it before leaving.

Compare with the answer and four-point rubric
  1. 1 point: Square each residual for A: 1,1,4.
  2. 1 point: A has SSE=6; B has SSE=0+0+9=9.
  3. 1 point: A is better by the least-squares criterion among these two candidates.
  4. 1 point: This does not prove A is the best among every possible line or that either model is appropriate.

Accept equivalent correct methods and explanations. This is a Refresh Kid teaching rubric, not an official AP scoring guideline.

Recall the ideas without notes Review →

Retrieve it before you reveal it.

RECALL 1What does least squares minimize?

The sum of squared vertical residuals.

RECALL 2Why square errors?

To avoid cancellation and penalize large errors more.

RECALL 3What is the third dimension in the surface?

SSE, not a third measured variable.

Revisit these tomorrow and a week later. Try a fresh problem and explain why the method applies.

Why does the best-fitting line minimize squared errors?

  • SSE=Σ(y−ŷ)².
  • Minimize SSE over a and b in ŷ=a+bx.
  • SSE units are squared response units.

Remember: Least squares minimizes squared vertical residuals, not the signed sum or perpendicular distances.

Conditions: Fixed synthetic data: (1,5),(2,4),(3,10),(4,8),(5,13), in hours and points. The best fit is intercept 2 and slope 2 with SSE=14 points squared. The 3D height is SSE, not a third measured variable. Axes stay fixed: intercept 0–4, slope 1–3, SSE 0–160. No motion runs automatically.

Refresh Kid · AP Statistics Unit 5 · Objectives 5.5.A · Review edition

Framework, scope and review status

Mapped to College Board, AP Statistics CED, Topic 5.5, objectives 5.5.A. Framework effective Fall 2026, checked September 17, 2026. Unit 5 is Regression Analysis in the revised five-unit course: scatterplots, correlation, linear prediction, residuals and least squares. Inference tests for regression slopes are outside this unit.

Examples and datasets are synthetic, independently authored teaching material. Correlation describes linear association, not causation. Least squares uses squared vertical residuals and a fitted intercept. Check scatterplots, residual patterns, unusual observations, explanatory range and population applicability before interpreting a model. Five-point demonstrations do not support population or causal claims.

The Organic Chemistry Tutor companion title and destination were checked; the full video was not reviewed. Khan Academy’s destination was located, but full lesson content was not available to the research tool. OpenStax is optional reference reading. No provider scripts, questions or graphics were copied. Refresh Kid is not affiliated with these providers.

GitHub’s 3D website collection informed optional spatial inspection. Our original least-squares surface uses self-hosted Three.js with its MIT license. The two base axes are candidate intercept and slope; vertical height is the resulting sum of squared errors. Rotation helps inspect the valley and its minimum as two parameters change. This is a parameter surface, not three measured variables. Fixed scales, an exact 2D parameter table and a labeled scatterplot provide alternatives. No autoplay or external 3D dependency is required.

Independent teacher review and observation of students remain pending. Technical checks do not certify statistical accuracy, accessibility or learning effectiveness. This is a review edition.

Released AP Statistics questions and scoring guides are optional. Older exams use the earlier framework, so check alignment before selecting parts. All practice on this page is original, not official AP material.

Learn → Explore → Practice → Review is informed by the IES learning guide. This implementation has not yet been evaluated with learners.

OPTIONAL LIVE SUPPORT

Want to work through this with a tutor?

Bring your question about Why does the best-fitting line minimize squared errors? Your explanation and answers remain free to access.

Request a statistics tutor →Ask about this lesson on WhatsAppThe team can confirm teacher availability and next steps.