Linear Regression (AI HL)

Linear regression fits the line y=ax+by=ax+b of yy on xx to a scatter diagram, with technology giving aa and bb. The line passes through the mean point, and its gradient and intercept are interpreted in the context of the data. Use it to predict yy from xx within the range of the data. It's part of the broader Bivariate & Non-linear Regression topic.

13 questions on this sub-topic.

Syllabus

CodeSyllabus content
SL4.4Linear correlation of bivariate data and Pearson's product-moment correlation coefficient rr, found using technology - meaningful only for linear relationships. Scatter diagrams with lines of best fit by eye through the mean point, the equation of the regression line of yy on xx, and interpreting the parameters aa and bb in y=ax+by=ax+b in context, including the dangers of extrapolation.

Official IB source: Mathematics: applications and interpretation subject brief (PDF, ibo.org).

Skills practised on this page:

The regression line

Regression line of yy on xx

y=ax+by=ax+b

Not in the formula booklet - your GDC generates aa and bb directly from the data. The line always passes through the mean point (x¯,y¯)(\bar{x},\bar{y}).

Residual

residual=yobserved−ypredicted\text{residual} = y_{\text{observed}} - y_{\text{predicted}}

How far a real data point sits above or below the line - a large residual flags an outlier or a point the line fits poorly.

Need the full syllabus wording and formula-booklet reference table? See Bivariate & Non-linear Regression.

Key terms

What does Pearson's correlation coefficient measure?

Pearson's product-moment correlation coefficient rr measures the strength and direction of a linear relationship, taking values from −1-1 to 11. It is only meaningful when the relationship is roughly linear.

e.g. r=−0.92r=-0.92 shows a strong negative linear correlation, while r=0.1r=0.1 shows a weak one.

How do you interpret the gradient of a regression line?

The gradient aa is the change in yy for each increase of 11 unit in xx, described in the context of the question.

e.g. If xx is hours of revision and yy is the test mark in y=1.8x+4y=1.8x+4, each extra hour of revision is associated with 1.81.8 more marks.

How do you interpret the y-intercept?

The constant bb is the predicted value of yy when x=0x=0. It may have no sensible meaning if x=0x=0 is far outside the data.

e.g. For y=1.8x+4y=1.8x+4 with xx hours of revision and yy the test mark, x=0x=0 predicts a mark of 44.

What is extrapolation?

Extrapolation is using the line to predict outside the range of the data, where the trend may not continue. Predictions inside the range, called interpolation, are more reliable.

e.g. A line fitted to data with xx from 55 to 2020 should not be trusted at x=60x=60.

Worked examples

1
Medium
GDC
[4 marks]

A regression line is y=3x+2.y = 3x + 2. A data point is (4,16).(4, 16).

(a) Find the predicted value of yy when x=4.x = 4.

(b) Find the residual for this point.

Worked solution

(a) Predicted y=3(4)+2y = 3(4) + 2 M1
y=14.y = 14. A1

(b) Residual =observed−predicted=16−14= \text{observed} - \text{predicted} = 16 - 14 M1
Residual =2.= 2. A1On the GDC. (a) Find the predicted value of y when x = 4. (b) Find the residual for this point.

TI-84 Plus CE: (a) 2nd mode then type 3*4+2 enter Then (b) 2nd mode then type 16-(3*4+2) enterCasio fx-CG50: (a) MENU Run-Matrix then type 3*4+2 EXE Then (b) MENU Run-Matrix then type 16-(3*4+2) EXECasio fx-CG100: (a) HOME Calculate then type 3*4+2 EXE Then (b) HOME Calculate then type 16-(3*4+2) EXETI-Nspire CX: (a) home Calculator then type 3*4+2 enter Then (b) home Calculator then type 16-(3*4+2) enterFull GDC guide: Enter a calculation on the home screen Topic page

M1 Substituting x=4x=4 into y=3x+2y=3x+2 A1 Correct answer of 1414 M1 Obs - pred A1 Correct answer of 22
2
Hard
GDC
[5 marks]

For a data set, the regression line of yy on xx is y=1.8x+4.y = 1.8x + 4. The mean point is (x¯,y¯)=(10,22).(\bar{x}, \bar{y}) = (10, 22).

(a) Verify that the mean point lies on the line.

(b) Explain why the line of yy on xx should be used to predict yy from xx, not xx from yy.

Worked solution

(a) 1.8(10)+4=221.8(10) + 4 = 22 M1
1.8(10)+4=y¯1.8(10) + 4 = \bar y, so (10,22)(10,22) lies on the line. A1 AG

(b) The yy on xx line minimises vertical (yy) errors, so it is for predicting yy from xx; M1 A1
using it in reverse would not minimise the relevant errors. A1On the GDC. Evaluate the expression (e.g. r2r^2, residual, or ece^{c}) directly.

