Linear Regression (AI HL)
Linear regression fits the line of on to a scatter diagram, with technology giving and . The line passes through the mean point, and its gradient and intercept are interpreted in the context of the data. Use it to predict from within the range of the data. It's part of the broader Bivariate & Non-linear Regression topic.
13 questions on this sub-topic.
Syllabus
| Code | Syllabus content |
|---|---|
| SL4.4 | Linear correlation of bivariate data and Pearson's product-moment correlation coefficient , 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 on , and interpreting the parameters and in in context, including the dangers of extrapolation. |
Official IB source: Mathematics: applications and interpretation subject brief (PDF, ibo.org).
Skills practised on this page:
- Find the equation of the regression line of y on x using a GDC.
- Interpret the gradient and intercept of a regression line in context, and explain the danger of extrapolating beyond the data.
- Calculate the residual (actual minus predicted value) for a single data point from a regression line.
The regression line
Regression line of on
Not in the formula booklet - your GDC generates and directly from the data. The line always passes through the mean point .
Residual
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 measures the strength and direction of a linear relationship, taking values from to . It is only meaningful when the relationship is roughly linear.
e.g. shows a strong negative linear correlation, while shows a weak one.
How do you interpret the gradient of a regression line?
The gradient is the change in for each increase of unit in , described in the context of the question.
e.g. If is hours of revision and is the test mark in , each extra hour of revision is associated with more marks.
How do you interpret the y-intercept?
The constant is the predicted value of when . It may have no sensible meaning if is far outside the data.
e.g. For with hours of revision and the test mark, predicts a mark of .
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 from to should not be trusted at .
Worked examples
A regression line is A data point is
(a) Find the predicted value of when
(b) Find the residual for this point.
Worked solution
(a) Predicted M1
A1
(b) Residual M1
Residual A1On the GDC. (a) Find the predicted value of y when x = 4. (b) Find the residual for this point.
For a data set, the regression line of on is The mean point is
(a) Verify that the mean point lies on the line.
(b) Explain why the line of on should be used to predict from , not from .
Worked solution
(a) M1
, so lies on the line. A1 AG
(b) The on line minimises vertical () errors, so it is for predicting from ; M1 A1
using it in reverse would not minimise the relevant errors. A1On the GDC. Evaluate the expression (e.g. , residual, or ) directly.
Casio fx-CG50: Run-Matrix.
Casio fx-CG100: HOME → Calculate.
TI-Nspire CX: Calculator.
A regression line is found from data with ranging from 5 to 20.
(a) Predict when
(b) Explain why predicting when is unreliable.
Worked solution
(a) M1
A1
(b) lies far outside the data range (5-20); this is extrapolation, where the linear relationship may not hold. M1 A1
Common mistakes
- Fitting the line in the wrong direction. The regression line of on minimises errors in , so it should only be used to predict from a given - not rearranged to predict from .
- 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 -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.
Core AI skill - gives the regression line and the correlation coefficient in one step.
- Enter -values in one list and -values in another.
- Turn on DiagnosticOn once (2nd → CATALOG) so appears; then STAT → CALC → 4:LinReg(ax+b), set Xlist and Ylist, Calculate.TI-84
- Calculator page → menu → Statistics → Stat Calculations → Linear Regression (mx+b).Nspire
- Statistics menu → CALC (F2) → REG (F3) → X (linear); shows automatically.Casio
- Read (gradient), (intercept), (correlation) and (coefficient of determination).
- Use the equation to predict - but only within the data range (interpolation).
Tip: near means a strong linear fit; near 0 means weak. is the proportion of variation explained.
After fitting several models (linear, quadratic, exponential...), you need to decide which fits the data best - is the key tool.
- Fit each candidate model in turn and note the value each time.
- Turn DiagnosticOn first (2nd → 0, scroll to DiagnosticOn, ENTER) - then appears after every regression.TI-84
- is shown automatically after each regression calculation in the Statistics menu.Nspire
- (displayed as ) appears in the regression output; run CALC → REG for each model type and compare.Casio
- The model with closest to 1 explains the most variation in - but also consider whether the model makes sense for the context.
- An exponential model with is better than a linear model with for the same data.
Tip: alone doesn't tell you whether the model is appropriate - always look at the scatter plot too. A high 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 on has equation , where and are found using technology from the data. The line always passes through the mean point .
What does a residual measure?
A residual is the difference between an observed -value and the value the regression line predicts for that , 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 on is the one used to predict from . Do not rearrange it to predict from ; fit the line of on 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 -values into the equation. The result should equal the mean of the -values, since the line passes through .
Ready to practise properly?
13 linear-regression questions, marked instantly like the real exam.