Skip to main content

Least-squares regression (SACE Stage 2 General Mathematics)

Syllabus dot point

“Determine and interpret the least-squares regression line, use it to make predictions, and assess fit using residuals.”

8 min read

Quick answer

The least-squares regression line is the straight line y=a+bxy = a + bx that minimises the sum of the squared vertical gaps (residuals) between the data and the line. You interpret the slope and intercept in context, then substitute to predict.

Jump to a section
  1. What this dot point is asking
  2. The least-squares line
  3. Prediction, interpolation and extrapolation
  4. Using residuals to assess fit
  5. What "least squares" actually minimises
  6. Choosing a non-linear model
  7. Linking back to correlation
  8. Exam-style questions

What this dot point is asking

You must find the regression line (usually with a calculator), interpret its slope and intercept, use it to predict, and judge its fit using residuals.

The least-squares line

The least-squares line is written y=a+bxy = a + bx, where bb is the slope and aa is the vertical intercept. It is the unique line that makes the total of the squared vertical distances from the points to the line as small as possible.

Residual

A residual is the vertical gap between an observed data point and the value the line predicts: residual=yactual−ypredicted\text{residual} = y_{\text{actual}} - y_{\text{predicted}}. The least-squares line minimises the sum of the squared residuals.

In practice you read aa and bb from a calculator, but you must interpret both:

  • The slope bb is the predicted change in yy for each one-unit increase in xx.
  • The intercept aa is the predicted value of yy when x=0x = 0.
Worked example

A regression of weekly sales yy (thousands of dollars) against advertising spend xx (hundreds of dollars) gives y=5.2+1.8xy = 5.2 + 1.8x. Interpret the slope and intercept in context, then predict weekly sales when x=6x = 6.

Step 1: Interpret the slope in context

The slope b=1.8b = 1.8 is the predicted change in yy for each one-unit increase in xx. Because xx is measured in hundreds of dollars and yy in thousands of dollars, a one-unit rise in xx represents an extra $100\$100 of advertising. So the slope tells us that each additional $100\$100 spent on advertising is associated with a predicted rise of $1800\$1800 in weekly sales.

Step 2: Interpret the intercept in context

The intercept a=5.2a = 5.2 is the predicted value of yy when x=0x = 0, that is, when nothing is spent on advertising. This predicts weekly sales of $5200\$5200 with zero advertising spend. In practice this figure may reflect sales from loyal customers or other channels, though it should be used cautiously if x=0x = 0 is outside the range of the data.

Step 3: Substitute to make the prediction

To predict sales when x=6x = 6 (that is, $600\$600 of advertising), substitute x=6x = 6 into the regression equation. The multiplication comes first, then the addition:

y=5.2+1.8(6)=5.2+10.8=16.0.y = 5.2 + 1.8(6) = 5.2 + 10.8 = 16.0.

Final answer: Predicted weekly sales are $16 000\$16\,000 when $600\$600 is spent on advertising.

Prediction, interpolation and extrapolation

Substituting an xx-value inside the range of the data is interpolation, which is usually reliable. Substituting beyond the data range is extrapolation, which is risky because the linear pattern may not continue.

Interpolation versus extrapolation

Predicting within the range of the collected data is interpolation and is generally trustworthy. Predicting outside that range is extrapolation; treat it with caution because there is no evidence the relationship holds there.

Using residuals to assess fit

After fitting the line, residuals tell you how good the fit is. A residual plot graphs each residual against xx.

  • If the residuals are scattered randomly above and below zero with no pattern, a linear model is appropriate.
  • If the residual plot shows a clear curve or pattern, the relationship is not really linear and a straight line is the wrong model.
Worked example

Using the regression line y=5.2+1.8xy = 5.2 + 1.8x, suppose that at x=4x = 4 the actual recorded sales were $13 500\$13\,500, that is yactual=13.5y_{\text{actual}} = 13.5 (thousands). Find the residual at this point and explain what it means.

Step 1: Find the predicted value from the regression line

The residual compares what the line predicts against what actually happened. We first calculate what the line says sales should be at x=4x = 4 by substituting into the equation:

ypredicted=5.2+1.8(4)=5.2+7.2=12.4.y_{\text{predicted}} = 5.2 + 1.8(4) = 5.2 + 7.2 = 12.4.

So the model predicts weekly sales of $12 400\$12\,400 when $400\$400 is spent on advertising.

Step 2: Compute the residual

The residual is defined as the actual value minus the predicted value. Taking the actual minus the predicted preserves the sign: a positive residual means the model underestimated, and a negative residual means it overestimated.

