IB Diploma Mathematics AI · Statistics and probability
Correlation and regression
1Scatter diagrams and correlation
A scatter diagram plots pairs of data $(x, y)$ to show whether two variables are related.
- Positive correlation: as $x$ increases, $y$ tends to increase.
- Negative correlation: as $x$ increases, $y$ tends to decrease.
- No correlation: no clear pattern.
- The correlation is strong if the points lie close to a straight line, and weak if they are widely scattered.
Correlation does not mean causation. Ice cream sales and drownings both rise in summer, but one does not cause the other: a third variable (hot weather) affects both.
Check yourself
Ice cream sales and sunburn cases are strongly correlated. Does eating ice cream cause sunburn?
Show the answer
No: both are caused by hot sunny weather
Correlation alone never proves causation.
2Pearson's correlation coefficient
Pearson's product-moment correlation coefficient $r$ measures the strength of a linear relationship. Find it with your calculator.
- $r$ is always between $-1$ and $1$.
- $r = 1$: perfect positive linear correlation. $r = -1$: perfect negative. $r = 0$: no linear correlation.
- Rough guide: $|r| > 0.75$ strong, $0.5 < |r| \le 0.75$ moderate, $0.25 < |r| \le 0.5$ weak, below that very weak or none.
Pearson's $r$ only measures straight-line relationships. A perfect curve can still give a small $r$.
Check yourself
Which value of r shows the strongest correlation?
Show the answer
−0.92
The size of r matters, not its sign.
3The regression line
The least squares regression line of $y$ on $x$ is the line of best fit, $y = ax + b$. The calculator finds $a$ and $b$.
Revision and test scores, with the regression line through the mean point
Revision and test scores
- Hours of revision $x$: 1, 2, 3, 4, 5, 6. Test score $y$: 52, 55, 61, 64, 70, 72.
- The calculator gives $r = 0.993$: a strong positive linear correlation.
- Regression line: $y = 4.23x + 47.5$.
- Predict the score for 4.5 hours: $y = 4.23(4.5) + 47.5 = 66.6$.
- Interpret the gradient: each extra hour of revision is linked to about 4.23 more marks.
- Interpret the intercept: with no revision, the model predicts about 47.5 marks.
The line always passes through the mean point $(\bar{x}, \bar{y})$.
Check yourself
What does the gradient of a regression line tell you?
Show the answer
How much y changes, on average, for each increase of 1 in x
It is the rate of change in context.
4Using the regression line wisely
- Only use the line of $y$ on $x$ to predict $y$ from $x$.
- Interpolation (within the data range) is reasonably reliable if the correlation is strong.
- Extrapolation (outside the data range) is unreliable: the pattern may not continue. A student who revises for 30 hours would not score 174 marks.
- A prediction is only as good as the correlation: with a weak $r$, predictions are unreliable.
Before using a regression line, check the scatter diagram: is the relationship really linear, and are there outliers pulling the line?
Check yourself
A regression line was found for x from 10 to 50. Why is predicting y at x = 200 unreliable?
Show the answer
It is extrapolation far outside the data range
The relationship may change outside the data.
5Describing correlation in words
Describe correlation using direction and strength, in context.
- Direction: positive (both increase) or negative (one increases as the other decreases).
- Strength from $r$: roughly, $|r| > 0.75$ strong; $0.5$ to $0.75$ moderate; $0.25$ to $0.5$ weak; below $0.25$ very weak or none.
Worked example
- $r = -0.82$ between hours of screen time and hours of sleep.
- Description: strong negative linear correlation; students with more screen time tend to sleep less.
- Caution: this does not prove screen time causes less sleep.
Check yourself
What does $r = 0.1$ suggest?
Show the answer
Very weak or no linear correlation
Close to zero.
6Interpolation and extrapolation
- Interpolation: predicting within the range of the data; usually reliable if correlation is strong.
- Extrapolation: predicting outside the range; risky because the relationship may change.
Worked example
- Data on plant height for 0 to 10 weeks give $h = 2.5w + 3$.
- Prediction for 6 weeks: $h = 18$ cm (interpolation, reliable).
- Prediction for 52 weeks: $h = 133$ cm (extrapolation, unreliable; growth may slow).
Check yourself
Why is extrapolation unreliable?
Show the answer
The relationship may not continue outside the data range
Beyond the data.
7Going deeper: interpreting a regression model and knowing its limits
a shop records the daily maximum temperature $x$ (°C) and ice cream sales $y$ (number sold) on 15 days, with temperatures from 15°C to 30°C. The GDC gives $r = 0.88$ and $y = 12.4x - 85$.
- Describe: a strong, positive, linear correlation. Higher temperatures are associated with higher sales.
- Gradient: each rise of 1°C is associated with about 12.4 more ice creams sold.
- Intercept: at 0°C the model predicts $-85$ sales, which is impossible. The intercept has no sensible meaning here because 0°C is far outside the data.
- Interpolate: at 25°C, $12.4 \times 25 - 85 = 225$. Reliable: inside the data range with strong correlation.
- Extrapolate: at 5°C, $12.4 \times 5 - 85 = -23$. Unreliable and meaningless.
- Direction: this line predicts sales from temperature. Do not use it to estimate temperature from sales.
- Coefficient of determination (HL): $r^2 = 0.77$, so about 77% of the variation in sales is explained by the linear relationship with temperature.
Describing correlation in words: give strength (weak, moderate, strong), direction (positive, negative) and form (linear), then a sentence in context.
When to trust a prediction
- The value of $x$ is within the range of the data.
- The correlation is strong.
- The scatter diagram looks linear, without a curve.
- The sample is reasonably large.
Correlation and causation
- Temperature plausibly causes sales here. But a strong correlation alone never proves it.
- Shoe size and reading ability are correlated in children because both increase with age: a lurking variable.
- Experiments, where one variable is controlled, are needed to establish cause.
Outliers: one unusual day (a festival, a power cut) can pull the line and change $r$. Identify it on the scatter diagram and consider running the regression with and without it, explaining your choice.
The mean point: the regression line always passes through $(\bar{x}, \bar{y})$. This is useful for drawing a line of best fit by eye on Paper 1.
Piecewise linear models: if the scatter shows two different linear trends, such as sales rising with temperature until stock runs out, fit separate lines to each part.
Common mistakes
- Saying "as temperature increases, sales increase by 12.4" without "about" and without units.
- Using a line with weak correlation to predict.
- Reporting $r$ to too many figures or stating "$r$ is high so $x$ causes $y$".
Check yourself
Data were collected for x between 15 and 30. For which value of x is a prediction from the regression line most reliable?
Show the answer
x = 22
Only 22 lies inside the range of the data, so it is interpolation.
Now test yourself
This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.
Practise in Impera