Module 29 of 46Lesson 1 of 5 · Normal & regression 1 · The regression line of x on y
1
Regression x on y, standardisation & the normal distribution · Essential understanding 1

The regression line of x on y

IB AA SL 4.10with Prof. Kitso
💻 Using the TI-Nspire CX Student Software on a laptop
  • The screens in these notes are drawn exactly as the Student Software shows them. The keypad on the left of the software works like the handheld — click its keys with the mouse.
  • menu: click menu on the on-screen keypad (or Documents Toolbox ▸ 🔧). The menu numbers and letters are the same as in these notes.
  • enter = Enter  ·  tab = Tab (next box)  ·  esc = Esc  ·  del = Backspace.
  • Powers: type ^ (Shift+6), the power, then press → to come back down before typing more. x² = ^2 then →.
  • Fraction: type /  ·  √: type sqrt(  ·  π: type pi  ·  eˣ: type exp(  ·  store: type :=. For EE (×10ⁿ) and i, click them on the keypad.
  • New page: Ctrl+I (or the Insert menu)  ·  change page: Ctrl+← / Ctrl+→  ·  graph entry line: Ctrl+G  ·  var: Ctrl+L.
  • Radian / Degree: click Settings in the status bar at the bottom of the window. The mode (RAD or DEG) shows in the top bar.
  • IB exam mode (Press-to-Test): everything in these notes works on the non-CAS TI-Nspire with the IB exam settings. In exam mode there are no dot-product, cross-product, unit-vector or eigenvalue keys and no Diff Eq graphs — the notes show the allowed way (type the components, use polyRoots on the characteristic equation, do Euler steps on a Calculator page).
  • If you type nDeriv(, the software shows it as centralDiff( — it is the same command.
The big idea: Two variables give you two regression lines. The line of y on x predicts y from x. The line of x on y predicts x from y. They are different lines, they cross at the mean point (x̄, ȳ), and picking the wrong one gives a wrong answer.
By the end of this lesson you can:
  • explain what x on y means and when to use it instead of y on x
  • find the regression line of x on y with the GDC (swap the lists)
  • find both lines by hand from x̄, ȳ, sx, sy and r or sxy
  • use the fact that both lines pass through (x̄, ȳ)
  • use two given lines to find the mean point and the correlation r
  • predict, and comment on whether the prediction is reliable
🧑🏾 Imagine this…
Thato measures how many hours students study (x) and the mark they get (y). The usual line answers: “I study 6 hours. What mark should I expect?” But Thato may ask the other way round: “I want 70%. How many hours must I study?” Now the mark is the fixed number and the hours are the thing we are predicting. For that question we need a line built to predict hours: the line of x on y.
Regression line of on
the best-fit line for predicting y from a given x. Written . It makes the vertical gaps as small as possible.
Regression line of on
the best-fit line for predicting x from a given y. Written . It makes the horizontal gaps as small as possible.
Covariance
a number that measures how x and y move together. It is linked to r by , so .
Mean point
the point (x̄, ȳ). Both regression lines pass through it.
★ Two lines, one rule
  • Predicting y from x: use the line of y on x. Predicting x from y: use the line of x on y.
  • Both lines pass through the mean point (x̄, ȳ). So where they cross, you are at (x̄, ȳ).
  • By hand:   and   .   (the y-on-x form is in the IB formula booklet; the x-on-y line is the same with x and y swapped)
  • On the GDC for x on y: run Linear Regression (mx+b) with X List = the y data and Y List = the x data. The answer is then .
  • If the gradients are written as and , then . The sign of r is the sign of the gradients.
  • A prediction is reliable only if r is strong and the value you put in is inside the range of the data (interpolation).
⚠️ Watch out
  • Do not rearrange the y-on-x line to find x. It will give a different (worse) answer. If x is the thing you are asked to find, you need the x-on-y line.
  • On the GDC the swap is easy to forget. If your x-on-y line looks like it has the same gradient as y on x, you did not swap the lists.
  • An x-on-y line is x = my + c. The gradient m is “change in x per 1 unit of y”, not the slope you would draw on a graph with x across.
  • Your answer is only trusted if it is inside the data range. Say “interpolation” or “extrapolation” whenever you predict.
💡 Which line? Ask “what is given and what is wanted?”
Underline the number you are given and the quantity you must find. Given x, find y: y on x. Given y, find x: x on y. This one step decides the whole question.
🧪 Try it yourselfTwo lines open and close like scissors
Take x̄ = 10, ȳ = 50, sx = 2 and sy = 6. The slider r is the correlation. The two lines always cross at (10, 50). When r is small the lines are far apart. When r gets close to 1 the two lines almost become one line. Try r = 0.5, then 0.9, then 1.

Worked examples

Example 1.1Both lines on the GDC
A farmer in Palapye tries different amounts of fertiliser x (kg per hectare) on 8 plots and records the maize yield y (tonnes per hectare).
x: 20, 30, 40, 50, 60, 70, 80, 90
y: 2.1, 2.9, 2.4, 3.6, 3.1, 4.4, 3.8, 4.6
  1. (a) Find the regression line of y on x.
  2. (b) Find the regression line of x on y.
  3. (c) The farmer wants a yield of 4 tonnes per hectare. Estimate the fertiliser needed.
🧠 Think it through
  1. Part (a) is the usual regression: X List = x, Y List = y.
  2. Part (b): swap the lists. X List = y, Y List = x. The equation is then x = my + b.
  3. Part (c): the yield (4) is given and the fertiliser is wanted, so use x on y.
✍️ By hand
(a)
(b)
(c)
🔢 On your TI-Nspire CX II
  1. On Lists & Spreadsheet name column A fert and column B yld. Type the data.
  2. Go to menu💻 click menu on keypad▸6: Statistics▸1: Stat Calculations▸3: Linear Regression (mx+b). For (a) set X List = fert, Y List = yld.
    1.1*DocRAD◆Afert2030405060708090Byld2.12.92.43.63.14.43.84.6CD12345678A120
    1.1*DocRADLinear Regression (mx+b)X List:fertY List:yldSave RegEqn to:f1Frequency List:1Category List:Include Categories:OKCancel
    X List = fert, Y List = yld
    1.1*DocRADLinRegMxfert,yld,1:CopyVarstat.RegEqn,f1:stat.results"Title""Linear Regression (mx+b)""RegEqn""m·x+b""m"0.0327381"b"1.5619"r²"0.795492"r"0.891903"Resid""{…}"
    y on x: y = 0.0327x + 1.56
  3. For (b) run it again and swap: X List = yld, Y List = fert.
    1.1*DocRADLinear Regression (mx+b)X List:yldY List:fertSave RegEqn to:f1Frequency List:1Category List:Include Categories:OKCancel
    X List = yld, Y List = fert
    1.1*DocRADLinRegMxyld,fert,1:CopyVarstat.RegEqn,f1:stat.results"Title""Linear Regression (mx+b)""RegEqn""m·x+b""m"24.2987"b"-26.7042"r²"0.795492"r"0.891903"Resid""{…}"
    x on y: x = 24.3y − 26.7
    1.11.21.3*DocRAD1.522.533.544.555.520406080100yldfert
  4. For (c) type the value into the saved equation: f1(4).
    1.1*DocRADf1(4)70.4904
✅ Answer (a) y = 0.0327x + 1.56. (b) x = 24.3y − 26.7. (c) About 70.5 kg per hectare.
r is the same (0.892) for both lines. Using the wrong line, y = 0.0327x + 1.56 solved for y = 4, would give 74.5 kg per hectare: a different answer. 70.5 comes from the x-on-y line.
Example 1.2Which line should I use?
For 40 students, x is the hours of study per week and y the test mark (%). The two regression lines are
y on x: y = 4.2x + 31     x on y: x = 0.19y − 4.8
  1. (a) Estimate the mark of a student who studies 6 hours.
  2. (b) Estimate the hours a student should study to get 70%.
  3. (c) A learner rearranges y = 4.2x + 31 to answer (b). What does he get, and why is it wrong?
🧠 Think it through
  1. (a) Hours (6) is given, the mark is wanted: y on x.
  2. (b) The mark (70) is given, the hours are wanted: x on y.
  3. (c) Rearranging y on x gives . That is a different line from x on y.
✍️ By hand
(a)
(b)
(c)
🔢 On your TI-Nspire CX II
  1. Check the three values.
    1.1*DocRAD4.2·6+3156.20.19·70−4.88.570−314.29.28571
✅ Answer (a) 56.2%. (b) 8.5 hours. (c) He gets 9.29 hours. It is wrong because y on x is built to predict y; rearranging it does not give the best line for predicting x.
The two answers are not the same (8.5 and 9.29), and the x-on-y answer is the one the IB mark scheme wants whenever the question asks you to estimate x.
Example 1.3Both lines by hand from summary statistics
A sample of students has x̄ = 18.5, ȳ = 62, sx = 4, sy = 12 and correlation r = 0.75.
  1. (a) Find the covariance sxy.
  2. (b) Find the equation of the regression line of y on x.
  3. (c) Find the equation of the regression line of x on y.
  4. (d) Use the correct line to estimate x when y = 80.
🧠 Think it through
  1. Covariance: .
  2. y on x: gradient . x on y: gradient . Divide by the variance of the variable on the right of “on”.
  3. Put the mean point into each line. Simplify to the form asked for.
  4. y = 80 is given and x is wanted: x on y.
✍️ By hand
(a)
(b)
(c)
(d)
🔢 On your TI-Nspire CX II
  1. Check by typing the numbers.
    1.1*DocRAD0.75·4·1236.36422.25361220.250.25·80+323.
✅ Answer (a) 36. (b) y = 2.25x + 20.4. (c) x = 0.25y + 3. (d) x = 23.
Check that (18.5, 62) satisfies both: 2.25(18.5) + 20.375 = 62 and 0.25(62) + 3 = 18.5. If a mean point does not fit, you used the wrong variance.
Example 1.4Two lines given: find the mean point and r
The regression line of y on x is y = 0.8x + 12. The regression line of x on y is x = 0.45y + 1.
  1. (a) Find the mean of x and the mean of y.
  2. (b) Find the value of r.
  3. (c) Find the value of .
🧠 Think it through
  1. Both lines pass through (x̄, ȳ), so (x̄, ȳ) is where the two lines cross. Solve the two equations together.
  2. Gradients: (y on x) and (x on y). Then and r has the same sign as the gradients.
  3. The gradient of y on x is also . Use r from part (b).
✍️ By hand
(a)
(b)
(gradients are positive)
(c)
🔢 On your TI-Nspire CX II
  1. Check part (a) by solving both equations at once.
    1.1*DocRADlinSolvey=0.8·x+12x=0.45·y+1,{x,y}{10.,20.}0.8·0.450.6
✅ Answer (a) x̄ = 10, ȳ = 20. (b) r = 0.6. (c) .
Exam question tip: if you are told which equation is which, identify them from the form: y = … is “y on x”, x = … is “x on y”. If the two lines are given in a mixed form such as 2y − 3x = 8, rearrange both so that the variable that is alone is on the left.
Example 1.5Predicting and judging reliability
A dealer in Francistown records the age x (years) and the value y (thousand pula) of 7 used cars.
x: 1, 2, 3, 4, 5, 6, 7
y: 140, 112, 121, 90, 95, 70, 76
  1. (a) Find r and describe the correlation.
  2. (b) Find the regression line of x on y.
  3. (c) A buyer has P85 thousand. Estimate the age of car she should expect, and comment on reliability.
  4. (d) Comment on using the line for a car worth P30 thousand.
🧠 Think it through
  1. Linear Regression with X List = x and Y List = y gives r. The x-on-y line needs the lists swapped.
  2. For (c): y = 85 is given. Is 85 inside the y-values 70 to 140?
  3. For (d): 30 is far outside 70 to 140.
🔢 On your TI-Nspire CX II
  1. Enter lists age and val. Run Linear Regression with X List = val and Y List = age.
    1.1*DocRAD◆Aage1234567Bval14011212190957076CD1234567A11
    1.1*DocRADLinear Regression (mx+b)X List:valY List:ageSave RegEqn to:f1Frequency List:1Category List:Include Categories:OKCancel
    X List = val, Y List = age
    1.1*DocRADLinRegMxval,age,1:CopyVarstat.RegEqn,f1:stat.results"Title""Linear Regression (mx+b)""RegEqn""m·x+b""m"-0.0798158"b"12.0272"r²"0.860870"r"-0.927831"Resid""{…}"
    x on y: x = −0.0798y + 12.0
  2. Type f1(85) and f1(30).
    1.1*DocRADf1(85)5.24285f1(30)9.63271
✅ Answer (a) r = −0.928: a strong negative linear correlation (older cars are worth less). (b) x = −0.0798y + 12.0. (c) About 5.24 years. This is interpolation (85 lies between 70 and 140) and r is strong, so it is reliable. (d) 9.63 years is extrapolation (30 is outside 70 to 140; the data only cover cars up to 7 years old), so the estimate is not reliable.
r does not change when you swap x and y. It is the same −0.928 either way. Only the gradient and intercept change.

Challenge questions

⭐ Challenge 1.6Summary statistics, no calculatorPaper 1 style
For a set of bivariate data, x̄ = 14, ȳ = 52, sx = 2.5, sy = 10 and r = −0.8.
  1. (a) Find sxy.
  2. (b) Find the equation of the regression line of x on y, giving your answer in the form x = ay + b.
  3. (c) Estimate x when y = 60.
  4. (d) Explain why the line in (b) should not be used to estimate y.
✏️ Try it on paper and on your calculator first. Then check.
Show the full solution
🧠 Think it through
  1. .
  2. x on y: gradient , through (14, 52).
  3. Substitute y = 60.
  4. Think: which variable is the line built to predict?
✍️ By hand
(a)
(b)
(c)
✅ Answer (a) −20. (b) x = −0.2y + 24.4. (c) 12.4. (d) The x-on-y line is designed to estimate x from y. To estimate y from x you must use the y-on-x line.
The y-on-x gradient is . Multiply the two gradients: (−0.2)(−3.2) = 0.64 = r². Good check.
⭐ Challenge 1.7Rainfall and river flowPaper 2 style
Rainfall x (mm) in a catchment area and the flow y (m³ per second) in a river were recorded in 8 months.
x: 40, 55, 62, 75, 88, 95, 110, 125
y: 12, 15, 19, 20, 27, 26, 33, 36
  1. (a) Find r and describe the correlation.
  2. (b) Write down the equation of the regression line of y on x and of x on y.
  3. (c) Find the mean point and show that both lines pass through it.
  4. (d) Estimate the rainfall needed for a flow of 30 m³ per second.
  5. (e) Estimate the flow for 100 mm of rain.
  6. (f) Explain why you should not use these lines to estimate the rain for a flow of 5 m³ per second.
✏️ Try it on paper and on your calculator first. Then check.
Show the full solution
🧠 Think it through
  1. Run Linear Regression twice, swapping the lists.
  2. Mean point: Two-Variable Statistics, or average the data.
  3. (d) flow given, rain wanted: x on y. (e) rain given, flow wanted: y on x.
  4. (f) 5 is outside the y-range 12 to 36.
🔢 On your TI-Nspire CX II
  1. Lists rain and flow. First run with X List = rain, Y List = flow, then swap.
    1.1*DocRAD◆Arain405562758895110125Bflow1215192027263336CD12345678A140
    1.1*DocRADLinRegMxrain,flow,1:CopyVarstat.RegEqn,f1:stat.results"Title""Linear Regression (mx+b)""RegEqn""m·x+b""m"0.291576"b"-0.19059"r²"0.978117"r"0.988998"Resid""{…}"
    y on x: y = 0.292x − 0.191
    1.1*DocRADLinRegMxflow,rain,1:CopyVarstat.RegEqn,f1:stat.results"Title""Linear Regression (mx+b)""RegEqn""m·x+b""m"3.35458"b"2.41733"r²"0.978117"r"0.988998"Resid""{…}"
    x on y: x = 3.35y + 2.42
  2. Mean point: type mean(rain) and mean(flow), then test the lines.
    1.1*DocRADmean(rain)81.25mean(flow)23.50.291576·81.25−0.1905923.53.35458·23.5+2.4173381.25
  3. Predictions from the x-on-y line and the y-on-x line.
    1.1*DocRAD3.35458·30+2.41733103.0540.291576·100−0.1905928.9673.35458·5+2.4173319.1902
✅ Answer (a) r = 0.989: very strong positive linear correlation. (b) y = 0.292x − 0.191 and x = 3.35y + 2.42. (c) (x̄, ȳ) = (81.25, 23.5); both lines give 23.5 and 81.25 at the mean point. (d) About 103 mm. (e) About 29.0 m³ per second. (f) 5 is outside the data range (12 to 36), so this is extrapolation. The line gives 19.2 mm, but the real relationship may bend or stop near zero flow.
Because r is so close to 1, the two lines are almost the same, and either would give nearly the same answer here. When r is weaker, as in Example 1 (r = 0.89), the choice of line matters much more.
Next: Lesson 2 · Standardisation & z-values