# Correlation and linear regression

> IB Mathematics AI SL · IB MATH AI SL
> Source: https://www.owlsprep.com/study/ib-math-ai-sl-u4-correlation-and-linear-regression/

This module covers analysis of bivariate quantitative data, including interpreting correlation, calculating Pearson's $r$, finding least squares regression lines, and using them for prediction. You will learn to avoid common exam traps around causation and extrapolation.

**Prerequisites:** [Univariate descriptive statistics](https://www.owlsprep.com/study/ib-math-ai-sl-u4-descriptive-statistics/)

## Learning objectives

- Distinguish between correlation and causation in bivariate data
- Calculate and interpret Pearson's product-moment correlation coefficient
- Find the equation of the least squares regression line of $y$ on $x$ using technology
- Distinguish between interpolation and extrapolation, and comment on prediction reliability

## Correlation and Pearson's $r$

**Bivariate Data** — Data that collects two different quantitative variables from each observation. We analyse bivariate data to identify relationships between the two variables.

*Example:* Recording height and mass for 50 adult participants

A scatter diagram plots each pair of $(x,y)$ data points on a set of axes, allowing us to see if there is an upward (positive) or downward (negative) linear trend. Pearson's product-moment correlation coefficient $r$ quantifies this trend.

**Pearson's Product-Moment Correlation Coefficient** — A standardised measure of the strength and direction of the *linear* relationship between two variables, with a fixed range of $-1 \leq r \leq 1$.

*Notation:* $r$

- $r=+1$: perfect positive linear correlation
- $r=-1$: perfect negative linear correlation
- $r=0$: no linear correlation

> **info**
>
> **Correlation does not imply causation**. A strong correlation between two variables does not prove that one causes changes in the other. The relationship may be due to coincidence or a third 'lurking' variable that affects both.

**Worked example:** A study finds $r=0.92$ between the number of fire fighters sent to a fire and the amount of damage the fire causes. Interpret $r$ and explain why more fire fighters do not cause more damage.

1. First, interpret the value of $r$:
2. $$r = 0.92$$
3. $r=0.92$ is positive and very close to 1, so there is a very strong positive linear relationship between the number of fire fighters sent and the amount of fire damage.
4. The correlation does not mean fire fighters cause more damage. A lurking variable, the size of the fire, causes both: larger fires require more fire fighters and cause more damage.

> **Exam tip:** Always interpret $r$ in the context of the given variables, not just state the number. 1 mark is usually allocated for context in exams.

*Calculator:* allowed

## Least Squares Regression Line

If there is a linear relationship between two variables, we can model the relationship with a straight line called the least squares regression line, which we use to predict values of one variable from the other.

**Least Squares Regression Line ($y$ on $x$)** — The straight line that minimises the sum of the squares of the vertical distances (residuals) between the observed $y$-values and the line. $y$ is the response (predicted) variable, and $x$ is the explanatory (independent) variable.

*Notation:* \hat{y} = a + bx

> **tip**
>
> Always assign the variable you need to predict as $y$, and the known variable as $x$ before calculating the regression line on your GDC.

**Worked example:** The table below shows the daily temperature ($^\circ C$, $x$) and the number of ice creams sold at a beach shop ($y$) for 7 days. Find the equation of the regression line of $y$ on $x$, to 3 significant figures. 

$x = [18, 20, 22, 25, 26, 28, 30]$
$y = [120, 155, 160, 190, 210, 240, 250]$

1. 1. Enter the $x$ and $y$ data into your GDC's statistics mode.
2. 2. Run a linear regression to calculate the intercept $a$ and gradient $b$.
3. 3. Round the coefficients to 3 significant figures: $a \approx -111$ and $b \approx 12.2$.
4. 4. Write the equation in context:
5. $$\hat{y} = -111 + 12.2x$$
6. Where $\hat{y}$ is the predicted number of ice creams sold and $x$ is daily temperature in $^\circ C$.

> **Exam tip:** IB expects regression coefficients rounded to 3 significant figures, unless stated otherwise. Avoid rounding too early in your working.

*Calculator:* allowed

## Prediction: Interpolation vs Extrapolation

We use regression lines to predict unknown values of $y$ for a given $x$. The reliability of the prediction depends on whether the $x$-value falls inside or outside the range of the original data used to create the line.

**Interpolation** — Predicting a value of $y$ for an $x$-value that lies within the range of the original $x$ data. Interpolation is generally reliable, as we know the linear relationship holds in this range.

**Extrapolation** — Predicting a value of $y$ for an $x$-value that lies outside the range of the original $x$ data. Extrapolation is unreliable, because we have no evidence the linear relationship continues outside the observed range.

> **warning**
>
> IB exam questions almost always allocate 1 mark for commenting on the reliability of a prediction, based on whether it is interpolation or extrapolation. Never skip this step.

**Worked example:** Use the ice cream regression line from the previous example, where original $x$ values range from $18^\circ C$ to $30^\circ C$. State whether each prediction is interpolation or extrapolation, and comment on reliability: (a) Predict ice cream sales at $24^\circ C$, (b) Predict ice cream sales at $10^\circ C$.

1. (a) $24^\circ C$ lies between 18 and 30, so this prediction is interpolation. The prediction is expected to be reliable.
2. (b) $10^\circ C$ is less than the minimum original $x$-value of $18^\circ C$, so this is extrapolation. The prediction is unreliable, because we do not know if the linear relationship holds at this lower temperature. For example, the shop may sell zero ice creams at $10^\circ C$, but the line would predict a positive value.

> **Exam tip:** Always reference the original data range when justifying your comment on reliability.

*Calculator:* allowed

## Common pitfalls

- **Wrong:** Claiming that a strong correlation proves one variable causes the other.
  - Why it fails: Examiners specifically test understanding of the difference between correlation and causation, and will deduct marks for incorrect causal claims.
  - Correct: State that correlation only indicates association, not causation, unless the relationship is confirmed by a controlled experiment.
- **Wrong:** Swapping $x$ and $y$ when calculating the regression line, using the wrong variable as the response.
  - Why it fails: The $y$ on $x$ regression line changes depending on which variable you predict, so swapping gives an incorrect equation.
  - Correct: Always confirm which variable you need to predict, set it as $y$ before running regression on your GDC.
- **Wrong:** Claiming $r=0$ means there is no relationship at all between the two variables.
  - Why it fails: $r$ only measures linear relationships, so $r=0$ does not rule out a strong non-linear relationship.
  - Correct: State that $r=0$ means there is *no linear relationship* between the variables.
- **Wrong:** Forgetting to comment on the reliability of a prediction after calculating it.
  - Why it fails: Most exam questions allocate 1 mark explicitly for this comment, which is easy to miss.
  - Correct: Always compare the prediction $x$-value to the original data range, state if it is interpolation (reliable) or extrapolation (unreliable).

## Cheatsheet

| Concept | Key Meaning | Exam Note |
| --- | --- | --- |
| $r = +1$ | Perfect positive linear correlation | All points on upward straight line |
| $r = -1$ | Perfect negative linear correlation | All points on downward straight line |
| $\|r\| > 0.7$ | Strong linear correlation |  |
| $0.3 < \|r\| < 0.7$ | Moderate linear correlation |  |
| $\|r\| < 0.3$ | Weak linear correlation | $r=0$ = no linear correlation |
| Regression line | $\hat{y} = a + bx$ | $y$ = variable to predict |
| Interpolation | $x$ inside original range | Prediction is reliable |
| Extrapolation | $x$ outside original range | Prediction is unreliable |
| Correlation $\neq$ Causation | Association does not prove causation | Always watch for this question |

## What's next

Correlation and linear regression is a foundational concept for all further statistical analysis of relationships between variables in IB AI SL. It forms the basis for understanding residual analysis, goodness of fit, and non-linear transformation of data to fit linear models. Mastering the key distinctions between correlation and causation, and interpolation and extrapolation, will help you avoid common mistakes in exam questions and build a strong base for more advanced statistical topics.

- [Basic probability concepts and combined events](https://www.owlsprep.com/study/ib-math-ai-sl-u4-basic-probability-concepts-and-combined/)
- [Conditional probability and independence](https://www.owlsprep.com/study/ib-math-ai-sl-u4-conditional-probability-and-independence/)
- [Discrete probability distributions](https://www.owlsprep.com/study/ib-math-ai-sl-u4-discrete-probability-distributions/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/ib-math-ai-sl-u4-correlation-and-linear-regression/
