☰ 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
3

Spearman against Pearson on the same numbers, and ranking up or down: does ΣD² change?

Statistics Sec 3 Term 1, Unit 1, Lesson 1
GoalCompare Spearman’s and Pearson’s coefficients on the same numbers, and see that ranking from the largest or from the smallest gives the same ΣD².
New words
Spearman · uses only the order of the values, so it is not affected by very large or very small valuesPearson · uses the actual numbers and measures how close the dots are to a straight linesame direction · both lists must be ranked from the smallest, or both from the largest
Explanation

When the data are numbers, we can calculate both coefficients, and they usually give similar values. They differ because they answer different questions. Pearson’s r measures how well the dots follow a straight line. Spearman’s r measures how well one list follows the other in order, whatever the shape. If y increases every time x increases, Spearman gives exactly 1, even if the dots lie on a curve; Pearson gives less than 1. Spearman is also not disturbed by one extreme value, because an extreme value is just the last rank. Now the direction of ranking: if both lists are ranked from the largest instead of the smallest, every rank k becomes n + 1 − k in both lists, so every D only changes sign and D² stays the same. So ΣD² and r are unchanged, as long as both lists are ranked in the same direction. If you rank one list up and the other down, r changes sign.

xy12345671002000
Worked examples
Same numbers, two coefficients: x = 4, 6, 7, 9, 10, 13 and y = 11, 12, 15, 13, 18, 20. The ranks of x are 1 to 6; the ranks of y are 1, 2, 4, 3, 5, 6, so D = 0, 0, −1, 1, 0, 0 and ΣD² = 2. Spearman: r = 1 − 12 ÷ 210 = 0.9429. Pearson on the same numbers: 0.9054. Both say strong and direct.
A curve. The cubes y = x³ for x = 1, …, 6 are 1, 8, 27, 64, 125, 216. y always rises with x, so the ranks are identical and Spearman’s r is exactly 1. Pearson’s r is 0.9379, because the dots (see the picture) bend away from a straight line.
Pupil12345
Ranked from smallest: D20−10−1
Ranked from largest: D−20101
Ranking up or down. Take x = 8, 5, 7, 9, 6 and y = 40, 38, 45, 52, 41. From the smallest, the ranks of x are 4, 1, 3, 5, 2 and of y are 2, 1, 4, 5, 3, so D = 2, 0, −1, 0, −1 and ΣD² = 6, r = 1 − 36 ÷ 120 = 0.7. From the largest, the ranks are 2, 5, 3, 1, 4 and 4, 5, 2, 1, 3, so D = −2, 0, 1, 0, 1 and ΣD² = 6 again. Only the signs of D changed.
Class activity

Take x = 1, 2, 3, 4, 5 and y = 2, 3, 4, 5, 60. Rank both lists and find Spearman’s r. Then guess whether the one huge value 60 makes Pearson’s r much smaller than 1, and check your guess with the five sums.

Practice
1
For x = 1, 2, 3, 4, 5, 6 and y = 2, 3, 4, 5, 6, 60 what is Spearman’s r, and is Pearson’s r larger or smaller?
2
The ranks of two lists are 1, 2, 3, 4 and 4, 3, 2, 1 when ranked from the smallest. They are now ranked from the largest in both lists. What happens to ΣD²?
3
A pupil ranks list x from the smallest but list y from the largest. If both lists ranked from the smallest would give r = 0.7, what does she get?
4
When is Spearman’s coefficient preferred to Pearson’s?
5
The values y = 2, 4, 8, 16, 32 for x = 1, 2, 3, 4, 5: what is Spearman’s r?