• Foundation
  • About 22 min
  • 5 practice questions

Spearman's rank correlation

Know when rank correlation is used and calculate Spearman's coefficient when ranks are given, when ranks must be assigned, and when ranks are repeated.

If something looks wrong, please tell us.

By the end of this lesson you can

  • State the situations in which Spearman's rank correlation is used.
  • Calculate the rank correlation coefficient from given or worked-out ranks.
  • Apply the correction for repeated (tied) ranks.

Spearman's rank correlation was developed by the British psychologist C. E. Spearman. It measures the linear association between the ranks given to items rather than their values.

When to use rank correlation

  1. When variables cannot be measured for practical reasons but can be ranked: for example, ranking students by height and weight in a place with no measuring rod or scale.
  2. When at least one variable is an attribute such as honesty, fairness or beauty, which can at most be ranked, not measured.
  3. When the relationship has a clear direction but is non-linear, as in rising or falling curves.
  4. When the data contain extreme values: rank correlation is not affected by them, so here it is better than Karl Pearson's r.

Spearman's rank correlation coefficient: rs = 1 − 6ΣD² ÷ (n³ − n), where n is the number of pairs and D is the difference between the two ranks of each item. Like r, it lies between −1 and +1 and is interpreted the same way.

Because only ranks are used, some information in the data is lost, so for precisely measured data rank correlation is generally less accurate than Karl Pearson's coefficient; in general it is less than or equal to r. If the gaps between successive values were constant, the two would give identical results.

Case 1: ranks are given

Illustrative: two made-up judges rank six contestants in a debate.

ContestantJudge PJudge QD = P − QD²
112−11
22111
334−11
44311
556−11
66511
Total06

n = 6, so n³ − n = 216 − 6 = 210. rs = 1 − (6 × 6) ÷ 210 = 1 − 36 ÷ 210 = 1 − 0.171 = 0.83. The judges largely agree. If a third judge R ranked them 6, 5, 4, 3, 2, 1 (the exact reverse of P), the differences from P would be −5, −3, −1, 1, 3, 5, ΣD² = 25 + 9 + 1 + 1 + 9 + 25 = 70, and rs = 1 − 420 ÷ 210 = 1 − 2 = −1: perfect disagreement. Check: ΣD is always 0, a quick test of the ranks.

Case 2: ranks must be worked out

Illustrative marks of five made-up students. Rank each subject separately, giving rank 1 to the highest mark.

StudentEconomicsAccountancyRank in EconomicsRank in AccountancyDD²
A72682200
B58624311
C655534−11
D80751100
E50485500
Total02

n = 5, n³ − n = 125 − 5 = 120. rs = 1 − (6 × 2) ÷ 120 = 1 − 12 ÷ 120 = 1 − 0.1 = 0.9. Students who do well in Economics tend to do well in Accountancy.

Case 3: repeated (tied) ranks

When two or more items have the same value, each gets the average of the ranks they would have occupied if slightly different; the next item gets the next rank after those used. A correction factor (m³ − m) ÷ 12 is added to ΣD² for each group of m tied items:

With ties: rs = 1 − 6[ΣD² + (m1³ − m1) ÷ 12 + (m2³ − m2) ÷ 12 + ...] ÷ (n³ − n), where m1, m2, ... are the numbers of items in each tied group.

Illustrative: X = 40, 35, 35, 30, 25, 20 and Y = 15, 18, 12, 12, 10, 8 for six made-up firms. Ranks of X: 40 → 1; the two 35s share ranks 2 and 3, so each gets (2 + 3) ÷ 2 = 2.5; 30 → 4; 25 → 5; 20 → 6. Ranks of Y: 18 → 1; 15 → 2; the two 12s share 3 and 4, so each gets 3.5; 10 → 5; 8 → 6.

FirmRank of XRank of YDD²
112−11
22.511.52.25
32.53.5−11
443.50.50.25
55500
66600
Total04.5

Corrections: two tied groups, each with m = 2: (8 − 2) ÷ 12 = 0.5 each, total 1. rs = 1 − 6 × (4.5 + 1) ÷ (216 − 6) = 1 − 33 ÷ 210 = 1 − 0.157 = 0.84. A fairly strong positive rank correlation.

Karl Pearson's r and Spearman's rs

  • Karl Pearson's r
    • Uses actual values
    • Needs measurable variables
    • Affected by extreme values
    • More accurate for precisely measured data
  • Spearman's rs
    • Uses ranks
    • Works for attributes and unmeasurable variables
    • Not affected by extreme values
    • Loses some information; generally rs ≤ r

Key takeaways: Spearman's rank correlation, rs = 1 − 6ΣD² ÷ (n³ − n), is used for attributes, for variables that can be ranked but not measured, for some non-linear relations and when extreme values are present. Tied items share the average rank, and (m³ − m) ÷ 12 is added to ΣD² for each tied group. It lies between −1 and +1 and does not imply causation.

Check your understanding

  1. 1. Illustrative: for 5 pairs of ranks, ΣD² = 10. Spearman's rank correlation coefficient is:

    1. 0.9
    2. 0.5
    3. −0.5
    4. 0.1
    Show answer

    Answer: B. rs = 1 − 6ΣD² ÷ (n³ − n) = 1 − 60 ÷ (125 − 5) = 1 − 60 ÷ 120 = 1 − 0.5 = 0.5.

  2. 2. Rank correlation is the appropriate measure when studying the relation between:

    1. income and expenditure in rupees
    2. height in cm and weight in kg measured accurately
    3. price and quantity in kg
    4. honesty and punctuality of employees, as judged by a manager
    Show answer

    Answer: D. Honesty and punctuality are attributes that can be ranked but not measured, which is when Spearman's rank correlation is used.

  3. 3. Illustrative: the values 60, 55, 55, 55, 40 are ranked from highest. The rank given to each 55 is:

    1. 2
    2. 3
    3. 4
    4. 2.5
    Show answer

    Answer: B. The three 55s would occupy ranks 2, 3 and 4; each gets the average, (2 + 3 + 4) ÷ 3 = 9 ÷ 3 = 3. The value 40 then gets rank 5.

  4. 4. Illustrative: a group of 3 tied items adds a correction factor of:

    1. 2
    2. 0.5
    3. 3
    4. 24
    Show answer

    Answer: A. Correction = (m³ − m) ÷ 12 = (27 − 3) ÷ 12 = 24 ÷ 12 = 2. 24 is the numerator before dividing by 12.

  5. 5. Assertion (A): Spearman's rank correlation is preferred to Karl Pearson's r when the data contain extreme values. Reason (R): Ranks are not affected by how extreme a value is, only by its order.

    1. Both A and R are true, and R is the correct explanation of A
    2. Both A and R are true, but R is not the correct explanation of A
    3. A is true, but R is false
    4. A is false, but R is true
    Show answer

    Answer: A. Both are true, and R explains A: an extreme value simply gets the top or bottom rank, so it cannot distort the coefficient as it can distort r.

Sign in to keep track of the lessons you finish.

Next lesson → Final self-assessment: Correlation

Privacy · Terms · Refunds · Delivery