Resources For Teachers For Tutors For Students & Parents AI New Pricing
Year 10 Maths - 10A Statistics

Linear Regression Using Technology

20 practice questions 2 video lessons Theory + worked examples
Practice 20 questions
Practice questions

Every question with a fully worked solution.

Start practising
Watch 2 video(s)
  • Linear Regression Using Technology - Video - Line of Best Fit using Technology Watch
  • Linear Regression Using Technology - Video - Line of Best Fit (2 of 2) Sharp Calculator Watch
Create a free accountTrack your progress and save your work as you go.
Create free account

Theory

Linear regression finds the least-squares line of best fit with a calculator, spreadsheet or graphing software. This Year 10A maths page shows how to enter the data, write the equation with the right variables, interpret the gradient and intercept, choose the regression equation from options, compare it with a line through two points, and judge interpolation and extrapolation. It builds on lines of best fit drawn by eye.

A line of best fit is a straight line drawn through a scatter plot with a linear association so that the points are spread evenly either side of it. It need not pass through any data point.

The mean point \((\bar{x}, \bar{y})\) is a good point to draw the line through.

In \(y = mx + c\), the gradient \(m\) is the average change in \(y\) for each increase of \(1\) in \(x\); the intercept \(c\) is the predicted \(y\) when \(x = 0\) (which may or may not make sense).

A prediction inside the range of the data is interpolation; outside it is extrapolation, which is less reliable because the trend may change. The least-squares line is the line of best fit a calculator finds; it always passes through the mean point.

Linear regression is the name for finding this line with a digital tool: a scientific or graphics calculator, a spreadsheet, or graphing software. The tool does the arithmetic; your job is to enter the data correctly, write the equation with the right variables, and judge whether the predictions make sense.

Line of best fit by eye through the mean pointEight points rising from left to right with a straight line drawn through their mean point. The points are balanced, with about half above the line and half below. x y mean point
Draw the line so the points are balanced either side of it, following the trend. A good line passes through (or very near) the mean point \((\bar{x}, \bar{y})\).
Interpolation and extrapolationA number line for x. The shaded section between the smallest x-value in the data, 10, and the largest, 45, is where predictions are interpolation. Beyond either end, predictions are extrapolation and are less reliable. 0102030405060 interpolation (inside the data) extra- polation extra- polation less reliable smallest x largest x
Predictions inside the range of the data are interpolation. Predictions outside it are extrapolation: the pattern may not continue.
\[m = \dfrac{y_2 - y_1}{x_2 - x_1}\]
\[y - y_1 = m(x - x_1)\]
\[(\bar{x}, \bar{y}) = \left(\dfrac{\sum x}{n},\ \dfrac{\sum y}{n}\right)\]
y−y1=m(x−x1)
Reading the line from a graph. Choose two points on the line (not data points) that are far apart and easy to read, often where it crosses grid lines. Use the line's own variable names, e.g. \(T = 3d + 12\), not \(y = 3x + 12\).
Working backwards. To find \(x\) for a given \(y\), substitute \(y\) and solve. If a budget is involved, first turn the money into the quantity (e.g. \(\$36\,000\) at \(\$450\) per unit is \(80\) units), then solve. A change in \(y\) of \(k\) goes with a change in \(x\) of \(\dfrac{k}{m}\).
Reading a model. In \(C = 0.08k + 1.5\), where \(C\) is the cost in dollars of a trip of \(k\) km, the gradient \(0.08\) means the cost rises by \(\$0.08\) for each extra kilometre, which is \(\$8\) per \(100\) km, and \(1.5\) is a fixed cost of \(\$1.50\). A rate per \(100\) units is \(100\) times the gradient.
Which line is better? A line through two chosen data points (for example the first and the last) depends on only those two points. The least-squares line uses every point, so it is usually the better model. When two lines give almost the same prediction, say so, and still prefer the line that uses all the data.

Drawing and using a line of best fit

  1. Check the scatter plot shows a linear association (a curve needs a different model).
  2. Find the mean point and mark it.
  3. Draw a straight line through the mean point following the trend, with about as many points above as below.
  4. Equation: read two points on the line (or use the mean point and the intercept), find \(m\), then \(c\).
  5. Interpret \(m\) and \(c\) in words, with units.
  6. Predict: substitute \(x\) to find \(y\), or substitute \(y\) and solve for \(x\). Say whether it is interpolation or extrapolation.

