Educerie

Educerie · IB Diploma · Mathematics: analysis and approaches

IB Mathematics AA 4.10 · SL and HL

Regression line of x on y

The regression line of yy on xx predicts yy, so what do you use when the value you know is yy and the value you want is xx, and when can you trust the answer?

What you will learn

  • Understand that the regression line of x on y minimises horizontal distances and is a different line from y on x.
  • Know that the line used has the wanted variable on its left, and that neither line is rearranged to give the other.
  • Know that both regression lines pass through the mean point.
  • Understand that a prediction is reliable only with strong correlation and a given value inside the data's range.

You must be able to

  1. Write down the equation of the regression line of x on y from a GDC, as x = cy + d.
  2. Calculate an estimate of x from a given value of y using the correct line.
  3. Explain why the y on x line should not be used to estimate x.
  4. Comment on the reliability of an estimate, naming extrapolation where it applies.
  5. Calculate the mean point by solving the two regression equations together.
  6. Interpret the gradient of the x on y line in context.

In the exam. Paper 2, as 3 to 6 marks at the end of a bivariate data question that began in 4.4: after rr and the yy on xx line, find the xx on yy line, use it to estimate xx, and say why the other line would be wrong or the estimate unreliable. Paper 1, without a calculator: both lines are given, and you solve them together for the mean point or choose the right line for a prediction (3 to 5 marks).

1Two jobs, two lines

  • In 4.4 the line of yy on xx came from least squares. Take each point's vertical distance to the line. This is the residual: how far the line misses when it predicts that yy.
    • Square each residual, so misses above and below cannot cancel, and add the squares. The chosen line has the smallest total.
  • Figure 1, left, shows those vertical misses for five points.
Figure 1 · Two lines, two ways of measuring the misses Regression line of y on x 0 1 2 3 4 5 6 x 0 1 2 3 4 5 6 7 y y = 0.83x + 1.77 Regression line of x on y 0 1 2 3 4 5 6 x 0 1 2 3 4 5 6 7 y x = 0.752y − 0.205 y on x makes the vertical misses small (it predicts y). x on y makes the horizontal misses small (it predicts x).
Figure 1 · Two lines, two ways of measuring the misses
  • Now reverse the task: you have a yy-value and need xx. Your error is how far left or right of the true xx you land: a horizontal distance.
    • Squaring and adding horizontal gaps gives a different winner, the line of xx on yy, on the right of Figure 1. For those five points it is x=0.752y−0.205x = 0.752y - 0.205. The yy on xx line is y=0.83x+1.77y = 0.83x + 1.77.
    • Rearranged, the first is y=1.33x+0.273y = 1.33x + 0.273 (3 s.f.), far steeper than y=0.83x+1.77y = 0.83x + 1.77. Same dots, two answers to two questions.

Reading the names

  • The variable before the word "on" is the one the line predicts. It sits alone on the left.
    • "yy on xx" is y=ax+by = ax + b.
    • "xx on yy" is x=cy+dx = cy + d.
  • Letters are only labels.
  • Example: with ss and tt, "the regression line of ss on tt" is s=ct+ds = ct + d. It predicts ss.

To estimate yy, use yy on xx. To estimate xx, use xx on yy. Never rearrange one line to get the other.

Which line fits the situation?

  • In IB questions the test is which value you are handed. The wanted variable goes on the left.
  • Some textbooks add a second reason, about measurement. Say yy is measured precisely (or set by the experimenter) and xx is a rough reading. Then nearly all the scatter is in xx and the misses that matter are horizontal. The xx on yy line describes the relationship better.
  • Example: a lifeguard judges wave heights by eye (xx) while a buoy logs the true height (yy). Asked why xx on yy is appropriate, name the precise variable.
    • This reason chooses the model. It does not change the prediction rule. An estimate of yy from a given xx still comes from the yy on xx line, as the guide's caution says.

2Finding the xx on yy line with technology

  • A GDC has one linear regression command. It always fits "second list == gradient ×\times first list ++ intercept".
  • For xx on yy, swap the roles: the yy-data is the first (independent) list and the xx-data the second.
    • TI-84 Plus: xx in L1, yy in L2; run LinReg(ax+b) with Xlist = L2 and Ylist = L1.
    • Casio: in the regression set-up, XList is the list holding the yy-data and YList the list holding the xx-data.
    • TI-Nspire: in the linear regression dialog, choose the yy-column as X List and the xx-column as Y List.
  • The screen still says "y=ax+by = ax + b". The calculator does not know you swapped anything. Read its aa as your cc and its bb as your dd.

