Study Guide

Spearman's rank correlation coefficient

IB Mathematics: Applications and Interpretation HLΒ· 5.10 Bivariate statisticsΒ· 15 min read

1. When to use Spearman's $r_s$β˜…β˜…β˜†β˜†β˜†β± 4 min

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.

πŸ“˜ Definition

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.

πŸ“ 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. 1

    Check the type of relationship: it is increasing (monotonic) but non-linear.

  2. 2

    Pearson's only measures linear relationships, so it will underestimate the true strength of association.

  3. 3

    Conclusion: The researcher should use Spearman's rank correlation coefficient.

2. Calculation for untied ranksβ˜…β˜…β˜…β˜†β˜†β± 8 min

βœ“ Calculator OK

πŸ“˜ Definition

Spearman's rank correlation (untied ranks)

rsr_s

Calculated using the standard formula:

rs=1βˆ’6βˆ‘di2n(n2βˆ’1)r_s = 1 - \frac{6\sum d_i^2}{n(n^2 - 1)}

Where:

  • = difference between the ranks of the -th pair of observations
  • = 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 between the two ranks for each pair

  3. Square each and sum all squares to get

  4. Substitute values into the formula to find

πŸ“ Worked Example

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

  1. 1

    Rank maths from highest to lowest: [2, 5, 1, 6, 4, 3]

  2. 2

    Rank physics from highest to lowest: [1, 4, 2, 6, 5, 3]

  3. 3

    Calculate differences : , , , , ,

  4. 4

    Square differences: , , , , ,

  5. 5

    Sum of squared differences:

  6. 6
    βˆ‘di2=1+1+1+0+1+0=4\sum d_i^2 = 1 + 1 + 1 + 0 + 1 + 0 = 4
  7. 7

    Substitute into formula ():

  8. 8
    rs=1βˆ’6Γ—46(62βˆ’1)=1βˆ’24210β‰ˆ0.886r_s = 1 - \frac{6 \times 4}{6(6^2 - 1)} = 1 - \frac{24}{210} \approx 0.886

3. Handling tied ranksβ˜…β˜…β˜…β˜†β˜†β± 5 min

βœ“ Calculator OK

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. 1

    Sort times from fastest to slowest: 12.1, 12.1, 12.2, 12.3, 12.5

  2. 2

    The two 12.1s occupy positions 1 and 2. Assign each the average rank:

  3. 3

    Final ranks: 1.5, 3, 4, 1.5, 5

4. Interpreting $r_s$β˜…β˜…β˜†β˜†β˜†β± 4 min

Like Pearson's , always ranges between and . The sign indicates the direction of the monotonic relationship, and the absolute value indicates the strength.

Value of

Strength of association

Very weak

Weak

Moderate

Strong

Perfect monotonic

πŸ“ Worked Example

In the earlier maths/physics test example, we got . Interpret this value in context.

  1. 1

    The value of is positive, so there is a positive relationship: higher ranks in maths are associated with higher ranks in physics.

  2. 2

    The absolute value of is greater than , so this is a strong positive monotonic relationship between maths and physics test performance.

5. Common Pitfalls

Wrong move:

Using Pearson's correlation when Spearman's is required

Why:

Pearson only measures linear relationships, so it will give an incorrect result for ranked or non-linear monotonic data

Correct move:

Always check if the question mentions ranks or if the relationship is non-linear, use Spearman's in these cases

Wrong move:

Ranking one variable from lowest to highest and the other from highest to lowest, leading to wrong sign on

Why:

Reversing rank direction for one variable flips the sign of the final result, which will lose marks for interpretation

Correct move:

Always rank both variables in the same direction, and check that the sign of makes sense in context

Wrong move:

Forgetting to square differences before summing

Why:

This leads to an incorrect value of and wrong final

Correct move:

Always square each difference before adding to get the sum of squared differences

Wrong move:

Interpreting correlation as causation

Why:

Any correlation (including Spearman's) only measures association, not causal relationship. This is a common mark deduction

Correct move:

Never claim causation in your interpretation unless the question explicitly confirms it is a controlled experiment

Wrong move:

Assigning the same lowest rank to all tied observations without averaging

Why:

This leads to incorrect rank values and wrong differences, resulting in an incorrect

Correct move:

Always assign the average of the positions the tied observations would occupy to each tied value

6. Quick Reference 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

Perfect increasing monotonic relationship

Perfect decreasing monotonic relationship

No monotonic relationship

Interpretation

Always state direction + strength in context

When this came up on past exams

AI-estimated based on syllabus patterns β€” cross-check with official past papers for accuracy. Use only as revision-focus signals.

  • 2025 Β· 1

    6 mark calculation of r_s

  • 2024 Β· 2

    Interpret r_s in context

  • 2023 Β· 1

    Compare Spearman's vs Pearson's

Going deeper

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 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.