All subjects · Mathematics · WST01 (S1)

The least squares regression line

The regression line of y on x is the straight line that best fits the data in the sense of least squares. It lets you predict y from x.

Least squares

For each point, the residual is the vertical distance from the point to the line (observed y minus predicted y). The least squares line makes the sum of the squared residuals as small as possible. It always passes through the mean point (x̄, ȳ).

Finding the line

The regression line of y on x is y = a + bx, with

b = Sxy / Sxx and a = ȳ - b x̄.

With Sxx = 82.5, Sxy = 200, x̄ = 5.5, ȳ = 42: b = 200/82.5 = 2.4242, a = 42 - 2.4242 × 5.5 = 28.667.

So y = 28.7 + 2.42x (to 3 s.f.). Keep full accuracy for b when you work out a.

Interpreting a and b

The line of y on x is for predicting y from x; it should not be rearranged to predict x from y.

Worked example

Find the regression line of y on x for n = 10, Σx = 55, Σy = 420, Sxx = 82.5, Sxy = 200.

  1. b = 200/82.5 = 2.4242...
  2. x̄ = 5.5, ȳ = 42
  3. a = 42 - 2.4242... × 5.5 = 28.666...

Answer: y = 28.7 + 2.42x

Key idea: b = Sxy/Sxx, a = ȳ - bx̄; the line passes through (x̄, ȳ); interpret b as the rate of change in context.

Check yourself

  1. Sxx = 82.5 and Sxy = 200. Find the gradient b of the regression line of y on x. Give your answer to 3 significant figures.
    Show answer

    2.42. b = 200/82.5 = 2.42.

  2. Sxx = 82.5, Sxy = 200, x̄ = 5.5, ȳ = 42. Find a in y = a + bx. Give your answer to 3 significant figures.
    Show answer

    28.7. a = 42 - (200/82.5)(5.5) = 28.7.

  3. Sxx = 40, Sxy = -48. Find b.
    Show answer

    -1.2. b = -48/40 = -1.2.

  4. The regression line of y on x has gradient b = -1.2, and x̄ = 15, ȳ = 30. Find a.
    Show answer

    48. a = 30 - (-1.2)(15) = 30 + 18 = 48.

  5. The regression line is y = 28.67 + 2.424x. Predict y when x = 7. Give your answer to 3 significant figures.
    Show answer

    45.6. 28.67 + 2.424 × 7 = 45.64.

  6. Which point does every least squares regression line of y on x pass through?
    • (0, 0)
    • (x̄, ȳ)
    • (0, b)
    • The point with the largest residual
    Show answer

    (x̄, ȳ). Since a = ȳ - bx̄, substituting x = x̄ gives y = ȳ.

  7. What does the least squares method minimise?
    • The sum of the horizontal distances from the points to the line
    • The number of points not on the line
    • The gradient of the line
    • The sum of the squares of the vertical distances from the points to the line
    Show answer

    The sum of the squares of the vertical distances from the points to the line. Residuals are vertical (in y) and are squared before adding.

Practise with instant feedback

Sources

Last updated 7 November 2026. Spotted a mistake? Tell us.