Skip to content

Least-Squares Regression

Find and interpret the least-squares regression line (LSRL) and make predictions.

Written and reviewed by the Study Mondo Education TeamLast updated
🎯⭐ INTERACTIVE LESSON

Try the Interactive Version!

Learn step-by-step with practice exercises built right in.

Start Interactive Lesson →

Least-Squares Regression

Regression Line (Line of Best Fit)

Purpose: predict response variable y from explanatory variable x

Goal: minimize vertical distances (residuals) from points to line

Form: y^=a+bx\hat{y} = a + bx

where:

  • \(\hat{y}\) = predicted y value (not actual y)
  • a = y-intercept
  • b = slope

Finding the Regression Line

Slope: b=r⋅sysxb = r \cdot \frac{s_y}{s_x}

where r = correlation, \(s_x\) = std dev of x, \(s_y\) = std dev of y

Y-intercept: a=yˉ−bxˉa = \bar{y} - b\bar{x}

Key fact: regression line always passes through \((\bar{x}, \bar{y})\)

Interpreting Slope and Intercept

Slope (b): predicted change in y for each 1-unit increase in x

  • Positive slope: as x increases, predicted y increases
  • Negative slope: as x increases, predicted y decreases
  • Units: same ratio as y-units per x-unit

Example: \(\hat{\text{Score}} = 60 + 5 \cdot \text{Hours}\)

  • Slope b = 5: for each additional hour studied, predicted score increases by 5 points
  • Intercept a = 60: predicted score if 0 hours studied (often not meaningful in context)

Y-intercept (a): predicted y value when x = 0

  • Meaningful only if x = 0 is reasonable in context
  • Example: predicted exam score with 0 hours studied may not make sense

Making Predictions

Prediction for given x:

  1. Substitute x into regression equation
  2. Calculate \(\hat{y}\)
  3. Caveat: only valid for x-values in range of data

Extrapolation: predicting beyond range of data

  • Risky: relationship may not hold outside observed range
  • Avoid extrapolation unless strong theoretical reason

Example: If data ranges 1–6 hours, predicting score for 50 hours is extrapolation (unreliable)

Worked Example

Data: 6 students, hours studied (x) vs. exam score (y)

Hours (x)Score (y)
265
378
482
588
690
895

Given: \(\bar{x} = 4.67, \bar{y} = 83, s_x ≈ 1.97, s_y ≈ 10.05, r ≈ 0.97\)

Step 1: Calculate slope b=0.97⋅10.051.97≈0.97⋅5.10≈4.95b = 0.97 \cdot \frac{10.05}{1.97} ≈ 0.97 \cdot 5.10 ≈ 4.95

Step 2: Calculate intercept a=83−4.95⋅4.67≈83−23.1≈59.9a = 83 - 4.95 \cdot 4.67 ≈ 83 - 23.1 ≈ 59.9

Regression line: \(\hat{\text{Score}} ≈ 59.9 + 4.95 \cdot \text{Hours}\)

Prediction: If student studies 7 hours: Score^=59.9+4.95(7)=59.9+34.65=94.55≈94.6 points\hat{\text{Score}} = 59.9 + 4.95(7) = 59.9 + 34.65 = 94.55 ≈ 94.6\text{ points}

(This is interpolation; 7 hours is within data range 2–8)

Residuals and Residual Plots

Residual: actual y − predicted y = \(y - \hat{y}\)

Residual plot: scatterplot of residuals vs. x values

  • If residuals randomly scattered around 0 → linear model is appropriate
  • If residuals show pattern (curved, increasing) → linear model inadequate

Sum of residuals: always ≈ 0 for least-squares regression

Common Mistakes

  1. Swapping x and y: regression of y on x ≠ regression of x on y
  2. Over-interpreting intercept: a = 60 (x = 0) may have no real meaning
  3. Extrapolating recklessly: don't predict far outside data range
  4. Confusing \(\hat{y}\) with y: \(\hat{y}\) is prediction, not actual value
  5. Ignoring residuals: always check residual plot to validate linear assumption

AP Exam Tip

FRQ response format:

  1. Show work: state formula for slope \(b = r \cdot \frac{s_y}{s_x}\) and intercept \(a = \bar{y} - b\bar{x}\)
  2. Write regression equation: \(\hat{\text{variable}} = a + b \cdot \text{variable}\)
  3. Interpret slope in context: "For each additional [x-unit], predicted [y-variable] increases by [slope value] [y-units]."
  4. Caveat on predictions: "This prediction assumes the linear relationship continues in this range" or note if extrapolating

Example: "\(\hat{\text{Score}} = 59.9 + 4.95 \cdot \text{Hours}\). For each additional hour studied, we predict the exam score increases by 4.95 points."

📚 Practice Problems

1Problem 1medium

❓ Question:

A study measures hours studied (x) and test scores (y) for 5 students: (2,65), (3,70), (4,75), (5,80), (6,85). Given x̄ = 4, ȳ = 75, calculate the least-squares regression line.

💡 Show Solution

Step 1: Calculate slope b₁ Formula: b₁ = Σ(x-x̄)(y-ȳ) / Σ(x-x̄)²

Create table: | x | y | (x-x̄) | (y-ȳ) | (x-x̄)(y-ȳ) | (x-x̄)² | |---|-------|--------|---------| | 2 | 65 | -2 | -10 | 20 | 4 | | 3 | 70 | -1 | -5 | 5 | 1 | | 4 | 75 | 0 | 0 | 0 | 0 | | 5 | 80 | 1 | 5 | 5 | 1 | | 6 | 85 | 2 | 10 | 20 | 4 |

