☰ Year plan · Statistics

Spearman’s rank correlation

Week 3 · Spearman’s rank correlation coefficient: ranks, tied values, D² and the formula, and when to use it instead of Pearson’s · 3 lessons
2

Spearman’s formula r = 1 − 6ΣD² ÷ n(n² − 1): the table of ranks, the differences D and D²

Statistics Sec 3 Term 1, Unit 1, Lesson 1
GoalCalculate Spearman’s coefficient from a table of ranks, the differences D and D².
New words
Spearman’s coefficient · r = 1 − 6ΣD² ÷ n(n² − 1), the correlation of two lists of ranksD · the difference between the two ranks of one itemΣD² and the check ΣD = 0 · the squared differences are added; the plain differences add to zero
Explanation

To find how well two lists agree in order, rank each list in the same direction, then for every item find D, the difference between its two ranks. If the two orders are identical every D is 0. The more the orders disagree, the larger the squared differences D² become, so we add them and put the total into Spearman’s formula r = 1 − 6ΣD² ÷ n(n² − 1), where n is the number of items. Identical orders give ΣD² = 0 and r = 1; completely reversed orders give r = −1. The squares are used so that positive and negative differences cannot cancel. The plain differences always add up to 0, which is a quick check on your ranks. A note: the formula is exact when there are no ties; with ties it is a good approximation, and that is how it is used in our book. The table shows two judges scoring eight pies at a school fair (out of 10). Here ΣD² = 6.5, n = 8, and n(n² − 1) = 8 × 63 = 504, so r = 1 − 6 × 6.5 ÷ 504 = 1 − 39 ÷ 504 = 0.9226.

PieJudge 1Judge 2Rank 1Rank 2DD²
17653.51.52.25
2542.520.50.25
3987611
46745−11
58967−11
6562.53.5−11
710108800
8431100
ΣD = 0ΣD² = 6.5
Worked examples
Identical orders: ranks 1, 2, 3, 4 for both lists. Every D = 0, so ΣD² = 0 and r = 1 − 0 = 1. Both judges put the items in the same order.
The pie table, step by step. The two 5’s of judge 1 share places 2 and 3 (rank 2.5); judge 2’s two 6’s share places 3 and 4 (rank 3.5). The differences D are 1.5, 0.5, 1, −1, −1, −1, 0, 0 (sum 0), and D² are 2.25, 0.25, 1, 1, 1, 1, 0, 0 (sum 6.5). Then r = 1 − 39 ÷ 504 = 0.9226.
Reading the result. r = 0.9226 is positive and close to 1: the two judges agree strongly about the order of the pies. It says nothing about the actual scores: judge 2 may simply be a stricter judge.
Class activity

Two friends each rank five school subjects from their favourite (1) to their least favourite (5), without ties. Find D for each subject, check that ΣD = 0, and calculate r. Do they agree?

Practice
1
The ranks 1, 2, 3, 4, 5, 6 are paired with 2, 1, 4, 3, 6, 5. Find ΣD² and r.
2
For n = 5 and ΣD² = 14, find r.
3
The ranks of x are 1, 2, 3, 4, 5 and the ranks of y are 5, 4, 3, 2, 1. Find r.
4
A pupil’s differences D add up to 2. What does that tell you?
5
Two judges rank six pies. Judge 1: 1, 2, 3, 4, 5, 6. Judge 2: 1, 3, 2, 4, 6, 5. Find D, ΣD² and r.