Write the answer as x=cy+dx = cy + d. Copying the calculator's letters unchanged loses marks.

The value of rr is the same in either order, so it is a quick check that you typed the data correctly.

Worked example 1: trees. A forester records the trunk diameter xx (cm) at chest height and the height yy (m) of eight trees of one species.

Diameter xx (cm)1822273136404552
Height yy (m)13.011.817.514.220.116.422.821.0

With the lists in the usual order, as in 4.4:

r=0.835strong positive linear correlationr = 0.835 \qquad \textcolor{#838c91}{\text{strong positive linear correlation}}y on x:y=0.286x+7.41y \text{ on } x:\quad y = 0.286x + 7.41

With the lists swapped:

x on y:x=2.44y−7.82the calculator’s a is now c, its b is dx \text{ on } y:\quad x = 2.44y - 7.82 \qquad \textcolor{#838c91}{\text{the calculator's }a\text{ is now }c\text{, its }b\text{ is }d}

A drone measures a tree's height from above, not its trunk. The forester wants the diameter of a tree 19 m19\ \mathrm{m} tall. Height yy is known and diameter xx is wanted: a job for xx on yy.

x=2.4381×19−7.8165use the unrounded values stored in the GDC=38.5 cm (3 s.f.)\begin{aligned}x &= 2.4381 \times 19 - 7.8165 && \textcolor{#838c91}{\text{use the unrounded values stored in the GDC}} \\[6pt] &= 38.5\ \mathrm{cm}\ \text{(3 s.f.)}\end{aligned}

Figure 2 draws both lines through the data. Rearranging the yy on xx line instead, x=19−7.410.286x = \dfrac{19 - 7.41}{0.286}, gives 40.5 cm40.5\ \mathrm{cm}, the grey mark on the figure. That is two centimetres out, purely from using the wrong line.

Figure 2 · Eight trees, both regression lines 10 20 30 40 50 60 x, trunk diameter (cm) 8 10 12 14 16 18 20 22 24 26 y, height (m) 40.5: rearranged y on x (wrong) 38.5 mean point (33.9, 17.1) x on y: x = 2.44y − 7.82 y on x: y = 0.286x + 7.41 Both lines pass through the mean point. For a tree 19 m tall, the x on y line predicts 38.5 cm.
Figure 2 · Eight trees, both regression lines

For the height of a 30 cm30\ \mathrm{cm} tree, use yy on xx: y=0.28615×30+7.4068=16.0 my = 0.28615 \times 30 + 7.4068 = 16.0\ \mathrm{m}. Rearranging the xx on yy line instead would give 15.5 m15.5\ \mathrm{m}, again the wrong value.

Interpreting cc and dd

  • In x=2.44y−7.82x = 2.44y - 7.82, c=2.44c = 2.44 says each extra metre of height goes with a predicted 2.44 cm2.44\ \mathrm{cm} more diameter.
  • The intercept d=−7.82d = -7.82 would be the predicted diameter at height 00: impossible and far outside the data. As in 4.4, "the intercept has no sensible meaning here" is then a full interpretation.

3Choosing the line, finding it, using it

Exam questions bundle these skills. Here is a complete one.

Worked example 2: river depth. Volunteers at a stream read the water depth xx (cm) off a marker post by eye. An electronic meter logs the flow yy (litres per second) at the same moment. Eight readings:

Depth xx (cm)1218253138445260
Flow yy (L ÷ s)0.91.61.83.13.04.64.46.2

(a) Explain why the regression line of xx on yy is appropriate. The meter gives yy precisely, while the eyeballed depth xx is the rougher measurement. So the error is mostly in xx, and the line that minimises horizontal distances describes the relationship better.

(b) Find it. Enter the flow list first and the depth list second:

r=0.972the same for either order of listsr = 0.972 \qquad \textcolor{#838c91}{\text{the same for either order of lists}}x=9.07y+5.98coefficients to 3 s.f.; stored values 9.0701 and 5.9757x = 9.07y + 5.98 \qquad \textcolor{#838c91}{\text{coefficients to 3 s.f.; stored values 9.0701 and 5.9757}}

(c) Estimate the depth when the flow is 3.9 L/s3.9\ \mathrm{L/s}. The flow is known, so use this line: x=9.0701×3.9+5.9757=41.3 cmx = 9.0701 \times 3.9 + 5.9757 = 41.3\ \mathrm{cm}. The data's flows run from 0.90.9 to 6.26.2, so this is interpolation. With r=0.972r = 0.972 the estimate is reliable.

(d) Estimate the flow when the depth is 40 cm40\ \mathrm{cm}. Now the depth is known and the flow is wanted. Part (a) does not change the rule: an xx on yy line cannot always reliably predict yy.

Use yy on xx: y=0.10418 x−0.44628y = 0.10418\,x - 0.44628, which gives y=3.72 L/sy = 3.72\ \mathrm{L/s}.

Turning the line from (b) round would give 40−5.97579.0701=3.75 L/s\dfrac{40 - 5.9757}{9.0701} = 3.75\ \mathrm{L/s}. The gap is only 0.030.03 because rr is close to 11. With weaker correlation it grows. A small gap is no licence to rearrange.

(e) Comment on using the line from (b) at a flow of 8.5 L/s8.5\ \mathrm{L/s}. The prediction is 9.0701×8.5+5.9757=83.1 cm9.0701 \times 8.5 + 5.9757 = 83.1\ \mathrm{cm}.

A flow of 8.58.5 is above every flow in the data (the largest is 6.26.2). That is extrapolation, so the pattern may not continue and the estimate is unreliable.

(f) Interpret cc. Each extra 1 L/s1\ \mathrm{L/s} of flow goes with a predicted extra 9.07 cm9.07\ \mathrm{cm} of depth.

4Why rearranging gives the wrong answer

  • The lines disagree because correlation is not perfect.
    • Take the 19 m19\ \mathrm{m} tree in Worked example 1. It is 1.9 m1.9\ \mathrm{m} above the mean height of 17.1 m17.1\ \mathrm{m}. A rearranged yy on xx line treats every tree as sitting exactly on that line, as if height fixed diameter. It gives 40.5 cm40.5\ \mathrm{cm}.
    • But with r=0.835r = 0.835, height does not fix diameter: some tall trees are slim. A tall tree's best diameter estimate is above average, but by less. The xx on yy line pulls it back towards the mean diameter, to 38.5 cm38.5\ \mathrm{cm}.
  • Each line pulls its predictions towards the mean of the variable it predicts. That is why each is right only for its own variable.
  • Figure 3 shows the gap as the correlation changes. When rr is weak, the lines open like scissors, one almost flat, one almost upright. A prediction from the wrong one is wildly out.
    • As ∣r∣\lvert r\rvert grows the blades close. At r=±1r = \pm 1 all the points sit on a single line, so the two regression lines are the same line. That is the only case in which rearranging one gives the other.
Figure 3 · The stronger the correlation, the closer the two lines r = 0.28 x y r = 0.80 x r = 0.99 x Weak correlation, the lines open like scissors. As |r| approaches 1 they close into one line.
Figure 3 · The stronger the correlation, the closer the two lines

A check that is not on the syllabus

  • Write the lines with their own variable on the left: y=ax+by = ax + b and x=cy+dx = cy + d. The product of the gradients is then a×c=r2a \times c = r^{2}.
    • Trees: 0.28615×2.43810=0.6980.28615 \times 2.43810 = 0.698 and 0.8352=0.6980.835^{2} = 0.698.
    • Worked example 2: 0.10418×9.0701=0.945=0.97220.10418 \times 9.0701 = 0.945 = 0.972^{2}.
  • The gradients share a sign and their product cannot exceed 11. If yours do not, one is wrong.

5Both lines pass through the mean point

  • Every least squares regression line passes through the mean point (xˉ,yˉ)(\bar{x}, \bar{y}). Its coordinates are the mean of the xx-values and the mean of the yy-values.
    • Both lines pass through it, so they always cross there (the cross in Figure 2). A question can use this with no data at all.

Worked example 3 (no calculator). For some bivariate data, the line of yy on xx is y=0.8x+2y = 0.8x + 2 and the line of xx on yy is x=1.1y−1.3x = 1.1y - 1.3. Find xˉ\bar{x} and yˉ\bar{y}.

The mean point is on both lines, so solve them together. Figure 4 shows the crossing.

x=1.1(0.8x+2)−1.3put the first line’s y into the secondx = 1.1(0.8x + 2) - 1.3 \qquad \textcolor{#838c91}{\text{put the first line's }y\text{ into the second}}x=0.88x+2.2−1.3x = 0.88x + 2.2 - 1.30.12x=0.90.12x = 0.9x=7.5x = 7.5y=0.8(7.5)+2=8check in line 2: 1.1(8)−1.3=7.5 ✓y = 0.8(7.5) + 2 = 8 \qquad \textcolor{#838c91}{\text{check in line 2: }1.1(8) - 1.3 = 7.5\ \checkmark}

So xˉ=7.5\bar{x} = 7.5 and yˉ=8\bar{y} = 8.

Figure 4 · The lines cross at the mean point 0 2 4 6 8 10 12 14 x 0 2 4 6 8 10 12 14 y (7.5, 8) y on x: y = 0.8x + 2 x on y: x = 1.1y − 1.3 Solve the two equations together: x̄ = 7.5 and ȳ = 8.
Figure 4 · The lines cross at the mean point

One line and one mean

  • Suppose the line of xx on yy is x=0.9y−3x = 0.9y - 3 and yˉ=20\bar{y} = 20.
  • The mean point lies on the line, so xˉ=0.9×20−3=15\bar{x} = 0.9 \times 20 - 3 = 15. This works only for the mean. Any other yy gives a prediction, not xˉ\bar{x}.

Both lines, then a prediction

  • Paper 1 can print both equations and then ask for estimates. Picking the right line is the method mark.
  • Example: take y=0.4x+5y = 0.4x + 5 and x=1.5y−3.5x = 1.5y - 3.5.
    • The mean point is (10,9)(10, 9), since 0.4×10+5=90.4 \times 10 + 5 = 9 and 1.5×9−3.5=101.5 \times 9 - 3.5 = 10.
    • To estimate yy when x=15x = 15, use the first line and get 1111.
    • To estimate xx when y=7y = 7, use the second and get 77.

6When a prediction can be trusted

The correct line is necessary but not sufficient. Two checks from 4.4 carry over. Figure 5 shows the full decision.

Figure 5 · Choosing a line, then deciding whether to trust it What do you want to find? the unknown variable y from a given x: use y on x x from a given y: use x on y Is the prediction reliable? |r| strong (close to 1)? given value inside the data range? Both yes interpolation: a sensible estimate Either no weak r or extrapolation: unreliable Never rearrange one line to get the other. Pick the line by what you want to find. Then check strength and range before you believe the number.
Figure 5 · Choosing a line, then deciding whether to trust it
  1. How strong is the correlation? Weakly correlated data give poor predictions both ways. At r=0.835r = 0.835 the tree estimates are sensible. At r=0.3r = 0.3 they would be barely better than quoting the mean.
  2. Is the given value inside the data's range? An estimate between observed values is interpolation. It is fine when rr is strong. One beyond them is extrapolation, unreliable because nothing says the pattern continues.
  • With xx on yy, the range that matters is the range of the yy-values, because yy is what you substitute. The tree heights run from 11.8 m11.8\ \mathrm{m} to 22.8 m22.8\ \mathrm{m}. A 19 m19\ \mathrm{m} tree is interpolation.
    • A 30 m30\ \mathrm{m} tree is extrapolation. The line would claim 2.4381×30−7.8165=65.3 cm2.4381 \times 30 - 7.8165 = 65.3\ \mathrm{cm}, a figure with no data behind it.
    • Write: the value lies outside the range of the data used to find the line, so the pattern may not hold. Do not call it an "outlier". That word means a data point far from the rest of the data, which is a different idea.
  • The guide's caution (an xx on yy line cannot always reliably predict yy from xx) is 4.4's warning turned round.
  • Asked to justify your choice of line, write: "yy is known and xx is to be estimated, so the line of xx on yy is used; the yy on xx line minimises vertical distances, so it does not give the best estimate of xx."
  • A strong line is also not a cause. Height does not produce diameter; both grow as the tree ages.

Practice questions

36 questions on this note, from easy to hard. Each one you get right lights a star of this topic's constellation.