ASCENTLEARNING
Join a weekly class
Skip to learning content
YEAR 12 · STATISTICS AND REGRESSION · 18 MIN

Least-squares regression

Fit a prediction line, then check its meaning against the data.

In this lesson

Before you start
  • Calculate means.
  • Read a scatter plot.
  • Substitute into a straight-line equation.
01 / LEARN

Understand the method.

THE CORE RULE
y^=a+b⁢x,a=y¯−bx¯

The line predicts y from x and passes through the point of sample means (x¯,y¯).

Measure vertical prediction errors

A residual is the observed response minus the predicted response at the same x. It is a vertical difference on the scatter plot.

Least squares chooses the slope and intercept that minimise the sum of squared residuals. Squaring prevents positive and negative errors cancelling.

e=y−y^

Calculate slope first, then intercept

Use centred sums, or correlation and standard deviations, to find the slope. Then substitute the two sample means to find the intercept.

Keep unrounded coefficients for calculations. Round the final prediction to a precision that suits the measurements.

b=Sx⁢ySx⁢x=rsysxa=y¯−bx¯

Check what the model can predict

Name the response, the explanatory variable and their units. Record the observed x-range before making predictions.

Inspect the scatter plot: a calculated line is not automatically a sensible model. Curvature, clusters or influential outliers may need attention.

02 / WORKED EXAMPLES

See the method in action.

EXAMPLE 01

Calculate a fitted line

Fit y on x to the supplied table.

Five sage points (1,3), (2,4), (3,4), (4,6), (5,8) appear with the gold least-squares line y-hat equals 1.4 plus 1.2x, drawn from x one to five. The original labelled values and unlabelled outer padding are retained.
Paired measurements
xy
13
24
34
46
58

Worked solution

  1. 1

    Calculate the sample means.

    x¯=3,y¯=5

    Use all five paired rows from the supplied table.

  2. 2

    Calculate the centred sums and slope.

    Sx⁢x=4+1+0+1+4=10Sx⁢y=4+1+0+1+6=12b=1210=1.2

    Multiply matching deviations for Sx⁢y; square the x-deviations for Sx⁢x.

  3. 3

    Find the intercept and state the model.

    a=5−1.2⁢(3)=1.4y^=1.4+1.2⁢x

    At x=3, the predicted response is 5, so the line passes through the point of means.

Answer

y^=1.4+1.2⁢x. The observed input range is 1≤x≤5.

EXAMPLE 02

Fit from summary statistics

For x¯=10, y¯=25, sx=4, sy=6 and r=0.8, find the regression line.

Worked solution

  1. 1

    Use correlation and the two standard deviations.

    b=0.8×64=1.2

    The response standard deviation goes in the numerator because the model predicts y from x.

  2. 2

    Substitute the means to find the intercept.

    a=25−1.2⁢(10)=13

    A fitted line with an intercept passes through (10,25).

  3. 3

    Write the prediction equation.

    y^=13+1.2⁢x

    The hat distinguishes a predicted response from an observed one.

Answer

y^=13+1.2⁢x.

03 / YOUR TURN

Try it yourself.

Calculate, explain, then apply.

CHECK 01

Use the point of means

Given x¯=4, y¯=9 and slope b=2, find the intercept.

Show answer & reasoning

a=1.

Use a=9−2⁢(4)=1.

Keep practising

6 worksheet questions · 18 marks

Read the questions online
  1. Find the line from x¯=6,y¯=20,Sx⁢x=10 and Sx⁢y=25.
    3 marks
  2. Given r=−0.6,sx=5,sy=10,x¯=8 and y¯=30, find the regression line.
    3 marks
  3. A candidate line has residuals −2,1,1. Calculate its sum of squared residuals.
    3 marks
  4. Two models have residuals A=(−3,0,3) and B=(−2,1,1). Which has the smaller least-squares error?
    3 marks
  5. A regression line has a=7 and b=0.5. Predict y at x=12.
    3 marks
  6. A student rounds b=0.08473 to 0.1 before predicting at x=900. Explain the risk.
    3 marks
Read the worked solutions

Equivalent correct methods earn the corresponding marks. Include units where asked.

  1. Find the line from x¯=6,y¯=20,Sx⁢x=10 and Sx⁢y=25.
    3 marks

    b=2510=2.5.

    a=20−2.5×6=5.

    y^=5+2.5⁢x.
  2. Given r=−0.6,sx=5,sy=10,x¯=8 and y¯=30, find the regression line.
    3 marks

    b=−0.6×105=−1.2.

    a=30−(−1.2×8)=39.6.

    y^=39.6−1.2⁢x.
  3. A candidate line has residuals −2,1,1. Calculate its sum of squared residuals.
    3 marks

    Square each residual: 4,1,1.

    Add the squares, not their signed values.

    6.
  4. Two models have residuals A=(−3,0,3) and B=(−2,1,1). Which has the smaller least-squares error?
    3 marks

    A has squared sum 9+0+9=18.

    B has 4+1+1=6, so B is better on this criterion.

    B.
  5. A regression line has a=7 and b=0.5. Predict y at x=12.
    3 marks

    Substitute x=12 into y^=7+0.5⁢x.

    7+6=13.

    13.
  6. A student rounds b=0.08473 to 0.1 before predicting at x=900. Explain the risk.
    3 marks

    A small coefficient rounding can become large after multiplication by x.

    Keep guard digits until the final prediction.

    The slope contribution changes from 76.257 to 90, an error of 13.743.
Checking saved progress…
Curriculum reference & lesson scope

SACE Board of South Australia

Stage 2 General Mathematics: statistical models. Original lessons and assessment practice; not an official SACE assessment.

Official curriculum source ↗

Save your next step.

Create a free account to save your learning progress. Lessons and downloads stay free, with or without an account.

Create free account