Least Squares Regression Line Formula

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

The Formula

y^=a+bxwhereb=rβ‹…sysx,a=yΛ‰βˆ’bxΛ‰\hat{y} = a + bx \quad\text{where}\quad b = r \cdot \frac{s_y}{s_x}, \quad a = \bar{y} - b\bar{x}

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 (xx) and test scores (yy) for 5 students. The LSRL might be: y^=52+4.8x\hat{y} = 52 + 4.8x Interpretation: each additional hour of study is associated with a 4.84.8-point increase in the predicted test score. A student who studies 0 hours is predicted to score 5252.

Notation

y^\hat{y} is the predicted value. bb is the slope. aa is the y-intercept. rr is the correlation coefficient. sx,sys_x, s_y are the standard deviations of xx and yy.

What This Formula Means

The unique straight line y^=a+bx\hat{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\hat{y} = a + bx where b=rβ‹…sysxb = r \cdot \frac{s_y}{s_x} and a=yΛ‰βˆ’bxΛ‰a = \bar{y} - b\bar{x}; equivalently, b=βˆ‘(xiβˆ’xΛ‰)(yiβˆ’yΛ‰)βˆ‘(xiβˆ’xΛ‰)2b = \frac{\sum(x_i - \bar{x})(y_i - \bar{y})}{\sum(x_i - \bar{x})^2}

Worked Examples

Example 1

medium
Find the least-squares regression line for: (x,y)(x,y): (1,2),(2,4),(3,5),(4,4),(5,5)(1,2), (2,4), (3,5), (4,4), (5,5). Use b=rsysxb = r \frac{s_y}{s_x} and a=yΛ‰βˆ’bxΛ‰a = \bar{y} - b\bar{x}.

Answer

y^=2.2+0.60x\hat{y} = 2.2 + 0.60x

First step

1
xΛ‰=3\bar{x} = 3, yΛ‰=4\bar{y} = 4; sx=2.5β‰ˆ1.58s_x = \sqrt{2.5} \approx 1.58; sy=1.5β‰ˆ1.22s_y = \sqrt{1.5} \approx 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 (yy, kg) from height (xx, cm) is y^=βˆ’100+0.8x\hat{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\bar{x}=4, yˉ=20\bar{y}=20, r=0.8r=0.8, sx=2s_x=2, sy=5s_y=5, find the LSRL.

Common Mistakes

  • Minimizing perpendicular or horizontal distances - LSRL minimizes squared VERTICAL distances (yy residuals) only.
  • Confusing the slope bb with the correlation rr - they relate by b=rsysxb=r\frac{s_y}{s_x}; bb has units, rr does not.
  • Extrapolating far outside the data's xx-range - the line is only trustworthy across the observed xx values.

Why This Formula Matters

The LSRL turns a vague scatter cloud into a usable prediction rule and a single interpretable slope (how much yy changes per unit xx). It's the foundation for residuals, r2r^2, 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 rr 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\hat{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^\hat{y} is the predicted value. bb is the slope. aa is the y-intercept. rr is the correlation coefficient. sx,sys_x, s_y are the standard deviations of xx and yy.

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 yy changes per unit xx). It's the foundation for residuals, r2r^2, 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 rr 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.