Free access until 31 December 2026 · Physics and Maths questions and notes, updated continuously · Build a test

ExaminerPrep › IB Maths AA › Notes

IB Maths AA · Topic 4 · 4.4 · SL and HL

Correlation and regression of y on x

This note explains how to describe the relationship between two numerical variables using a scatter diagram, the Pearson correlation coefficient \(r\) and the regression line of \(y\) on \(x\). It also covers how to use a regression line to make predictions, and when those predictions can be trusted.

Key ideas

Bivariate data and scatter diagrams. Bivariate data records two variables for each item, for example hours of revision and test score. A scatter diagram plots each pair \((x,y)\) as a point. Usually \(x\) is the independent (explanatory) variable and \(y\) is the dependent (response) variable.

Describing correlation. Look at the direction and the strength.

  • Positive correlation: as \(x\) increases, \(y\) tends to increase.
  • Negative correlation: as \(x\) increases, \(y\) tends to decrease.
  • No correlation: no clear pattern.
  • The closer the points are to a straight line, the stronger the linear correlation.

Pearson's product-moment correlation coefficient \(r\). It measures the strength of linear correlation. It always lies between \(-1\) and \(1\).

  • \(r=1\): perfect positive linear correlation. \(r=-1\): perfect negative. \(r=0\): no linear correlation.
  • One common guide to size: \(|r|\) up to about 0.25 is very weak, 0.25 to 0.5 weak, 0.5 to 0.75 moderate, 0.75 to 0.9 strong, above 0.9 very strong. The sign gives the direction.
  • \(r\) only measures straight-line patterns. A clear curve can have \(r\) close to 0.
  • You find \(r\) with your GDC's linear regression feature.

Correlation is not causation. A strong correlation shows that two variables move together. It does not prove that one causes the other. A third factor may affect both.

Regression line of \(y\) on \(x\). This is the line \(y=ax+b\) that fits the data best. It is found using the least squares method, which makes the sum of the squares of the vertical distances from the points to the line as small as possible. The GDC gives \(a\) and \(b\).

  • The line passes through the mean point \((\bar{x},\bar{y})\).
  • The gradient \(a\) is the predicted change in \(y\) for a 1-unit increase in \(x\).
  • The intercept \(b\) is the predicted \(y\) when \(x=0\). It is only meaningful if \(x=0\) makes sense in context.

Using the line.

  • Interpolation: predicting \(y\) for an \(x\) inside the range of the data. Usually reliable if \(|r|\) is large.
  • Extrapolation: predicting outside the range of the data. This is unreliable, because the pattern may not continue.
  • The line of \(y\) on \(x\) is built to predict \(y\) from a given \(x\). Do not rearrange it to estimate \(x\) from a given \(y\); this gives a less reliable estimate.

Definitions and formulae

Term or formulaMeaning / when to use
\(r\), with \(-1\le r\le1\)Strength and direction of linear correlation. Found on the GDC.
\(y=ax+b\)Regression line of \(y\) on \(x\), found by least squares.
\((\bar{x},\bar{y})\)Mean point. It always lies on the regression line.
Gradient \(a\)Change in predicted \(y\) per unit increase in \(x\).
Interpolation / extrapolationPredicting inside / outside the data range.
Independent / dependent variable\(x\) is chosen or controlled; \(y\) is the response being predicted.

Worked examples

Example 1 A student records weekly revision time \(x\) (hours) and test score \(y\) (out of 30).
\(x\): 1, 2, 3, 4, 5, 6, 7, 8
\(y\): 12, 15, 14, 19, 21, 20, 26, 27
(a) Find \(r\) and describe the correlation. (b) Find the regression line of \(y\) on \(x\). (c) Predict the score for 5.5 hours.

(a) Enter \(x\) and \(y\) into two lists and use the linear regression feature on your GDC. It gives \(r=0.964\).

This is very close to 1, so there is a very strong positive linear correlation.

(b) The GDC gives \(a=2.14\) and \(b=9.61\), so \(y=2.14x+9.61\).

(c) \(x=5.5\) is inside the data range (1 to 8), so this is interpolation.

\(y=2.142857\times5.5+9.607=21.4\) (using unrounded values from the GDC).

Answer: (a) \(r=0.964\), very strong positive; (b) \(y=2.14x+9.61\); (c) about 21.4 marks

Example 2 Use the line from Example 1 to (a) interpret the gradient, and (b) comment on predicting the score for 10 hours of revision.

(a) The gradient is 2.14. Each extra hour of weekly revision is linked with an increase of about 2.14 marks in the predicted score.

(b) \(y=2.142857\times10+9.607=31.0\), but the test is out of 30, so the prediction is impossible.

Also, 10 hours is outside the data range (1 to 8), so this is extrapolation. The pattern may level off, and the prediction is not reliable.

Answer: about 2.14 extra marks per extra hour; the prediction of 31.0 is unreliable (extrapolation, and above the maximum)

Example 3 For used cars, price \(y\) (thousand euros) is modelled against age \(x\) (years) by \(y=-1.45x+18.2\), with \(r=-0.93\) and mean age \(\bar{x}=4.0\). (a) Find the mean price. (b) Describe the correlation. (c) Predict the price at 6 years and at 15 years, and comment.

(a) The line passes through \((\bar{x},\bar{y})\): \(\bar{y}=-1.45(4.0)+18.2=-5.8+18.2=12.4\).

(b) \(r=-0.93\) is close to \(-1\): very strong negative linear correlation. Older cars tend to be cheaper.

(c) At 6 years: \(y=-1.45(6)+18.2=9.5\), so about 9500 euros.

At 15 years: \(y=-1.45(15)+18.2=-3.55\), a negative price, which is impossible. Fifteen years is likely outside the data range, so this extrapolation is not valid.

Answer: (a) 12.4 thousand euros; (b) very strong negative; (c) 9.5 thousand euros at 6 years; the 15-year value is meaningless

Common errors

  • Common error: saying that a high \(r\) proves that \(x\) causes \(y\). It only shows a linear association.
  • Common error: interpreting \(r=-0.9\) as "weak" because it is negative. Judge strength from \(|r|\), and direction from the sign.
  • Common error: using the line of \(y\) on \(x\) to estimate \(x\) from a given \(y\) by rearranging. The line is designed to predict \(y\), so the estimate of \(x\) is less reliable.
  • Common error: making predictions far outside the data range without a warning.
  • Common error: interpreting the intercept literally when \(x=0\) is not sensible in the context.

Exam tip: When you interpret a gradient, include the units and both variables, for example "per extra hour of revision, the predicted score rises by 2.14 marks".

Check yourself

  1. Describe the correlation when \(r=-0.12\).
    AnswerVery weak negative linear correlation. There is almost no linear relationship.
  2. A regression line is \(y=3x+2\) and \(\bar{x}=5\). Find \(\bar{y}\), and the predicted \(y\) when \(x=4\).
    Answer\(\bar{y}=3(5)+2=17\). At \(x=4\): \(y=3(4)+2=14\).
  3. The data range is \(x\) from 10 to 50. For which of \(x=35\) and \(x=80\) is a prediction more reliable, and why?
    Answer\(x=35\). It is inside the range (interpolation). \(x=80\) is outside the range (extrapolation), so the relationship may not continue.
  4. Two variables have \(r=0.95\). A newspaper says one causes the other. Is this justified?
    AnswerNo. A strong correlation shows association only. Both could be affected by a third variable, or the link could be chance.