TI-84 Plus CE: home screen.
Casio fx-CG50: Run-Matrix.
Casio fx-CG100: HOME → Calculate.
TI-Nspire CX: Calculator.

M1 Substituting x¯=10\bar x=10 into the line to get 1.8(10)+4=221.8(10)+4=22 A1 =y¯=\bar y M1 Minimises yy-errors A1 Predict yy from xx A1 Not reverse
3
Medium
GDC
[4 marks]

A regression line y=2.5x+10y = 2.5x + 10 is found from data with xx ranging from 5 to 20.

(a) Predict yy when x=12.x = 12.

(b) Explain why predicting yy when x=40x = 40 is unreliable.

Worked solution

(a) y=2.5(12)+10y = 2.5(12) + 10 M1
y=40.y = 40. A1

(b) x=40x = 40 lies far outside the data range (5-20); this is extrapolation, where the linear relationship may not hold. M1 A1

Regression on the GDC - TI‑84 STAT▸CALC▸LinReg/ExpReg/PwrReg · Casio STAT▸CALC · Nspire Stat Calculations; turn DiagnosticOn for rr.

M1 Substituting x=12x=12 into y=2.5x+10y=2.5x+10 A1 Correct answer of 4040 M1 Outside range A1 Extrapolation

Common mistakes

  • Fitting the line in the wrong direction. The regression line of yy on xx minimises errors in yy, so it should only be used to predict yy from a given xx - not rearranged to predict xx from yy.
  • Getting the residual sign backwards. A residual is observed minus predicted, not the other way round - a point above the line gives a positive residual.
  • Trusting a prediction far outside the data range. Extrapolating well beyond the smallest and largest xx-values used to fit the line assumes the same linear trend continues, which often isn't true.

Using your GDC

Every step below is a real button sequence, not a vague "use your calculator" hint - covering the TI-84 Plus, TI-Nspire, and Casio fx-9860/fx-CG50. Pick your model to filter down to just the steps that apply to you.

Show steps for:
Linear regression (line of best fit) and r

Core AI skill - gives the regression line and the correlation coefficient in one step.

  1. Enter xx-values in one list and yy-values in another.
  2. Turn on DiagnosticOn once (2nd → CATALOG) so rr appears; then STAT → CALC → 4:LinReg(ax+b), set Xlist and Ylist, Calculate.TI-84
  3. Calculator page → menu → Statistics → Stat Calculations → Linear Regression (mx+b).Nspire
  4. Statistics menu → CALC (F2) → REG (F3) → X (linear); rr shows automatically.Casio
  5. Read aa (gradient), bb (intercept), rr (correlation) and r2r^2 (coefficient of determination).
  6. Use the equation to predict - but only within the data range (interpolation).

Tip: rr near ±1\pm1 means a strong linear fit; near 0 means weak. r2r^2 is the proportion of variation explained.

Compare regression models using R²

After fitting several models (linear, quadratic, exponential...), you need to decide which fits the data best - R2R^2 is the key tool.

  1. Fit each candidate model in turn and note the R2R^2 value each time.
  2. Turn DiagnosticOn first (2nd → 0, scroll to DiagnosticOn, ENTER) - then R2R^2 appears after every regression.TI-84
  3. R2R^2 is shown automatically after each regression calculation in the Statistics menu.Nspire
  4. R2R^2 (displayed as r2r^2) appears in the regression output; run CALC → REG for each model type and compare.Casio
  5. The model with R2R^2 closest to 1 explains the most variation in yy - but also consider whether the model makes sense for the context.
  6. An exponential model with R2=0.98R^2 = 0.98 is better than a linear model with R2=0.91R^2 = 0.91 for the same data.

Tip: R2R^2 alone doesn't tell you whether the model is appropriate - always look at the scatter plot too. A high R2R^2 on a model that shouldn't apply (e.g. sinusoidal for steadily growing data) is meaningless.

See the full GDC guide for more calculator models and topics.

Quick questions

What is the equation of the linear regression line?

The regression line of yy on xx has equation y=ax+by = ax + b, where aa and bb are found using technology from the data. The line always passes through the mean point (x¯,y¯)(\bar{x}, \bar{y}).

What does a residual measure?

A residual is the difference between an observed yy-value and the value the regression line predicts for that xx, calculated as observed minus predicted. See using your GDC for how to generate the line itself.

Why is the line of y on x different from the line of x on y?

The line of yy on xx is the one used to predict yy from xx. Do not rearrange it to predict xx from yy; fit the line of xx on yy instead.

Does a strong correlation mean that x causes y?

No. Correlation shows that two variables are associated, not that one causes the other, because a third factor may affect both.

How can I check my line using the mean point?

Substitute the mean of the xx-values into the equation. The result should equal the mean of the yy-values, since the line passes through (x¯,y¯)(\bar{x},\bar{y}).

Ready to practise properly?

13 linear-regression questions, marked instantly like the real exam.