KS Maths
Topic 4.10 · AA Standard Level

The regression line of x on y

There are two regression lines.

They cross at the mean point, they are not the same line, and using the wrong one is a mark.

This video lesson is a free sample. The plans open the rest of the lessons in this course, each with a figure to move and questions that check your answer as you type. See the plans.
Words you need (10 key words in this lesson)

The maths words this lesson uses, in plain English. Open this before you start if English is not your first language.

regression
A method for finding the best straight line through data.The regression line predicts y from x.
gradient
How steep a line is. Up divided by across.A line going up 2 for each 1 across has gradient 2.
mean
The total of all values divided by how many values there are.The mean of 2, 4, 6 is 4.
predict
Say what you think will happen using the data.Predict the score for 5 hours of study.
estimate
Find an answer that is close, but not exact.Estimate 19 times 21 as 20 times 20.
correlation
How strongly two sets of data are linked.Hours of study and test scores show positive correlation.
height
How tall something is, measured straight up.The height of the box is 5 cm.
square
Multiply a number by itself. Also, a shape with four equal sides and four right angles.5 squared is 25.
rearrange
Change a formula so a different letter is alone on one side.Rearrange y = 2x plus 1 to make x the subject.
sample
A small group chosen from a bigger group.We asked a sample of 50 students.

Warm-up

Four quick ones from earlier work. Try each on paper before you open the answer.

  1. Make x the subject of y = 3x − 2.
    Answer

    x = (y + 2)/3. Add 2 first, then divide everything by 3. The slip is x = y/3 + 2, which divides only one term.

  2. Find the mean of 2, 4, 9, 11 and 14.
    Answer

    (2 + 4 + 9 + 11 + 14) ÷ 5 = 40 ÷ 5 = 8. The mean point of a data set is built from two means like this.

  3. A line has equation y = 0.5x + 7. Find y when x = 4.
    Answer

    y = 0.5(4) + 7 = 2 + 7 = 9. Substitute for x, then work out the multiplication before the addition.

  4. A correlation coefficient is r = −0.8. Work out r².
    Answer

    r² = (−0.8)² = 0.64. Squaring a negative number gives a positive one; r² is never negative.

Words used in this lesson
regression line
the straight line that best fits the points, used to make predictions. For example: “the regression line of y on x”.
y on x
the line used to predict y from a known x; y is on the left of the “on”. For example: to estimate a mark from hours of study, use the mark on hours line.
least squares
the method that makes the squared gaps between points and line as small as possible. For example: the line of least squares is the best fit in this sense.
gradient
how steeply the line rises: the change in y for one step in x. For example: a gradient of 2 means y rises by 2 for each 1 in x.
mean point
the point (mean of x, mean of y); every regression line passes through it. For example: for x values 2, 4, 6 the mean of x is 4.
predict
use the line to work out an expected value. For example: predict the time for a runner who trains 7 hours.
interpolate
predict inside the range of your data, which is reasonable. For example: data run from 2 to 10 and you predict at 6.
extrapolate
predict outside the range of your data, which is unreliable. For example: data run from 2 to 10 and you predict at 25.
correlation coefficient
r, a number from −1 to 1 saying how close the points are to a line. For example: r close to 1 means points nearly on a rising line.
estimate
give an approximate value from a model. For example: “estimate the weekly hours” asks for a prediction, not an exact value.

Predict first. Before you sweep: for each value of y the page shows two predicted values of x, one from the correct line and one from rearranging the other. Do you think there is a value of y where the two predictions are the same? Say where, and why, before you look.

Then check

Now sweep y across its whole range and watch the “apart” readout. Where is it smallest, and what happens as you move away from that place? Which feature of the picture explains it?

The same eight points, with both least squares lines drawn. Slide the value of y you want to predict x from, and watch the two answers separate.

y = 17
8.70x on y · correct
10.13rearranging y on x
1.43apart

Both lines are correct. They answer different questions.

Which line answers which question

y on x minimises the vertical distances. Use it to predict y from a known x.

x on y minimises the horizontal distances. Use it to predict x from a known y. It is a different line because it is minimising different gaps.

