# Spearman's rank correlation coefficient

> IB Mathematics: Applications and Interpretation HL · Unit 5: Statistics and probability
> Source: https://www.owlsprep.com/study/ib-math-ai-hl-u5-spearman-s-rank-correlation-coefficient/

This module covers Spearman's rank correlation coefficient ($r_s$), a non-parametric measure of association between two ranked variables. You will learn when to use it, how to calculate it, and how to interpret its value for IB exam questions.

**Prerequisites:** [Pearson's product-moment correlation coefficient](https://www.owlsprep.com/study/ib-math-ai-hl-u5-pearson-s-correlation/); [Bivariate data analysis](https://www.owlsprep.com/study/ib-math-ai-hl-u5-bivariate-data-analysis/)

## Learning objectives

- Identify when to use Spearman's rank correlation instead of Pearson's
- Calculate Spearman's $r_s$ for data with and without tied ranks
- Interpret the value of $r_s$ in context
- Handle tied ranks correctly according to IB exam requirements

## When to use Spearman's $r_s$

Spearman's rank correlation coefficient measures the strength and direction of a **monotonic relationship** between two variables. A relationship is monotonic if as one variable increases, the other either always increases or always decreases, regardless of whether the change is at a constant rate.

**Monotonic relationship** — A relationship where one variable consistently changes in the same direction as the other changes, but not necessarily at a constant rate.

*Example:* As daily calorie intake increases, adult body weight generally increases, but not at a constant linear rate.

Unlike Pearson's correlation coefficient, which only measures linear relationships, Spearman's works for any monotonic relationship, including non-linear ones. It is also required when data is already provided in ranks rather than raw numerical values.

> **info**
>
> You will almost always be expected to use Spearman's if the question mentions ranks, or if the scatterplot shows a clear non-linear monotonic trend.

**Worked example:** A researcher studies the relationship between age of drivers and number of accident claims. A scatterplot shows a clear increasing non-linear trend. Should the researcher use Pearson's or Spearman's correlation?

1. Check the type of relationship: it is increasing (monotonic) but non-linear.
2. Pearson's only measures linear relationships, so it will underestimate the true strength of association.
3. Conclusion: The researcher should use Spearman's rank correlation coefficient.

## Calculation for untied ranks

**Spearman's rank correlation (untied ranks)** — Calculated using the standard formula:

*Notation:* r_s

$$r_s = 1 - \frac{6\sum d_i^2}{n(n^2 - 1)}$$

Where: 
- $d_i$ = difference between the ranks of the $i$-th pair of observations
- $n$ = total number of paired observations

1. Rank each variable separately in the same direction (lowest to highest or highest to lowest)
2. Calculate the difference $d_i$ between the two ranks for each pair
3. Square each $d_i$ and sum all squares to get $\sum d_i^2$
4. Substitute values into the formula to find $r_s$

**Worked example:** 6 students have the following maths and physics test scores. Rank the scores and calculate Spearman's $r_s$. Maths: 85, 72, 90, 65, 78, 80. Physics: 90, 75, 85, 60, 70, 82.

1. Rank maths from highest to lowest: [2, 5, 1, 6, 4, 3]
2. Rank physics from highest to lowest: [1, 4, 2, 6, 5, 3]
3. Calculate differences $d_i$: $2-1=1$, $5-4=1$, $1-2=-1$, $6-6=0$, $4-5=-1$, $3-3=0$
4. Square differences: $1^2=1$, $1^2=1$, $(-1)^2=1$, $0^2=0$, $(-1)^2=1$, $0^2=0$
5. Sum of squared differences:
6. $$\sum d_i^2 = 1 + 1 + 1 + 0 + 1 + 0 = 4$$
7. Substitute into formula ($n=6$):
8. $$r_s = 1 - \frac{6 \times 4}{6(6^2 - 1)} = 1 - \frac{24}{210} \approx 0.886$$

> **Exam tip**
>
> Ranking direction does not affect the final value of $r_s$ as long as you are consistent for both variables.

*Calculator:* allowed

## Handling tied ranks

When two or more observations have the same value for a variable, they have tied ranks. We assign the average of the positions they would have occupied to each tied observation.

When there are tied ranks, the standard formula above is an approximation. For IB AI HL exams, this approximation is always accepted, unless the question specifically asks for the full adjusted calculation (which is extremely rare).

**Worked example:** Five runners have 100m times (seconds): 12.3, 12.1, 12.2, 12.1, 12.5. Assign ranks to these times (fastest = lowest rank).

1. Sort times from fastest to slowest: 12.1, 12.1, 12.2, 12.3, 12.5
2. The two 12.1s occupy positions 1 and 2. Assign each the average rank: $(1+2)/2 = 1.5$
3. Final ranks: 1.5, 3, 4, 1.5, 5

> **tip**
>
> Most GDCs will automatically calculate $r_s$ for you from raw data, even with ties. Always check your GDC result against your manual calculation in exams.

*Calculator:* allowed

## Interpreting $r_s$

Like Pearson's $r$, $r_s$ always ranges between $-1$ and $+1$. The sign indicates the direction of the monotonic relationship, and the absolute value indicates the strength.

| Value of $\|r_s\|$ | Strength of association |
| --- | --- |
| $0 \leq \|r_s\| < 0.3$ | Very weak |
| $0.3 \leq \|r_s\| < 0.5$ | Weak |
| $0.5 \leq \|r_s\| < 0.7$ | Moderate |
| $0.7 \leq \|r_s\| < 0.9$ | Strong |
| $0.9 \leq \|r_s\| \leq 1$ | Perfect monotonic |

**Worked example:** In the earlier maths/physics test example, we got $r_s = 0.886$. Interpret this value in context.

1. The value of $r_s$ is positive, so there is a positive relationship: higher ranks in maths are associated with higher ranks in physics.
2. The absolute value of $0.886$ is greater than $0.7$, so this is a strong positive monotonic relationship between maths and physics test performance.

**Exam command terms**

Common exam command terms for this topic:

- **Interpret** — Explain what $r_s$ tells you about the relationship in the given context *(You must mention direction and strength, and refer to the specific variables in the question to get full marks.)*

- **Calculate** — Show all working steps to get the final numerical value of $r_s$

## Common pitfalls

- **Wrong:** Using Pearson's correlation when Spearman's is required
  - Why it fails: Pearson only measures linear relationships, so it will give an incorrect result for ranked or non-linear monotonic data
  - Correct: Always check if the question mentions ranks or if the relationship is non-linear, use Spearman's in these cases
- **Wrong:** Ranking one variable from lowest to highest and the other from highest to lowest, leading to wrong sign on $r_s$
  - Why it fails: Reversing rank direction for one variable flips the sign of the final result, which will lose marks for interpretation
  - Correct: Always rank both variables in the same direction, and check that the sign of $r_s$ makes sense in context
- **Wrong:** Forgetting to square differences $d_i$ before summing
  - Why it fails: This leads to an incorrect value of $\sum d_i^2$ and wrong final $r_s$
  - Correct: Always square each difference before adding to get the sum of squared differences
- **Wrong:** Interpreting correlation as causation
  - Why it fails: Any correlation (including Spearman's) only measures association, not causal relationship. This is a common mark deduction
  - Correct: Never claim causation in your interpretation unless the question explicitly confirms it is a controlled experiment
- **Wrong:** Assigning the same lowest rank to all tied observations without averaging
  - Why it fails: This leads to incorrect rank values and wrong differences, resulting in an incorrect $r_s$
  - Correct: Always assign the average of the positions the tied observations would occupy to each tied value

## Cheatsheet

| Rule/Property | Details |
| --- | --- |
| When to use | Ranked data, non-linear monotonic relationship |
| Standard formula | r_s = 1 - \frac{6\sum d_i^2}{n(n^2 -1)} |
| Tied ranks | Assign average rank, use standard formula for IB |
| $r_s = +1$ | Perfect increasing monotonic relationship |
| $r_s = -1$ | Perfect decreasing monotonic relationship |
| $r_s = 0$ | No monotonic relationship |
| Interpretation | Always state direction + strength in context |

## What's next

Spearman's rank correlation is a key tool for bivariate data analysis that extends beyond the limitations of Pearson's linear correlation. It is commonly tested alongside hypothesis testing for correlation in IB AI HL, where you will use $r_s$ to test whether a monotonic relationship observed in sample data is statistically significant. Understanding when to use which correlation coefficient is a high-value exam skill, often assessed for 5-6 marks in both Paper 1 and Paper 2. Mastery of this topic also lays the foundation for non-parametric statistical methods you will encounter in further university study.

- [Graph theory: basic concepts](https://www.owlsprep.com/study/ib-math-ai-hl-u5-graph-theory-basic-concepts/)
- [Graph theory: adjacency matrices, paths and cycles](https://www.owlsprep.com/study/ib-math-ai-hl-u5-graph-theory-adjacency-matrices-paths/)
- [Spanning trees and minimum spanning tree algorithms](https://www.owlsprep.com/study/ib-math-ai-hl-u5-spanning-trees-and-minimum-spanning/)

---

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-hl-u5-spearman-s-rank-correlation-coefficient/
