Resources For Teachers For Tutors For Students & Parents Pricing
Year 12 Maths Standard 2 (2027) Bivariate data analysis

Least-Squares Regression Line

20 practice questions 0 video lessons Theory + worked examples

Master the least-squares regression line for NSW Year 12 Mathematics Standard 2. This is the calculated line of best fit \(y=a+bx\): you enter bivariate data into a scientific calculator, read off the gradient \(b\) and \(y\)-intercept \(a\), and write the equation of the line.

You will learn to interpret the gradient as a rate of change and the \(y\)-intercept as the value when \(x=0\), both in the context of the data, and to use the line to make predictions — a core bivariate-data skill for the Standard 2 course and the HSC.

Create a free accountTrack your progress and save your work as you go.
Create free account

Theory

The least-squares regression line is the calculated line of best fit \(y=a+bx\) for bivariate data. This Year 12 Standard 2 (NSW) guide shows how to find \(a\) and \(b\) with a calculator, interpret the gradient and \(y\)-intercept in context, and use the line to make predictions.

The least-squares regression line is the calculated line of best fit for a set of bivariate data. It is the one straight line that makes the total of the squared vertical distances from the data points to the line as small as possible.

In NSW Year 12 Mathematics Standard 2 its equation is written \(y = a + bx\), where \(b\) is the gradient and \(a\) is the \(y\)-intercept. You find \(a\) and \(b\) using the linear-regression mode of a scientific calculator, then interpret them in the context of the data.

The gradient \(b\) tells you how much the predicted \(y\) changes for each \(1\)-unit increase in \(x\); the intercept \(a\) is the predicted \(y\) when \(x=0\). Substituting an \(x\)-value into \(y=a+bx\) gives a prediction.

Least-squares line with a positive gradientA scatter of five points with the least-squares regression line y = 3 + 2x rising through them x y 1 2 3 4 5 4 8 12 16
Positive gradient: the least-squares line \(y=3+2x\) rises through the points.
Least-squares line with a negative gradientA scatter of five points with the least-squares regression line y = 20 - 3x falling through them x y 1 2 3 4 5 6 12 18 24
Negative gradient: \(y=20-3x\) falls, so \(y\) decreases as \(x\) increases.

NESA writes the least-squares regression line in intercept–gradient form:

\[y = a + bx\]
y=a+bx

The calculator finds the coefficients from the summary statistics (\(\bar{x},\bar{y}\) are the means):

\[b = \dfrac{S_{xy}}{S_{xx}}, \qquad a = \bar{y} - b\,\bar{x}\]
b=SxySxx
Reading it in context. \(b\) is a rate (change in \(y\) per \(1\)-unit increase in \(x\)); \(a\) is the predicted \(y\) when \(x=0\). A negative \(b\) means \(y\) falls as \(x\) rises.

Finding and using the least-squares line

  1. Enter the data. Put the \(x\)-values and \(y\)-values into your calculator's statistics / linear-regression (\(a+bx\)) mode.
  2. Read off \(a\) and \(b\). Write the equation \(y = a + bx\), keeping the full calculator values.
  3. Interpret. \(b\) is the change in \(y\) per \(1\)-unit increase in \(x\); \(a\) is the predicted \(y\) when \(x=0\). Give units and the sign.
  4. Predict. Substitute an \(x\)-value into \(y=a+bx\) to estimate \(y\).
Example 1 — Find the equation
A courier records the distance \(x\) (km) and delivery time \(y\) (min) for five parcels. Find the equation of the least-squares regression line.
Solution

Enter the data in linear-regression (\(a+bx\)) mode and read off \(a\) and \(b\).

Example 1 scatterDelivery time against distance with the least-squares line y = 8 + 6x x y 1 2 3 4 5 10 20 30 40
\(\bar{x}\)\(=\)\(3,\ \ \bar{y}=26\)
\(b\)\(=\)\(\dfrac{S_{xy}}{S_{xx}}=\dfrac{60}{10}=6\)
\(a\)\(=\)\(\bar{y}-b\bar{x}=26-6(3)=8\)
\(\therefore\ y\)\(=\)\(8+6x\)
y=8+6x
Example 2 — Interpret and predict
For five plumbing jobs, hours worked \(x\) and total charge \(y\) (\(\$\)) give the least-squares line \(y=90+60x\). Interpret \(a\) and \(b\), then predict the charge for a \(3.5\)-hour job.
Solution