Σ(x-x̄)(y-ȳ) = 50 Σ(x-x̄)² = 10

b₁ = 50/10 = 5

Step 2: Calculate y-intercept b₀ b₀ = ȳ - b₁x̄ b₀ = 75 - 5(4) b₀ = 75 - 20 = 55

Step 3: Write equation ŷ = 55 + 5x

Interpretation: Each additional hour studied predicts a 5-point increase in test score.

Answer: ŷ = 55 + 5x

2Problem 2medium

❓ Question:

For data with Σx = 50, Σy = 120, Σx² = 350, Σxy = 720, n = 10, find the least-squares regression line.

💡 Show Solution

Step 1: Calculate means x̄ = Σx/n = 50/10 = 5 ȳ = Σy/n = 120/10 = 12

Step 2: Calculate slope Formula: b₁ = [Σxy - n(x̄)(ȳ)] / [Σx² - n(x̄)²]

Numerator: Σxy - n(x̄)(ȳ) = 720 - 10(5)(12) = 720 - 600 = 120 Denominator: Σx² - n(x̄)² = 350 - 10(5)² = 350 - 250 = 100

b₁ = 120/100 = 1.2

Step 3: Calculate intercept b₀ = ȳ - b₁x̄ = 12 - 1.2(5) = 12 - 6 = 6

Step 4: Write equation ŷ = 6 + 1.2x

Verification: When x = 5, ŷ = 6 + 6 = 12 = ȳ ✓

Answer: ŷ = 6 + 1.2x

3Problem 3easy

❓ Question:

A regression of car weight (x, in 1000s of lbs) on fuel efficiency (y, mpg) gives ŷ = 45 - 5.2x. Interpret the slope and predict mpg for a 3,500 lb car.

💡 Show Solution

Step 1: Interpret slope Slope = -5.2 mpg per 1000 lbs

Interpretation: "For each additional 1,000 pounds of car weight, fuel efficiency is predicted to DECREASE by 5.2 miles per gallon."

The negative slope makes sense: heavier cars use more fuel.

Step 2: Convert weight to correct units Car weight = 3,500 lbs = 3.5 thousands of lbs So x = 3.5

Step 3: Make prediction ŷ = 45 - 5.2(3.5) ŷ = 45 - 18.2 ŷ = 26.8 mpg

Step 4: Complete interpretation "A car weighing 3,500 pounds is predicted to have fuel efficiency of approximately 26.8 miles per gallon."

Answer: Slope: Each 1,000 lb increase predicts 5.2 mpg decrease Prediction: 26.8 mpg

4Problem 4medium

❓ Question:

Given x̄ = 15, ȳ = 240, sₓ = 4, sᵧ = 60, r = 0.75, find the regression line using b₁ = r(sᵧ/sₓ).

💡 Show Solution

Step 1: Calculate slope Formula: b₁ = r(sᵧ/sₓ)

b₁ = 0.75 × (60/4) b₁ = 0.75 × 15 b₁ = 11.25

Step 2: Calculate y-intercept b₀ = ȳ - b₁x̄ b₀ = 240 - 11.25(15) b₀ = 240 - 168.75 b₀ = 71.25

Step 3: Write regression equation ŷ = 71.25 + 11.25x

Interpretation: Each 1-unit increase in x predicts an 11.25-unit increase in y.

Answer: ŷ = 71.25 + 11.25x

5Problem 5medium

❓ Question:

The regression of temperature (°F) vs ice cream sales ($) is ŷ = -2 + 0.8x. Is it appropriate to predict sales when temp = 0°F? Explain.

💡 Show Solution

Step 1: Make the prediction ŷ = -2 + 0.8(0) = -2

This predicts -$2 in sales, which is IMPOSSIBLE!

Step 2: Identify the problem This is EXTRAPOLATION - predicting outside the data range.

Issues:

  1. Temperature of 0°F likely outside original data range
  2. Linear relationship may not hold at extremes
  3. Model gives nonsensical result (negative sales)
  4. Y-intercept is just a mathematical constant, not meaningful here

Step 3: Proper approach Should only use regression for INTERPOLATION (within data range). If data collected at 60-100°F, only predict in that range.

Answer: NO - This is inappropriate extrapolation resulting in an impossible prediction. Only use regression within the range of observed x-values.

Explain using:

⚠️ Common Mistakes: Least-Squares Regression

Avoid these 3 frequent errors

📌 Related Topics in Unit 2: Exploring Two-Variable Data

❓ Frequently Asked Questions

What is Least-Squares Regression?▾
Find and interpret the least-squares regression line (LSRL) and make predictions.
How can I study Least-Squares Regression effectively?▾
Start by reading the study notes and working through the examples on this page. Then use the flashcards to test your recall. Practice with the 5 problems provided, checking solutions as you go. Regular review and active practice are key to retention.
Is this Least-Squares Regression study guide free?▾
Yes — all study notes, flashcards, and practice problems for Least-Squares Regression on Study Mondo are free to access. No account is needed.
What course covers Least-Squares Regression?▾
Least-Squares Regression is part of the AP Statistics course on Study Mondo, specifically in the Unit 2: Exploring Two-Variable Data section. You can explore the full course for more related topics and practice resources.
Are there practice problems for Least-Squares Regression?▾
Yes, this page includes 5 practice problems with detailed solutions. Each problem includes a step-by-step explanation to help you understand the approach.