y on x: y = 1.40x + 2.77 x on y: x = 0.492y + 0.338 r= 0.831, so r² = 0.691 predict x at y = 17→ 0.492(17) + 0.338 = 8.70 rearranging y on x→ (17 − 2.77) / 1.40 = 10.1  wrong line

The fact that explains the whole thing

Multiply the two gradients together and you get r². Here 1.405 × 0.4917 = 0.691 = r². So when r = ±1 the product is 1, the lines are inverses of each other, and they coincide. The weaker the correlation, the wider they open. The gap between the two lines is a picture of how much r is missing.

Both lines pass through (x̅, y̅). So at the mean they agree exactly, and the disagreement grows the further out you go. That is the same reason extrapolation is unsafe, arriving from a different direction.

On the GDC: both regression lines

The machine will give you either line, and choosing the wrong one is the examinable mistake.

When you may use it. Analysis. Paper 1 is non-calculator; Papers 2 and 3 allow one. So this is the Paper 2 route and the by-hand method is the one that has to be secure.

TI-Nspire CX II

  1. For y on x: menu → Statistics → Stat Calculations → Linear Regression (mx+b)
  2. For x on y: run the SAME command with the lists swapped
  3. Read m, b and r each time

Casio fx-CG50

  1. F2 CALC → F3 REG → F1 X with x in List 1
  2. Swap the lists and run it again for x on y
  3. The r is the same both times, which is the clue they are related

The mark people lose. Swapping the lists is not the same as rearranging the line. Rearranging y on x minimises the wrong distances and gives a different, wrong prediction. The two gradients multiply to r², which is the quickest check you did it properly.

A second example, finished by you

Both regression lines pass through the mean point, so two lines are enough to find it. The first steps are written out with a reason each; the last one is yours.

A set of data has y on x line y = 1.5x + 3 and x on y line x = 0.4y + 0.4. Find the mean point, and check that r² is a sensible value.

  1. Both lines pass through (x̅, y̅), so (x̅, y̅) satisfies both equations at once.A point on two lines is where they cross: solve the two equations simultaneously.
  2. Substitute y = 1.5x + 3 into the second line: x = 0.4(1.5x + 3) + 0.4 = 0.6x + 1.2 + 0.4 = 0.6x + 1.6Replace y with the first line, expand the bracket, and collect the constants.
  3. Collect the x terms: x − 0.6x = 1.6, so 0.4x = 1.6Get every x on one side so that you can divide.
  4. Solve 0.4x = 1.6 for x, then use y = 1.5x + 3 to find y. Finally multiply the two gradients, 1.5 and 0.4: is it between 0 and 1, as r² must be?Your step. Write it out in full before you type the answer below.

Your answer. Type the x-coordinate of the mean point.

Check before you go on

One question that tells you whether the main idea has landed. Each wrong option is a different common slip, so the reply tells you which one you made.

For a data set r = 0.6 and the line of y on x has gradient 0.9. The line of x on y is written x = my + c. What is m?

For a data set r = 0.6 and the line of y on x has gradient 0.9. The line of x on y is written x = my + c. What is m?

Where it decides something

A club coach has records of x, weekly training hours, and y, the 10 km time in minutes, for its runners. The mean point is (6, 52.5). The y on x line is y = −2.2x + 65.7 and the x on y line is x = −0.3y + 21.75. A new runner finished a 10 km race in 45 minutes. The coach wants to estimate the weekly training hours of such a runner. Choosing the right line is the whole question.

Estimate the weekly training hours (x) of a runner with a 10 km time of 45 minutes. Give your answer to 2 decimal places.

Your turn

1. A different data set has mean point (4.2, 13.6). Its x on y line is x = 0.35y + c. Find the value of c.

2. For another data set the y on x line has gradient 1.96 and the x on y line has gradient 0.25. Find the correlation coefficient r.

3. A question gives you a height and asks for the predicted arm span. You should use:

Where the marks go

Choosing the line by what you are predicting, not by what the question mentions first. The thing you want is on the left of the "on".

Not rearranging one line to do the other's job. It is the commonest error here and it produces a plausible, wrong number.

