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ˉ

Ask yourself: Am I fitting a single straight line to two-variable numeric data by minimizing squared vertical distances?

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.

Imagine each data point attached to a stiff rod by a vertical spring whose pull grows with its stretch. Let go, and the rod settles where all the pulls balance: close to most points, tugged hardest by the farthest. That resting position is the least-squares line. Like any rod, it stays straight, so it can't follow a curved pattern.

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ˉ.
Show solution

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

Free: full solutions on 3 topics a day. No card.

Every topic, every day: the Family plan

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

A scatter plot shows a trend; the LSRL turns it into a usable rule, such as "each extra hour of study goes with 4.8 more points." Its slope gives the rate of change in real units, and the equation gives predictions for new cases. Used carelessly, it extrapolates far beyond the data or is forced onto a curved pattern, and then its predictions are confidently wrong.

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?

Use the LSRL when you have paired numeric data, a scatter plot with a roughly linear trend, and a need to predict y from x or state a rate of change. Check the scatter plot first: if the pattern curves, a straight line is the wrong model. If you need only the strength of the relationship, report r or r2. If two points lie exactly on a line with no scatter, the ordinary two-point slope is enough.

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?

A scatter plot shows a trend; the LSRL turns it into a usable rule, such as "each extra hour of study goes with 4.8 more points." Its slope gives the rate of change in real units, and the equation gives predictions for new cases. Used carelessly, it extrapolates far beyond the data or is forced onto a curved pattern, and then its predictions are confidently wrong.

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.