Least-squares regression and prediction (QCE General Mathematics Unit 3)
“Fit a least-squares line y = mx + c to bivariate numerical data using technology and using m = r(s_y / s_x) and c = y-bar - m x-bar, interpret the slope and y-intercept in context, distinguish between interpolation and extrapolation, use the line to make predictions, and recognise and explain the potential dangers of extrapolation”
The least-squares line minimises the sum of the squared residuals. Find it with the calculator's regression mode, or from and ; it passes through . The slope is the predicted change in for each one-unit increase in ; the intercept is the predicted at and is often meaningless. Predictions inside the data range (interpolation) are generally reliable; predictions outside it (extrapolation) can be badly wrong and must always be flagged.
What this dot point is asking
Once a scatterplot shows a linear association between two numerical variables, you model it with a straight line and use the line to predict. The QCAA General Mathematics 2025 syllabus (Unit 3, Topic 2, Bivariate data analysis 2, "Fitting a linear model to numerical data") asks you to
- fit a least-squares line using technology (your calculator's statistics mode),
- understand and use and to find the line from summary statistics,
- interpret the slope and -intercept in context,
- distinguish between interpolation and extrapolation,
- use the line to make predictions, and
- recognise and explain the dangers of extrapolation.
Residual plots, the other part of this sub-topic, have their own page, and so does association and causation. In the external assessment you have a scientific calculator, which can run a linear regression from raw data in its statistics mode.
The answer
Explanatory and response variables
The explanatory variable (, horizontal axis) is the one you think explains or predicts the other; the response variable (, vertical axis) is the one being predicted. Hours of training explains run time, temperature explains ice-cream sales, age explains height. Getting this the right way round matters: regressing on gives a different line from regressing on .
The least-squares line
For any line drawn through a scatterplot, each point has a residual: the vertical distance from the point to the line, (observed minus predicted). The least-squares line is the one line that makes the sum of the squared residuals as small as possible. In QCAA notation it is written
where is the slope (gradient) and is the -intercept. Always write it with the variable names in context, for example .
Using the calculator
Put the calculator into its statistics (two-variable or linear regression) mode, enter the values in one column and the matching values in the other, and read off the regression coefficients. Two cautions:
- Many scientific calculators write the line as or , so the letter called or is the intercept and or is the slope. Check which is which before you copy them into .
- The same screen gives . Write it down: you need it to judge how good the model is.
Round the coefficients sensibly (usually to 3 or 4 significant figures) and keep more precision in any follow-up calculation.
From summary statistics
When you are given the means, standard deviations and instead of the raw data, use
where is the correlation coefficient, and are the (sample) standard deviations of the and values, and and are the means. Three facts follow from these formulas:
- The slope has the same sign as (standard deviations are positive).
- The line always passes through the mean point , because rearranging gives .
- A weaker correlation gives a flatter line for the same spreads: the slope is "shrunk" by the factor .
Interpreting the slope and intercept
Use a template and put the context in:
- Slope. "For each increase of 1 [unit of ] in [ variable], the [ variable] is predicted to increase (or decrease) by [ units of ]."
- -intercept. "When [ variable] is 0, the predicted [ variable] is [ units]." Then judge it: if is far outside the data or is impossible in context, say the intercept has no practical meaning.
Words like "predicted", "on average" or "is associated with" matter: the line describes a trend, not a law, and it does not prove that causes .
Making predictions
Substitute the value into the equation. For the run-time model , 7 hours of training gives minutes.
Interpolation and extrapolation
- Interpolation is predicting for an value within the range of the data. It is generally reliable, especially when the association is strong.
- Extrapolation is predicting for an value outside the range of the data. It assumes the linear pattern continues where there is no data to support it.
The dangers of extrapolation
Extrapolation can go badly wrong because:
- The pattern may change. Relationships that look linear over a small range often curve, level off or reverse outside it. Training improves run times, but not without limit.
- The prediction can be impossible. The run-time line predicts a 5 km time of about 3.2 minutes at 45 hours of training a week, and a negative time beyond about 50 hours.
- Conditions change over time. Forecasting a future year from past trends (time-series extrapolation) assumes nothing about the situation changes.
Extrapolating a little beyond the data (for example one year ahead in a steady trend) is common and can be reasonable, but you must always label it as extrapolation and say it is less reliable.
How reliable is a prediction?
A prediction is more trustworthy when
- it is an interpolation,
- the association is strong ( close to , so is close to 1: a high proportion of the variation in is explained by ),
- the residual plot shows no pattern, so a straight line is an appropriate model, and
- the data set is reasonably large and contains no influential outliers.
Coding time
When is a year, code it as "years since" a starting year (for example for 2019). Using 2019 directly gives a huge negative intercept that is hard to interpret and easy to mis-key. State your coding in words; the marker needs it to follow your intercept and your forecast.
Least-squares line: , from the calculator's regression mode or from and . It passes through and its slope has the sign of . Slope: predicted change in per one-unit increase in . Intercept: predicted at (often meaningless). Interpolation (inside the data range) is generally reliable; extrapolation (outside it) is not.
1. Fitting a line with the calculator
Hours of training per week, : 2, 3, 5, 6, 8, 9, 11. Time for a 5 km run, (min): 31.8, 30.2, 30.0, 28.1, 27.9, 26.2, 25.8. Find the least-squares line and .
- Variables
- Training explains run time, so = hours of training, = time (min).
- Calculator
- Linear regression gives intercept , slope , .
- Answer
- , with : a strong, negative, linear association.
Marker's note: the calculator may show and . Here is the intercept, not the slope.
2. The same line from summary statistics
For the training data, , , , and . Verify the equation using the syllabus formulas.
- Slope
- .
- Intercept
- .
- Answer
- , the same line as Example 1.
Marker's note: use the unrounded slope when you calculate . With you would get .
3. Interpreting the slope and intercept
Interpret the slope and -intercept of .
Slope. For each extra hour of training per week, the predicted 5 km time decreases by about 0.655 minutes (about 39 seconds).
Intercept. A runner who does no training is predicted to take about 32.7 minutes. Zero hours is just outside the data (2 to 11 hours), so this is a small extrapolation; it is plausible, but it is not supported directly by the data.
4. Interpolation and extrapolation
Use the model to predict the run time for 7 hours and for 20 hours of training a week, and comment on each.
7 hours. min. Interpolation (7 lies within 2 to 11), and is strong, so this is reliable.
20 hours. min. Extrapolation (20 is well above 11). The improvement from training is unlikely to keep going at the same rate, so this prediction is unreliable.
5. Coding the year
Museum visitors (thousands) from 2019 to 2024: 12.4, 13.1, 14.3, 14.8, 16.0, 16.5. Forecast the visitors in 2026.
- Code
- for 2019, so 2024 is and 2026 is .
- Fit
- , .
- Forecast
- , about 18 300 visitors.
- Comment
- The trend is very strong, but 2026 is two years beyond the data, so this is extrapolation and should be treated as an estimate.
6. When the intercept is meaningless
A pool's weekly visitors, , are modelled by for maximum temperatures from 18 °C to 34 °C. Interpret the intercept and predict for .
Intercept. At 0 °C the model predicts visitors: impossible, and 0 °C is far outside the data, so the intercept has no practical meaning. It simply fixes the height of the line.
Prediction. : impossible again. Extrapolating below 18 °C breaks the model.
- Swapping the calculator's and
- On many calculators is the intercept and the slope. Check against the scatterplot: a falling pattern must have a negative slope.
- Interpreting without context
- "The slope is " earns little. Say what increases, by how much, and in what units.
- Treating the intercept as always meaningful
- If is outside the data or impossible, say so.
- Not labelling extrapolation
- Every prediction outside the data range must be called extrapolation, with a comment on reliability.
- Rounding before finding
- Use the full value of in .
- Using the wrong variable as
- The explanatory variable goes on the horizontal axis and into the calculator's column.
- Claiming causation
- A strong line shows association, not that causes .
For a regression question: (1) name the explanatory and response variables; (2) write the equation with variable names, coefficients to about 3 or 4 significant figures; (3) substitute and show the working for each prediction; (4) label each prediction interpolation or extrapolation and comment on reliability using (or ), the residual plot and the data range. For a "justify" or "evaluate" question, finish with a clear conclusion sentence.
If you plot points that roughly follow a straight line, the least-squares line is the "best" straight line through them: it is as close as possible to all the points at once. You can then use it to guess values you did not measure. Guessing in between the points you have (interpolation) usually works well. Guessing far beyond them (extrapolation) is risky, because the pattern might change, like assuming a child who grew 6 cm a year will be 3 metres tall by age 40.
Exam-style questions
Questions in the style of QCAA 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.
Practice3 marksThe table shows the number of sales for a small business in their first six months of trading. Time in months, t: 1, 2, 3, 4, 5, 6. Number of sales, n: 86, 180, 160, 226, 240, 335. a) Use your calculator to determine the equation of the least-squares line. [1 mark] b) Use the equation from part a) to predict the number of sales in the 21st month. [2 marks]Show worked answer →
a) Fit the line (1 mark). Enter as the explanatory variable and as the response variable in the calculator's two-variable statistics (linear regression) mode: .
b) Predict (2 marks). Substitute (1 mark): . The model predicts about 950 sales in the 21st month (1 mark).
This is extrapolation far beyond months 1 to 6, so the prediction is unreliable: a new business's early growth rarely continues in a straight line for almost two years.
Practice4 marksThe table shows the profit made each year (in thousands of dollars) by a small business. Year: 2015, 2016, 2017, 2018, 2019, 2020. Profit ($'000s): 42.1, 36.9, 48.4, 52.3, 56.1, 59.8. a) Use a mathematical model to determine the equation of the least-squares line to fit this data. [2 marks] b) Use the least-squares line to forecast the profit in 2021, to the nearest hundred dollars. [2 marks]Show worked answer →
a) Fit the line (2 marks). Define the variables (1 mark): let be the number of years since 2014 (so 2015 is ) and the annual profit in $'000s. Linear regression gives (1 mark).
b) Forecast (2 marks). For 2021, (1 mark): . The forecast profit is about $64 300 (1 mark).
The marks reward defining clearly (the choice of starting year fixes the intercept) and converting the $'000s answer back into dollars at the required rounding.
Practice4 marksThe least-squares line has been provided for a scatterplot showing the association between an employee's years of experience, n, and their hourly pay, p. a) Given that the least-squares line passes directly through the points (2, 20) and (7, 40), determine its equation. [2 marks] b) Use the equation from part a) to predict the hourly pay of an employee with 15 years experience. [2 marks]Show worked answer →
a) Equation (2 marks). Slope (1 mark): . Through : , so and (1 mark).
b) Predict (2 marks). (1 mark). An employee with 15 years of experience is predicted to earn about $72 per hour (1 mark).
If 15 years is beyond the plotted range this is extrapolation, so flag the prediction as less reliable. The slope means pay rises by about $4 per hour for each extra year of experience.
Original4 marksFor a group of Year 12 students, the weekly hours of part-time work, , and the exam score (%), , have , , , and . (a) Use and to determine the equation of the least-squares line. (b) Interpret the slope in context. (c) Predict the score of a student who works 12 hours a week.
Show worked answer →
(a) . (1 mark) . (1 mark) So .
(b) For each extra hour of part-time work per week, the predicted exam score falls by about 1.5 percentage points. (1 mark)
(c) , a predicted score of about 67%. (1 mark)
Keep full precision for when finding ; rounding to first gives . The association is only moderate (), so predictions are rough.
Original5 marksArm span, (cm), and height, (cm), were measured for eight people. Arm span: 152, 158, 163, 167, 171, 176, 181, 188. Height: 155, 160, 162, 170, 169, 178, 180, 186. (a) Use your calculator to determine the least-squares line and . (b) Predict the height of a person with an arm span of 165 cm, and comment on the reliability. (c) A basketballer has an arm span of 210 cm. Explain why the model's prediction for them should be treated with caution.
Show worked answer →
(a) Arm span is the explanatory variable. , . (2 marks)
(b) , so about 166 cm. (1 mark) This is interpolation (165 lies within 152 to 188) and the association is very strong (, ), so the prediction is reliable. (1 mark)
(c) 210 cm is well outside the data range (152 to 188 cm), so the prediction (about 206 cm) is extrapolation. There is no evidence the linear pattern continues for very tall people, and only eight people were measured. (1 mark)
Original4 marksA council models the number of weekly visitors to a pool, , against the maximum daily temperature, (°C), for temperatures from 18 °C to 34 °C: . (a) Interpret the slope. (b) Interpret the -intercept and explain whether it is meaningful. (c) Predict the visitors at 26 °C and at 10 °C, and comment on each.
Show worked answer →
(a) For each 1 °C increase in maximum temperature, the model predicts 42 more weekly visitors. (1 mark)
(b) At 0 °C the model predicts visitors. This is impossible and 0 °C is far outside the data (18 to 34 °C), so the intercept has no practical meaning. (1 mark)
(c) : visitors, an interpolation, so reasonably reliable. (1 mark) : , which is impossible; it is an extrapolation and shows the danger of using the line outside the data range. (1 mark)
Practice questions
Original practice questions graded from foundation to exam level, each with a full worked solution. Try them before revealing the solution.
foundation2 marksFor the line , where is the number of hours a shop is open on a day and is its daily sales in $'00s, interpret the slope and the -intercept.
Show worked solution →
Slope: each extra hour of opening is associated with a predicted increase of 2.4 hundred dollars ($240) in daily sales. (1 mark)
Intercept: at 0 hours of opening, predicted sales are $1500. This is not meaningful, since a closed shop makes no sales, and 0 hours is almost certainly outside the data. (1 mark)
foundation2 marks, , , and . Find the equation of the least-squares line.
Show worked solution →
. (1 mark)
, so . (1 mark)
foundation2 marksA least-squares line was fitted to data with from 5 to 40. Classify each prediction as interpolation or extrapolation: (a) (b) (c) (d) .
Show worked solution →
(a) interpolation, (b) extrapolation, (c) interpolation, (d) extrapolation. (2 marks, lose 1 for each error)
core3 marksHours of training per week, : 2, 3, 5, 6, 8, 9, 11. Time for a 5 km run, (min): 31.8, 30.2, 30.0, 28.1, 27.9, 26.2, 25.8. (a) Find the least-squares line. (b) Predict the time for 7 hours of training.
Show worked solution →
(a) From the calculator's linear regression: (2 marks; .)
(b) minutes. (1 mark) This is interpolation.
core3 marksThe least-squares line for a data set passes through and has slope . (a) Find its equation. (b) If and , find .
Show worked solution →
(a) , so . (1 mark)
(b) gives , so . (2 marks)
exam3 marksAnnual visitors (thousands) to a museum from 2019 to 2024 were 12.4, 13.1, 14.3, 14.8, 16.0, 16.5. Using for 2019, (a) find the least-squares line, (b) forecast the visitors in 2026, and (c) give one reason the forecast may be unreliable.
Show worked solution →
(a) (). (1 mark)
(b) 2026 is : , about 18 300 visitors. (1 mark)
(c) It is extrapolation beyond 2024, and the trend may not continue (a new exhibition, a closure or a change in tourism could change it). (1 mark)
exam3 marksA student says: "The line predicts that with 45 hours of training a week I could run 5 km in about 3.2 minutes, so more training always makes me faster." Evaluate this claim.
Show worked solution →
The calculation is right: . (1 mark)
But the data only covered 2 to 11 hours, so 45 hours is extreme extrapolation. A 3-minute 5 km is physically impossible, which shows the linear pattern cannot continue: improvements level off and too much training can cause injury. (1 mark)
Conclusion: the claim is not supported. The model is only useful for predictions within (or very close to) 2 to 11 hours a week. (1 mark)