\(a\) is the value at \(x=0\); \(b\) is the rate per hour. Then substitute \(x=3.5\).

Example 2 scatterTotal charge against hours with the least-squares line y = 90 + 60x x y 1 2 3 4 5 100 200 300 400
\(a\)\(=\)\(90\ \text{(call-out fee at } x=0)\)
\(b\)\(=\)\(60\ \text{(\$60 per hour)}\)
\(y\)\(=\)\(90+60(3.5)\)
\(y\)\(=\)\(300\)
y=300

The predicted charge for a \(3.5\)-hour job is \(\$300\).

Example 3 — A negative gradient
An alpine café records the daily maximum temperature \(x\) (°C) and the number of hot chocolates \(y\) sold. Find the line and interpret its gradient.
Solution

Fit the line; a negative \(b\) means \(y\) falls as \(x\) rises.

Example 3 scatterHot chocolates sold against temperature with the least-squares line y = 52 - 4x x y 1 2 3 4 5 10 20 30 40 50
\(\bar{x}\)\(=\)\(3,\ \ \bar{y}=40\)
\(b\)\(=\)\(\dfrac{-40}{10}=-4\)
\(a\)\(=\)\(40-(-4)(3)=52\)
\(\therefore\ y\)\(=\)\(52-4x\)

The gradient \(-4\) means each extra \(1\,°\text{C}\) is linked to about 4 fewer hot chocolates sold.

Example 4 — Use the line
A shop's weekly advertising spend \(x\) (\(\$1000\)s) and sales \(y\) (\(\$1000\)s) give \(y=20+8x\). Predict sales when \(\$2500\) is spent on advertising.
Solution

Spending \(\$2500\) means \(x=2.5\); substitute into the line.

Example 4 scatterSales against advertising spend with the least-squares line y = 20 + 8x x y 1 2 3 4 5 20 40 60
\(y\)\(=\)\(20+8x\)
\(y\)\(=\)\(20+8(2.5)\)
\(y\)\(=\)\(20+20\)
\(y\)\(=\)\(40\)
y=40

Predicted sales are \(40\) thousand dollars, i.e. \(\$40\,000\).

Common pitfalls

Do not swap \(a\) and \(b\). NESA writes \(y=a+bx\), so \(a\) is the intercept and \(b\) is the gradient. Some calculators list them the other way — match them to the right letter.
The gradient is a rate. It is the change in \(y\) for each \(1\)-unit rise in \(x\), not a total. Always give its units and its sign.
Round only at the end. Keep the full calculator values of \(a\) and \(b\) while you work, and round the final answer to a sensible accuracy.

Frequently asked questions

How do I find the least-squares regression line on my calculator?

Go into the statistics or linear-regression (a+bx) mode, enter the x-values in one list and the y-values in the other, then read off the values of a and b. Write the line as y = a + bx.

What is the difference between a and b in y = a + bx?

b is the gradient of the line: the change in the predicted y for each 1-unit increase in x. a is the y-intercept: the predicted value of y when x equals 0. In NESA's form the intercept a is written first.

Is the least-squares line the same as the line of best fit by eye?

They both summarise the trend, but the least-squares line is calculated, not drawn by eye. It is the single line that minimises the total of the squared vertical distances from the points, so everyone who enters the same data gets exactly the same equation.

How do I interpret the gradient in context?

Read b as a rate with units. For example, if x is hours and y is dollars, a gradient of 60 means the charge rises by $60 for each extra hour. A negative gradient means y decreases as x increases.

How do I use the line to make a prediction?

Substitute the x-value you are interested in into y = a + bx and work out y. For example, with y = 20 + 8x, spending x = 2.5 gives y = 20 + 8(2.5) = 40.

Why is it called the least-squares line?

Because it is chosen to make the sum of the squared vertical gaps between the data points and the line as small as possible. Squaring the gaps stops positive and negative errors cancelling and gives one unique best-fitting line.