---
title: "The line that makes the squared leftovers smallest. | FiveStudy"
description: "A cross-country coach records weekly mileage and best 5K time for eight runners. Many lines pass near those eight points. Least squares is the rule that picks one."
url: https://fivestudy.com/guides/apstats-5-5-least-squares-regression
---

[AP Statistics](https://fivestudy.com/ap-statistics) · Study guide

# The line that makes the squared leftovers smallest.

[Figure: FiveStudy]

FiveStudy

AP® Statistics · Unit 5 · Regression Analysis

AP® Statistics · Unit 5 · Regression Analysis

# The *Least-Squares* Regression Line

Why the regression line is the one that minimizes the sum of squared residuals, how to get its slope, y-intercept, r and r² from technology, and how to interpret each in context.

1. Why “least squares” 2. Getting the line 3. Slope and intercept 4. r²

The idea in one paragraph

Of all possible lines, the **least-squares regression line** (LSRL) is the one with the smallest sum of squared residuals. It always passes through \((\bar{x}, \bar{y})\). Technology gives its slope \(b\), y-intercept \(a\), and the correlation \(r\). Interpret the slope as a *predicted* change per one-unit increase in x, the intercept as the predicted y at x = 0 (when that makes sense), and \(r^2\) as the share of variation in y accounted for by the line.

## 1 Why “least squares”

The simple linear regression model is fit to the data by minimizing the sum of the squares of the residuals. That is why it is called the least-squares regression line. Squaring keeps positive and negative residuals from canceling and penalizes large misses more than small ones.

**Figure 1.** Each residual is turned into a square. The least-squares regression line is the line that makes the total area of the squares as small as possible: 10.81 here, compared with 13.08 for a line that looks almost as good.

Common Mistake 1 · Saying the line minimizes the sum of the residuals

The residuals from the least-squares line always add to 0, and so do the residuals of many other lines. What the LSRL minimizes is the sum of the *squared* residuals.

## 2 Getting the line

The slope \(b\), the y-intercept \(a\), and the correlation \(r\) are calculated using technology. The line always passes through the point \((\bar{x}, \bar{y})\).

Worked Example 1 Find the line with technology

### Used cars

Ages (years): 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10. Prices (thousand dollars): 24.1, 23.6, 21.4, 20.6, 18.6, 21.0, 17.8, 15.0, 15.6, 12.0, 12.6, 9.4. Find the least-squares regression line, r, and r².

1. 1Enter age in L1 and price in L2. STAT, CALC, LinReg(a+bx) L1, L2 (with DiagnosticOn).
2. 2Output: a ≈ 25.688, b ≈ −1.583, r ≈ −0.978, r² ≈ 0.957.

**Answer:** Predicted price = 25.688 − 1.583(age), with r = −0.978 and r² = 0.957.

Behind the calculator

The calculator’s numbers satisfy \(b = r\dfrac{s_y}{s_x}\) and \(a = \bar{y} - b\bar{x}\). For the cars, \(b = -0.978(4.75/2.94) \approx -1.58\). The second formula is why the line goes through \((\bar{x}, \bar{y})\).

**Figure 2.** The least-squares line always passes through the point of means, (x̄, ȳ). Substituting x̄ = 5.08 gives ŷ = 17.64, the mean price.

## 3 Interpreting the slope and the y-intercept

The slope and y-intercept are statistics: they come from a sample of values. The slope is the predicted increase or decrease in the response for a one-unit increase in the explanatory variable. The y-intercept is the predicted response when the explanatory variable equals 0.

Worked Example 2 Interpret the slope

### Used cars

Interpret the slope, −1.583, in context.

1. 1The slope is the predicted change in the response for a one-unit increase in the explanatory variable.
2. 2Use “predicts”: the slope describes the model, not what happens to each car.

**Answer:** For each additional year of age, the model predicts a decrease of 1.583 thousand dollars in the price of these used cars.

Say it like this

“For each additional year of age, the model predicts a decrease of 1.583 thousand dollars in price.”

Common Mistake 2 · Describing the slope as an actual change

“Each car loses 1.583 thousand dollars a year” is not what the slope says. Individual cars scatter around the line. The slope describes the model’s *predicted* change.

Worked Example 3 Interpret the y-intercept, and know when not to

### Two models

(a) Interpret the y-intercept of the car model, 25.688. (b) A model for students gives predicted arm span = −4.2 + 1.03(height), both in centimeters. Does its y-intercept have a sensible meaning?

1. 1(a) At age 0 (a new car) the model predicts a price of 25.688 thousand dollars. The data start at age 1, so this is a mild extrapolation.
2. 2(b) The intercept predicts an arm span of −4.2 cm for a height of 0 cm. No student is 0 cm tall, and arm span cannot be negative.

**Answer:** (a) The model predicts a price of about 25.69 thousand dollars for a 0-year-old car. (b) No: x = 0 is far outside the data and the predicted value is impossible, so the intercept has no reasonable interpretation.

Common Mistake 3 · Interpreting every intercept

Sometimes x = 0 is far outside the data (extrapolation), or the predicted value is impossible, such as a negative length. Then say that the intercept has no reasonable interpretation in context.

## 4 r², the coefficient of determination

The square of the correlation, \(r^2\), is the **coefficient of determination**. It is the proportion of the variation in the response variable that is accounted for by the linear relationship with the explanatory variable.

**Figure 3.** Price varies a lot around its mean (sum of squared deviations 248.6). Around the line, only 10.81 is left. The share removed, 0.957, is r²: the proportion of variation in price accounted for by the linear relationship with age.

Worked Example 4 Interpret r²

### Used cars

Interpret \(r^2 = 0.957\).

1. 1r² is the proportion of variation in the response accounted for by the linear relationship with the explanatory variable.

**Answer:** About 95.7% of the variation in the price of these used cars is accounted for by the linear relationship with age.

Common Mistake 4 · Mixing up r and r²

r = −0.978 gives direction and strength; r² = 0.957 is a proportion of variation and is never negative. To get r from r², take the square root and attach the sign of the slope: \(-\sqrt{0.957} \approx -0.978\).

### Quick reference

| Piece | Interpretation template |
| --- | --- |
| Slope b | For each additional [unit of x], the model predicts an increase (decrease) of [\|b\|] [units of y]. |
| Intercept a | The model predicts [a] [units of y] when [x] = 0 (only if x = 0 is sensible and near the data). |
| r | r measures the strength and direction of the linear association between [x] and [y]. |
| r² | About [r² as %] of the variation in [y] is accounted for by the linear relationship with [x]. |
| Facts | Minimizes Σ(residual²); passes through \((\bar{x}, \bar{y})\); residuals sum to 0 |

FiveStudy AP® Statistics · The least-squares regression line
