Least Squares Regression Line Formula

Least squares regression line is the unique straight line ŷ = a + bx that minimizes the sum of squared vertical distances (residuals) between the observed data points and the line.

The Formula

y^=a+bxwhereb=r⋅sysx,a=yˉ−bxˉ

When to use: You have a scatter plot with points scattered around a general trend. The LSRL is the line that gets as close as possible to all the points simultaneously—it's the 'best' straight line through the cloud. 'Best' means it minimizes the total squared prediction error.

Quick Example

Study hours (x) and test scores (y) for 5 students. The LSRL might be: y^=52+4.8x Interpretation: each additional hour of study is associated with a 4.8-point increase in the predicted test score. A student who studies 0 hours is predicted to score 52.

Notation

y^ is the predicted value. b is the slope. a is the y-intercept. r is the correlation coefficient. sx,sy are the standard deviations of x and y.

What This Formula Means

The unique straight line y^=a+bx that minimizes the sum of squared vertical distances (residuals) between the observed data points and the line.

You have a scatter plot with points scattered around a general trend. The LSRL is the line that gets as close as possible to all the points simultaneously—it's the 'best' straight line through the cloud. 'Best' means it minimizes the total squared prediction error.

Formal View

y^=a+bx where b=r⋅sysx and a=yˉ−bxˉ; equivalently, b=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2

Worked Examples

Example 1

medium
Find the least-squares regression line for: (x,y): (1,2),(2,4),(3,5),(4,4),(5,5). Use b=rsysx and a=yˉ−bxˉ.

Answer

y^=2.2+0.60x

First step

1
xˉ=3, yˉ=4; sx=2.5≈1.58; sy=1.5≈1.22

See the full worked solution + why-it-works coaching

SetupKey insightWhy it worksCommon pitfallConnection

Unlock answer keys One Family plan — every worked solution, all subjects

Example 2

hard
The LSRL for predicting weight (y, kg) from height (x, cm) is y^=−100+0.8x. Interpret the slope and intercept, predict weight for height=175 cm, and explain why extrapolating to height=50 cm is problematic.

Example 3

medium
Given xˉ=4, yˉ=20, r=0.8, sx=2, sy=5, find the LSRL.

Common Mistakes

  • Minimizing perpendicular or horizontal distances - LSRL minimizes squared VERTICAL distances (y residuals) only.
  • Confusing the slope b with the correlation r - they relate by b=rsysx; b has units, r does not.
  • Extrapolating far outside the data's x-range - the line is only trustworthy across the observed x values.

Why This Formula Matters

The LSRL turns a vague scatter cloud into a usable prediction rule and a single interpretable slope (how much y changes per unit x). It's the foundation for residuals, r2, and regression inference, so a wrong sign or a slope read as a raw correlation derails everything built on top. Recognizing it by "Am I fitting a single straight line to two-variable numeric data by minimizing squared vertical distances?" — rather than by familiar numbers — is what lets a student tell it apart from correlation r and slope (algebra) and residuals in a mixed problem set.

Frequently Asked Questions

What is the Least Squares Regression Line formula?

The unique straight line y^=a+bx that minimizes the sum of squared vertical distances (residuals) between the observed data points and the line.

How do you use the Least Squares Regression Line formula?

You have a scatter plot with points scattered around a general trend. The LSRL is the line that gets as close as possible to all the points simultaneously—it's the 'best' straight line through the cloud. 'Best' means it minimizes the total squared prediction error.

What do the symbols mean in the Least Squares Regression Line formula?

y^ is the predicted value. b is the slope. a is the y-intercept. r is the correlation coefficient. sx,sy are the standard deviations of x and y.

Why is the Least Squares Regression Line formula important in Math?

The LSRL turns a vague scatter cloud into a usable prediction rule and a single interpretable slope (how much y changes per unit x). It's the foundation for residuals, r2, and regression inference, so a wrong sign or a slope read as a raw correlation derails everything built on top. Recognizing it by "Am I fitting a single straight line to two-variable numeric data by minimizing squared vertical distances?" — rather than by familiar numbers — is what lets a student tell it apart from correlation r and slope (algebra) and residuals in a mixed problem set.

What do students get wrong about Least Squares Regression Line?

The procedure for least squares regression line is the easy part; the trap is minimizing perpendicular or horizontal distances. Asking "Am I fitting a single straight line to two-variable numeric data by minimizing squared vertical distances?" first is what keeps a correct-looking calculation from being attached to the wrong concept.

What should I learn before the Least Squares Regression Line formula?

Before studying the Least Squares Regression Line formula, you should understand: correlation, scatter plot, mean, standard deviation.