# Bivariate data: correlation and regression

> IB Mathematics AA HL · Statistics & Probability
> Source: https://www.owlsprep.com/study/ib-math-aa-hl-u4-bivariate-data-correlation-and-regression/

This sub-topic explores linear relationships between two quantitative variables. You will learn to measure the strength of association with correlation and fit linear prediction models with regression, which is regularly tested in both IB AA HL papers.

**Prerequisites:** [Descriptive statistics for univariate data](https://www.owlsprep.com/study/ib-math-aa-hl-u3-univariate-descriptive-statistics/)

## Learning objectives

- Distinguish between correlation and causation
- Calculate and interpret Pearson's product-moment correlation coefficient
- Find and interpret the equation of the least squares regression line
- Distinguish between interpolation and extrapolation and comment on prediction reliability
- Identify the effect of outliers on correlation and regression results

## Correlation and scatter diagrams

When we collect two measurements for the same individual or case, we plot the pairs of values on a scatter diagram to visually inspect the relationship between the variables.

**Bivariate data** — A dataset consisting of pairs of observations of two different variables collected on the same sampling unit.

*Example:* Height and weight measured for 50 high school students

Positive correlation means that as one variable increases, the other tends to increase. Negative correlation means as one variable increases, the other tends to decrease. No correlation means there is no observable linear trend.

> **warning**
>
> Correlation does not imply causation. A strong correlation can be caused by coincidence, a third confounding variable, or reverse causation. Causation can only be confirmed from controlled experiments, not observational data.

**Worked example:** A researcher finds a strong positive correlation between number of ice cream sales and number of drowning deaths per month. Explain why this does not mean ice cream sales cause drownings.

1. The positive correlation tells us that when ice cream sales are higher, drowning deaths also tend to increase following a linear trend.
2. This correlation is explained by the confounding variable of temperature. Higher temperatures lead to more people buying ice cream and more people swimming, which leads to more drownings.
3. There is no direct causal link between ice cream sales and drownings, the correlation is spurious.

## Pearson's product-moment correlation coefficient

Pearson's $r$ is a numerical measure of the strength and direction of the linear relationship between two quantitative variables. It is calculated with the formula:

$$r = \frac{\sum (x-\bar{x})(y-\bar{y})}{\sqrt{\sum (x-\bar{x})^2 \sum (y-\bar{y})^2}}$$

The value of $r$ always lies between $-1$ and $1$. Values close to $1$ mean strong positive linear correlation, values close to $-1$ mean strong negative linear correlation, and values close to $0$ mean weak or no linear correlation. Critically, $r$ only measures linear relationships: a strong non-linear relationship can have $r$ close to $0$.

**Worked example:** For the 4 data pairs $(1, 2), (2, 3), (3, 5), (4, 6)$, calculate Pearson's $r$ and interpret the result.

1. Calculate the means of $x$ and $y$:
2. $$\bar{x} = \frac{1+2+3+4}{4} = 2.5, \quad \bar{y} = \frac{2+3+5+6}{4} = 4$$
3. Calculate the required sums of products and squared deviations: $\sum (x-\bar{x})(y-\bar{y}) = 7$, $\sum (x-\bar{x})^2 = 5$, $\sum (y-\bar{y})^2 = 10$
4. Substitute into the formula for $r$:
5. $$r = \frac{7}{\sqrt{5 \times 10}} = \frac{7}{\sqrt{50}} \approx 0.99$$
6. Interpretation: There is a very strong positive linear correlation between $x$ and $y$.

**Check your understanding**

1. Pearson's $r = 0$ means there is no relationship between the two variables. True or false?

   - True
   - False

   *Why:* $r = 0$ only means there is no linear relationship. A strong non-linear relationship (e.g. $y=x^2$) can still exist even if $r=0$.

## Least squares regression line

When we have an explanatory variable $x$ and a response variable $y$, we can fit a straight line to model the relationship, which we use to predict values of $y$ for given values of $x$.

**Least squares regression line of $y$ on $x$** — The line that minimizes the sum of the squared vertical deviations between observed $y$ values and predicted $y$ values. This is the standard line of best fit for predicting $y$ from $x$.

*Notation:* $y = a + bx$

The gradient $b$ is the predicted change in $y$ for a 1-unit increase in $x$. The intercept $a$ is the predicted value of $y$ when $x=0$. Always interpret these values in context of the problem in the exam.

**Worked example:** For the data $(1, 2), (2, 3), (3, 5), (4, 6)$, find the equation of the least squares regression line of $y$ on $x$ and interpret the gradient.

1. We already know $\bar{x}=2.5$, $\bar{y}=4$, $\sum (x-\bar{x})(y-\bar{y})=7$, $\sum (x-\bar{x})^2=5$
2. Calculate the gradient $b$:
3. $$b = \frac{\sum (x-\bar{x})(y-\bar{y})}{\sum (x-\bar{x})^2} = \frac{7}{5} = 1.4$$
4. Calculate the intercept $a$ using $a = \bar{y} - b\bar{x}$:
5. $$a = 4 - (1.4 \times 2.5) = 0.5$$
6. Equation: $y = 1.4x + 0.5$. For every 1-unit increase in $x$, the predicted value of $y$ increases by 1.4 units on average.

> **tip**
>
> Always confirm which variable you are predicting. The line of $y$ on $x$ predicts $y$ from $x$. If you need to predict $x$ from $y$, you need a different regression line of $x$ on $y$.

## Interpolation and extrapolation

When using a regression line for prediction, the range of the original data is critical for assessing the reliability of the result.

**Interpolation vs extrapolation** — Interpolation predicts a value within the range of the original $x$ data and is generally reliable. Extrapolation predicts a value outside the range of the original $x$ data and is unreliable, because we cannot assume the linear trend continues outside observed values.

**Worked example:** A regression line for child height (y, cm) against age (x, years) for children aged 2 to 10 is $y = 6x + 70$. Predict the height of a 15-year-old and comment on reliability.

1. Substitute $x=15$ into the equation: $y = 6(15) + 70 = 160$ cm.
2. The original data covers ages 2 to 10, so 15 is outside the range. This prediction is extrapolation.
3. The prediction is unreliable: growth rate slows after age 10, so the linear trend observed for younger children does not extend to teenagers.

## Common pitfalls

- **Wrong:** Claiming a strong correlation proves causation
  - Why it fails: Correlation only measures association, not causal relationship, which requires experimental evidence
  - Correct: Never state causation unless the question explicitly justifies it, only describe the association
- **Wrong:** Saying $r=0$ means no relationship between variables
  - Why it fails: Pearson's $r$ only measures linear correlation, strong non-linear relationships can still exist
  - Correct: Always specify that $r=0$ means no linear relationship between the variables
- **Wrong:** Swapping $x$ and $y$ and using a $y$ on $x$ line to predict $x$
  - Why it fails: The least squares line minimizes error in the response variable, swapping variables gives a different line
  - Correct: Always confirm which variable you need to predict before fitting the regression line
- **Wrong:** Treating extrapolated predictions as equally reliable as interpolated ones
  - Why it fails: The linear trend may not hold outside the range of observed data
  - Correct: Always identify extrapolation and state that the prediction is unreliable
- **Wrong:** Ignoring outliers when calculating correlation and regression
  - Why it fails: Outliers can drastically change the value of $r$ and the slope of the regression line
  - Correct: Identify outliers on a scatter diagram and assess their impact on your results

## Cheatsheet

| Concept | Key Purpose | Key Notes |
| --- | --- | --- |
| Pearson's $r$ | Measure strength/direction of linear correlation | $-1 \leq r \leq 1$, $r \approx 1$ = strong +ve, $r \approx -1$ = strong -ve, $r \approx 0$ = no linear correlation |
| Least squares $y$ on $x$ | Predict $y$ from known $x$ | Minimizes sum of squared vertical deviations from the line |
| Correlation | Describe association between two variables | Correlation ≠ causation |
| Interpolation | Predict inside original $x$ range | Generally reliable |
| Extrapolation | Predict outside original $x$ range | Generally unreliable |

## What's next

Correlation and regression are core statistical skills that are regularly tested in IB AA HL, often appearing in extended multi-part questions that combine with other topics like descriptive statistics and probability. Note that hypothesis testing and chi-squared tests — sometimes associated with correlation elsewhere — belong to Math AI, not AA, and are not part of AA HL. Beyond IB, these ideas extend to more advanced statistical modeling such as significance testing for regression coefficients, residual analysis, and non-linear regression. Mastering the key concepts here will help you avoid common exam traps and earn full marks on both short and long response questions. Next, you can explore related statistical topics to build on your understanding.

---

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-aa-hl-u4-bivariate-data-correlation-and-regression/