Saying when a prediction is unreliable: weak r, or a value well outside the data.

Something to think about

What happens to the two regression lines if r = 0, so there is no linear correlation at all? Use the fact that the two gradients multiply to give r² to decide what each line must look like, and then say how the two lines meet.

One way to think about it

Put r = 0 into the product of the gradients. What must at least one gradient be? Then think about each line separately: if the y on x line has no tilt at all, what does it predict for y at every x? And what must the x on y line do? Sketch the mean point and both lines.

Climb to an exam question

Four steps, each one a little harder than the last, on one pair of regression lines: y = 3.2x + 12 and x = 0.2y + 1.2. Every step is a piece of the exam question at the end. Use your calculator as you would in the exam.

Step 1 of 4: choose the right line. A sample gives the regression line of y on x as y = 3.2x + 12 and the regression line of x on y as x = 0.2y + 1.2. Estimate x when y = 50, to 2 decimal places.

Step 2 of 4: find the mean point. Both lines pass through the mean point. For the same two lines, y = 3.2x + 12 and x = 0.2y + 1.2, find the x-coordinate of the mean point, to 2 decimal places.

Step 3 of 4: the correlation coefficient. The two gradients are 3.2 (y on x) and 0.2 (x on y), and both are positive. Which statement gives the value of r?

The two gradients are 3.2 (y on x) and 0.2 (x on y), and both are positive. Which statement gives the value of r?

Step 4 of 4: how far to trust it. The y values in the sample ran from 20 to 80, and r = 0.8. The line of x on y is used to estimate x when y = 95. Which statement is best?

The y values in the sample ran from 20 to 80, and r = 0.8. The line of x on y is used to estimate x when y = 95. Which statement is best?

The exam question

Written for this site in the style of the real papers. Do it on paper first, as you would in the exam, and show your working: most of the marks are for method. Give answers to 3 significant figures unless the question says otherwise. Then check each part below.

Paper 2 style · calculator (GDC) allowed · 13 marks · about 14 minutes

A researcher records x, the hours of sunlight per day, and y, the height in cm after six weeks, for a sample of seedlings. The regression line of y on x is y = 4.4x + 4 and the regression line of x on y is x = 0.16y + 0.84.

(a) Find the mean height of the seedlings in the sample. [3]

(b) Find the value of r, the correlation coefficient. Give your answer correct to three significant figures. [3]

(c) A seedling has height 32 cm. Estimate the hours of sunlight per day it received. Give your answer correct to three significant figures. [3]

(d) Interpret the value 0.16 in the equation of the regression line of x on y, in the context of the question. [2]

(e) The heights of the seedlings in the sample ranged from 14 cm to 38 cm. Comment on the reliability of your estimate in part (c). [2]

Check (a). Type the mean value of y.

Check (b). Type r, correct to 3 decimal places.

Check (c). Type the estimate, to 2 decimal places.

Check your working for (d)

Say what changes and by how much, using the quantities named in the stem, and say that this is what the line estimates on average for the sample, not an exact rule for every seedling.

Check your working for (e)

Use two pieces of evidence: how strong the linear correlation is, from your value of r, and whether a height of 32 cm lies inside the heights that were measured. Then give a conclusion about the estimate.

Want the rest of this topic?

This is a free sample lesson. The IB Diploma plan opens every other Diploma lesson, AA and AI, SL and HL, and every lesson from Year 7 for the refreshers. It covers every child in the family and includes all seven revision packs.

$99 for 12 months, or $149 for 2 years

One plan opens every Diploma lesson, AA and AI, SL and HL, for the whole family.

That is $8.25 a month for the whole family.

Student without a card? in one tap.

One payment. Nothing renews. Full refund within 30 days. Prices are in US$; Gumroad shows your local currency at checkout. Already paid? Type the email you paid with in the sign-in box, then click the link we send. See every price, including $19 revision packs.

Teaching this lesson?

Every lesson here has a teacher page beside it: worked answers, what each common wrong answer tells you about a student's thinking, and questions at three levels for the board. Every unit has a free sample lesson for students, and a plan opens every other lesson.

See the teacher pages