residual=yactual−ypredicted=13.5−12.4=1.1.\text{residual} = y_{\text{actual}} - y_{\text{predicted}} = 13.5 - 12.4 = 1.1.

Step 3: Interpret the sign and size of the residual

The residual of 1.11.1 (thousands of dollars) is positive, which means the actual sales of $13 500\$13\,500 were $1100\$1100 above the value the line predicted. The model underestimated sales at this point. A positive residual places the data point above the regression line on a scatterplot.

Final answer: The residual is 1.11.1 (that is, $1100\$1100), indicating actual sales were $1100\$1100 higher than the line's prediction.

What "least squares" actually minimises

The line is called "least squares" because, among all possible straight lines, it makes the sum of the squared residuals as small as possible. Squaring the residuals serves two purposes: it stops positive and negative gaps from cancelling, and it penalises large misses more heavily than small ones, so the line is pulled toward the bulk of the data. The line always passes through the mean point (xˉ,yˉ)(\bar{x}, \bar{y}), which is a useful checkpoint and explains why a single far-off outlier can swing the line noticeably - it drags the squared-distance total up until the line tilts toward it.

Choosing a non-linear model

When a residual plot shows a clear curved pattern, the straight-line model is wrong even if its r2r^2 looks high. SACE often compares a linear fit with an exponential one for growth data such as subscriber numbers or populations. The better model is the one whose residual plot is patternless and whose r2r^2 is closer to 11. Citing both pieces of evidence - the residual pattern and the r2r^2 value - is what a full-mark justification requires; relying on r2r^2 alone is not enough, because a curved relationship can still produce a deceptively high r2r^2.

Linking back to correlation

The coefficient of determination r2r^2 from the correlation work tells you the proportion of variation in yy explained by the line. A high r2r^2 together with a patternless residual plot means the linear model is a strong fit.

Round only at the end

Keep full calculator accuracy for aa and bb while predicting, and round the final answer to a sensible number of figures. Rounding the coefficients early can throw a prediction off by a noticeable amount.

Common mistake

Do not swap the explanatory and response variables; the regression of yy on xx is different from the regression of xx on yy. Also do not trust a far extrapolation, and do not call a fit "good" from r2r^2 alone; always check the residual plot for a leftover pattern.

Exam-style questions

Questions in the style of SACE Board exam questions on this dot point, each with a worked answer. They are written by ExamExplained unless tagged "Past paper"; the year shows the paper a question is modelled on.

SACE 2022-style2 marks
Calculator-assumed. The area of Arctic sea ice (SS million km squared) is recorded against the year of observation (DD) from 1980 to 2020. State the equation of the least-squares regression line using the context variables.
Show worked answer →

Enter the (D,S)(D, S) pairs into a calculator's linear regression. With DD explanatory and SS response, the calculator gives approximately slope −0.0872-0.0872 and intercept 178178.

So S=−0.0872D+178S = -0.0872D + 178 (small rounding differences accepted). (1 mark for slope and intercept, 1 mark for using the context variables SS and DD rather than xx and yy.)

The negative slope reflects the steady decline in sea-ice area over time.

SACE 2023-style2 marks
Calculator-assumed. Using the least-squares line N=2.01t+79.5N = 2.01t + 79.5 for the number of potoroos NN after tt months, predict when the population reaches 300, and comment on the reliability.
Show worked answer →

Substitute N=300N = 300: 300=2.01t+79.5300 = 2.01t + 79.5, so 220.5=2.01t220.5 = 2.01t and t=220.52.01≈109.7t = \dfrac{220.5}{2.01} \approx 109.7 months. (1 mark)

So about 110 months. This is an extrapolation well beyond the 60-month data range, so it should be treated with caution. (1 mark)

SACE 2021-style2 marks
Calculator-assumed. A regression of weekly sales yy (thousands of dollars) on advertising spend xx (hundreds of dollars) gives y=5.2+1.8xy = 5.2 + 1.8x. At x=4x = 4 the actual sales were 13.5 (thousand dollars). Find the predicted value and the residual.
Show worked answer →

Predicted value: y=5.2+1.8(4)=12.4y = 5.2 + 1.8(4) = 12.4 (thousand dollars). [1 mark]

Residual =yactual−ypredicted=13.5−12.4=1.1= y_{\text{actual}} - y_{\text{predicted}} = 13.5 - 12.4 = 1.1 (thousand dollars), so the actual sales were 1100 dollars above the line. [1 mark]

A positive residual means the model underestimated this point.

Practise this

Sources & how we know this

ExamExplained