With a calculator

  1. Statistics mode, linear regression. Enter the pairs and read \(m\) (or \(a\) or \(b\), depending on the model) and \(c\).
  2. Spreadsheet: put \(x\) and \(y\) in two columns, insert a scatter chart and add a linear trendline with its equation shown, or use =SLOPE(y-cells, x-cells) and =INTERCEPT(y-cells, x-cells). Graphing software works the same way with a linear regression command.
  3. Choosing from options: if you must pick the equation that best fits, first check the sign of the gradient (rising or falling points) and roughly where the line meets the \(y\)-axis, then check one data point.
  4. Round only for the final equation; predictions from the unrounded values are slightly more accurate.
  5. For years, it is often easier to let \(x\) be the number of years after the first year.
Example 1 β€” Least-squares line on a calculator
Six students recorded their daily typing practice and their typing speed.
Practice per day, \(x\) (min)Typing speed, \(y\) (words/min)
\(2\)\(15\)
\(4\)\(19\)
\(6\)\(26\)
\(8\)\(28\)
\(10\)\(35\)
\(12\)\(38\)

(i) Use a calculator to find the least-squares line of best fit, with values correct to \(2\) decimal places.
(ii) Predict the speed for \(7\) minutes of practice.
(iii) Comment on a prediction for \(20\) minutes.
Solution

(i) Statistics mode, linear regression (\(y = ax + b\) or \(y = mx + c\)). Enter \(x\) and \(y\) as pairs.

\(m\)\(=\)\(2.357\ldots \approx 2.36\)
\(c\)\(=\)\(10.333\ldots \approx 10.33\)
\(y\)\(=\)\(\boldsymbol{2.36x + 10.33}\)

(ii)

\(y\)\(=\)\(2.36(7) + 10.33\)
\(\)\(=\)\(26.85 \approx \boldsymbol{26.9}~\text{words/min}\)

(The unrounded line gives \(26.8\); small differences like this come from rounding \(m\) and \(c\).)

(iii) \(x = 20\) is outside the data (\(2\) to \(12\) minutes): extrapolation. The line gives about \(57.5\) words/min, but speed is unlikely to keep rising at the same rate, so treat it with caution.

y=2.36x+10.33
Example 2 β€” A spreadsheet trendline
A courier enters the mass, \(m\) kg, and the cost, \(C\) dollars, of \(10\) parcels from \(1\) kg to \(25\) kg in a spreadsheet. The linear trendline is \(y = 1.35x + 6.2\), and =SLOPE gives \(1.35\) and =INTERCEPT gives \(6.2\).
(i) Write the model with the variables \(C\) and \(m\), and explain the gradient and the intercept. What is the cost for each extra \(10\) kg?
(ii) Predict the cost of a \(12\) kg parcel.
(iii) What is the heaviest parcel that can be sent for \(\$33.20\)?
(iv) Should the model be used for a \(60\) kg parcel?
Solution

(i) The spreadsheet uses \(x\) and \(y\); write the model with the real variables.

\(C\)\(=\)\(\boldsymbol{1.35m + 6.2}\)

Gradient: the cost rises by about \(\$1.35\) for each extra kilogram, so about \(10 \times 1.35 = \boldsymbol{\$13.50}\) for each extra \(10\) kg. Intercept: a fixed charge of about \(\$6.20\) on every parcel.

\(\text{(ii) } C\)\(=\)\(1.35(12) + 6.2 = \boldsymbol{\$22.40}\)
\(\text{(iii) } 1.35m + 6.2\)\(=\)\(33.2\)
\(1.35m\)\(=\)\(27\)
\(m\)\(=\)\(\boldsymbol{20}~\text{kg}\)

\(20\) kg is inside the data (\(1\) to \(25\) kg), so this is interpolation.

(iv) No. \(60\) kg is far outside the data, so the model's \(\$87.20\) is an extrapolation; heavy parcels may be priced differently.

Example 3 β€” Choosing the regression equation
The table shows the water in a rainwater tank, \(y\) kilolitres, \(x\) weeks into a dry spell.
Week, \(x\)Water, \(y\) (kL)
\(1\)\(28.5\)
\(2\)\(26.4\)
\(3\)\(23.8\)
\(4\)\(21.5\)
\(5\)\(19.1\)
\(6\)\(16.4\)
\(7\)\(14.4\)
\(8\)\(11.8\)
Which equation is the least-squares line of best fit?
(A) \(y = 2.4x + 31\)
(B) \(y = -2.4x + 31\)
(C) \(y = -2.4x - 31\)
(D) \(y = -0.4x + 31\)
Solution

