# Spearman's rank correlation coefficient

> IB Mathematics Applications and Interpretation SL · IB Math AI SL
> Source: https://www.owlsprep.com/study/ib-math-ai-sl-u4-spearman-s-rank-correlation-coefficient/

This module covers definition, step-by-step calculation, tied rank adjustment, interpretation and exam application of Spearman's rank correlation coefficient for non-linear bivariate data.

**Prerequisites:** [Pearson's product moment correlation coefficient](https://www.owlsprep.com/study/ib-math-ai-sl-u4-pearson-correlation/); [Bivariate data and scatter diagrams](https://www.owlsprep.com/study/ib-math-ai-sl-u4-bivariate-scatterplots/)

## Learning objectives

- Calculate Spearman's rank correlation coefficient for bivariate data with and without tied ranks
- Interpret r_s values to assess the strength and direction of monotonic association
- Distinguish Spearman's rank from Pearson's product moment correlation coefficient
- Apply the method to exam-style bivariate datasets to earn full method marks

## Core Definition and Purpose of Spearman's Rank

Spearman's rank correlation coefficient is a non-parametric measure of association that works by converting raw data values into ranks, removing the requirement for a linear relationship between variables. It is ideal for datasets where you expect a consistent increasing or decreasing trend, but not a perfect straight line.

**Spearman's rank correlation coefficient** — A statistical value between -1 and +1 that quantifies the strength and direction of monotonic association between two ranked bivariate variables

*Notation:* $r_s$

*Example:* An $r_s$ value of 0.92 indicates a strong positive trend where higher values of one variable almost always correspond to higher values of the other

> **info**
>
> Unlike Pearson's r, Spearman's r_s does not require data to be normally distributed, making it suitable for ordinal survey data and skewed datasets.

**Worked example:** Identify which of the following datasets is better suited for Spearman's rank: A) Heights and weights of 20 teenagers, B) Customer satisfaction ratings (1-5) and product price for 15 items

1. Evaluate dataset A: Heights and weights typically have a roughly linear relationship, so Pearson's r is appropriate
2. Evaluate dataset B: Satisfaction ratings are ordinal, and the relationship to price is not guaranteed to be linear, so Spearman's rank is the correct choice

## Step-by-Step Calculation for Untied Ranks

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

1. Rank all x values from 1 (smallest) to n (largest)
2. Rank all corresponding y values from 1 to n
3. Calculate the difference $d_i$ between the x rank and y rank for every paired observation
4. Square each $d_i$ value to get $d_i^2$
5. Sum all $d_i^2$ values to get $\sum d_i^2$
6. Substitute the sum into the standard Spearman's rank formula to get $r_s$

**Worked example:** Calculate $r_s$ for the following 4 paired data points: (2,5), (4,7), (6,10), (8,9)

1. Rank x values: 2=1, 4=2, 6=3, 8=4
2. Rank y values: 5=1,7=2,9=3,10=4
3. Calculate $d_i$ values: 1-1=0, 2-2=0, 3-4=-1, 4-3=1
4. Calculate $d_i^2$ values: 0, 0, 1, 1. Sum = 2
5. Substitute into formula: $r_s = 1 - \frac{6 \times 2}{4(16-1)} = 1 - \frac{12}{60} = 0.8$

**Check your understanding**

1. What is the maximum possible value of $\sum d_i^2$ for n=5?

   *Why:* Maximum sum occurs when ranks are perfectly reversed, sum of squares is 16+9+4+1+0 = 30? No wait, for n=5 reversed ranks, d_i values are 4,2,0,-2,-4, sum of squares 16+4+0+4+16=40, correct.

*Calculator:* allowed

## Adjusting for Tied Ranks in Datasets

When two or more data points have identical values, you cannot assign different ranks to them. Instead, you assign the average of all the rank positions that the tied values occupy. For 2 tied values at positions 3 and 4, both get a rank of 3.5.

> **Exam tip**
>
> IB exam mark schemes accept the standard simplified formula even for small numbers of tied ranks, as long as you correctly assign average ranks to tied entries. You do not need to use the complex adjusted Spearman's formula for AI SL assessments.

**Worked example:** Assign ranks to the following x values: [12, 15, 15, 18]

1. The smallest value 12 occupies position 1, so rank = 1
2. The two 15 values occupy positions 2 and 3. Average rank = (2+3)/2 = 2.5 for both entries
3. The largest value 18 occupies position 4, so rank = 4

## Interpretation and Comparison to Pearson's r

**Exam command terms**

IB exams use specific command terms for correlation questions, with clear marking expectations:

- **Describe the correlation** — State both the direction (positive/negative) and strength (strong/moderate/weak) of the association

- **Compare Spearman's and Pearson's coefficients** — Explicitly note that Spearman's measures monotonic association while Pearson's measures linear association

**Comparing methods**

- **Spearman's Rank $r_s$** — Uses ranked data, works for non-linear trends, suitable for ordinal and skewed data
  - Pros: Robust to outliers, no normality assumption
  - Cons: Does not measure linear relationship strength

- **Pearson's $r$** — Uses raw continuous data, only measures linear association
  - Pros: More precise for linear datasets
  - Cons: Sensitive to outliers, requires normal distribution

## Common pitfalls

- **Wrong:** Using Pearson's r formula instead of Spearman's for non-linear monotonic data
  - Why it fails: Pearson's r will underestimate the true strength of association for non-linear trends
  - Correct: Use Spearman's rank whenever you only expect a consistent increasing/decreasing trend, not a straight line relationship
- **Wrong:** Assigning different ranks to tied data points
  - Why it fails: Produces artificially large $d_i$ values and incorrect final $r_s$
  - Correct: Assign the mean of all occupied rank positions to every tied entry
- **Wrong:** Rounding intermediate $d_i^2$ values to 1 decimal place early
  - Why it fails: Cumulative rounding error makes your final $r_s$ fall outside the acceptable mark range
  - Correct: Keep all intermediate values unrounded until you calculate the final $r_s$
- **Wrong:** Claiming $r_s = 1$ proves a perfect linear relationship
  - Why it fails: Spearman's r_s only measures perfect monotonic association, not linearity
  - Correct: State that $r_s = 1$ means one variable strictly increases as the other increases, regardless of the shape of the trend
- **Wrong:** Applying Spearman's rank to fewer than 5 paired observations
  - Why it fails: The coefficient becomes extremely sensitive to random variation and is not statistically meaningful
  - Correct: Confirm you have at least 6 paired data points before performing the calculation

## Cheatsheet

| Step | Untied Ranks Action | Tied Ranks Action | Interpretation Rule |
| --- | --- | --- | --- |
| 1 | Rank x values 1 to n | Assign average rank to tied x values | $r_s = 1$ = perfect positive monotonic association |
| 2 | Rank y values 1 to n | Assign average rank to tied y values | $r_s = 0$ = no monotonic association |
| 3 | Calculate $d_i = rank(x_i) - rank(y_i)$ | Use adjusted ranks to find $d_i$ | $r_s = -1$ = perfect negative monotonic association |
| 4 | Sum all $d_i^2$ values | Sum adjusted $d_i^2$ values | 0.7 < $\|r_s\|$ ≤ 1 indicates strong correlation |

## What's next

Now that you have mastered Spearman's rank correlation, you can apply this non-parametric skill to a wide range of exam scenarios, from ordinal survey data to skewed environmental measurements. This topic is frequently tested in both Paper 1 and Paper 2, so ensure you practice full calculation sequences without skipping steps to avoid losing method marks. Next, you will build on your understanding of correlation to learn linear regression, which lets you create predictive models for bivariate datasets with confirmed linear association. You will also explore hypothesis testing to confirm if an observed correlation value is statistically significant rather than due to random chance.

---

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