Least-Squares Regression Line
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.
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.
NESA writes the least-squares regression line in intercept–gradient form:
The calculator finds the coefficients from the summary statistics (\(\bar{x},\bar{y}\) are the means):
Finding and using the least-squares line
- Enter the data. Put the \(x\)-values and \(y\)-values into your calculator's statistics / linear-regression (\(a+bx\)) mode.
- Read off \(a\) and \(b\). Write the equation \(y = a + bx\), keeping the full calculator values.
- 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.
- Predict. Substitute an \(x\)-value into \(y=a+bx\) to estimate \(y\).
Enter the data in linear-regression (\(a+bx\)) mode and read off \(a\) and \(b\).
| \(\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\) |
\(a\) is the value at \(x=0\); \(b\) is the rate per hour. Then substitute \(x=3.5\).
| \(a\) | \(=\) | \(90\ \text{(call-out fee at } x=0)\) |
| \(b\) | \(=\) | \(60\ \text{(\$60 per hour)}\) |
| \(y\) | \(=\) | \(90+60(3.5)\) |
| \(y\) | \(=\) | \(300\) |
The predicted charge for a \(3.5\)-hour job is \(\$300\).
Fit the line; a negative \(b\) means \(y\) falls as \(x\) rises.
| \(\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.
Spending \(\$2500\) means \(x=2.5\); substitute into the line.
| \(y\) | \(=\) | \(20+8x\) |
| \(y\) | \(=\) | \(20+8(2.5)\) |
| \(y\) | \(=\) | \(20+20\) |
| \(y\) | \(=\) | \(40\) |
Predicted sales are \(40\) thousand dollars, i.e. \(\$40\,000\).
Common pitfalls
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.