Direction. The water falls as the weeks go by, so the gradient is negative. That rules out (A).

Intercept. At \(x = 0\) the tank held about \(31\) kL, not \(-31\). That rules out (C).

Gradient. The water drops about \(\dfrac{11.8 - 28.5}{8 - 1} \approx -2.4\) kL a week, not \(-0.4\). Check one point, \(x = 4\):

\(\text{(B)}\)\(:\)\(-2.4(4) + 31 = 21.4 \quad (\text{data } 21.5)\)
\(\text{(D)}\)\(:\)\(-0.4(4) + 31 = 29.4\)

The answer is (B) \(y = -2.4x + 31\). A calculator gives \(m = -2.398\ldots\) and \(c = 31.03\ldots\), which round to these values.

Example 4 β€” Two points or least squares?
Seven apprentices recorded their weeks of training, \(x\), and their errors per shift, \(y\).
Weeks, \(x\)Errors, \(y\)
\(1\)\(22\)
\(2\)\(20\)
\(3\)\(19\)
\(5\)\(14\)
\(6\)\(13\)
\(8\)\(10\)
\(9\)\(6\)
(i) Find the equation of the line through the first and last points.
(ii) Find the least-squares line, with values correct to \(2\) decimal places.
(iii) Use each line to predict the errors after \(7\) weeks.
(iv) Which line is the better model? Use the mean point.
Solution
\(\text{(i) } m\)\(=\)\(\dfrac{6 - 22}{9 - 1} = -2\)
\(y\)\(=\)\(\boldsymbol{-2x + 24}\)

(ii) Statistics mode, linear regression: \(m = -1.898\ldots\), \(c = 24.078\ldots\).

\(y\)\(=\)\(\boldsymbol{-1.90x + 24.08}\)
\(\text{(iii) two points}\)\(:\)\(-2(7) + 24 = \mathbf{10}\)
\(\text{least squares}\)\(:\)\(-1.90(7) + 24.08 \approx \mathbf{10.8}\)

(iv) The mean point is \(\left(\dfrac{34}{7}, \dfrac{104}{7}\right) \approx (4.86, 14.86)\). The least-squares line passes through it; the two-point line gives \(14.29\) there, which is too low. The least-squares line uses all seven points, so it is the better model. The two-point line depends on the first and last apprentices only.

Common pitfalls

Put the variables the right way round. Enter the explanatory variable as \(x\) and the one you want to predict as \(y\). Swapping them gives a different line.
Match the letters. If the calculator shows \(y = a + bx\), then \(b\) is the gradient; if it shows \(y = ax + b\), then \(a\) is. Write the final equation with the variables from the question.
Round at the end. Use the unrounded values for predictions if you can; rounding the gradient early can change the last digit of an answer.
Look at the scatter plot first. Regression always produces a line. If the points curve or form separate groups, the line can be badly misleading.
Extrapolation can be nonsense. A model built from \(1\) to \(25\) kg parcels says nothing reliable about a \(60\) kg parcel. Say why a prediction outside the data may fail.
Association is not cause. A regression line describes a trend; it does not show that \(x\) causes \(y\).

Frequently asked questions

How do you find a line of best fit on a calculator?

Use statistics mode with linear regression. Enter each pair of values, then read the gradient and the intercept. Check which letter is which, because some calculators use y = a + bx and others y = ax + b.

How do you find a line of best fit in a spreadsheet?

Put the x-values and y-values in two columns and make a scatter chart. Add a linear trendline and show its equation, or use =SLOPE(y-cells, x-cells) and =INTERCEPT(y-cells, x-cells).

What is the least-squares line of best fit?

It is the line a calculator or spreadsheet finds using linear regression. It fits the points as closely as possible overall and always passes through the mean point.

Why is the least-squares line better than a line through two points?

A line through two chosen points depends only on those two points, and one of them may be unusual. The least-squares line uses every point, so it usually gives better predictions.

Does linear regression work for any data?

A calculator will always give a line, even for curved data or data in separate groups. Look at the scatter plot first: use a straight line only when the points follow a straight-line pattern.