4.10 Spearman's rank correlation

4.10 Spearman's rank correlation

IB Maths: Applications and Interpretation HL: Revision notes

Studying this course? Keep your progress in one place.

Key facts

  • Spearman's rsr_s measures how well the ranks of two variables agree: a monotonic relationship.
  • Rank both variables the same way, then find Pearson's rr of the ranks on the GDC.
  • Tied values share the average of the ranks they occupy.
  • rs=1r_s=1 for any perfectly increasing relationship, even a curve; Pearson's tests linearity only.
  • rsr_s is less sensitive to outliers than Pearson's rr.

Ranking data

Rank each variable the same way, then find Pearson's coefficient of the two lists of ranks.

Pearson's rr measures closeness to a straight line. Spearman's rank correlation coefficient rsr_s measures how well the ranks agree, so it tests for a monotonic relationship: always increasing or always decreasing.

Rank each variable separately (rank 1 for the highest, for both). Then find Pearson's coefficient of the ranks on the GDC. −1≤rs≤1-1\le r_s\le1, read like rr.

Maths marks 45,60,72,38,55,8045,60,72,38,55,80 and physics marks 52,58,80,40,61,7552,58,80,40,61,75 give rs=0.886r_s=0.886.

  1. 1

    Rank variable 1

    rank 1 for the highest

  2. 2

    Rank variable 2

    the same way

  3. 3

    GDC

    Pearson's rr of the two rank lists

  4. 4

    Interpret

    direction and strength, in context

Finding Spearman's coefficient

Worked example

Maths marks 45,60,72,38,55,8045,60,72,38,55,80 and physics marks 52,58,80,40,61,7552,58,80,40,61,75. Find rsr_s.

Both variables are ranked from the highest. rs=−0.9r_s=-0.9 means...

Tied values

Tied values share the average of the ranks they would have taken.

When two or more items are equal, they share the ranks they would have taken, and each gets the average of those ranks.

Scores 9,8,7,6,5,5,49,8,7,6,5,5,4 ranked from the highest: the two 5s would take ranks 5 and 6, so each gets 5+62=5.5\frac{5+6}{2}=5.5. The next value, 4, takes rank 7. Three equal values taking ranks 2, 3, 4 would each get 3.

Then use the GDC on the two lists of ranks as before.

02468ABCDEFItemValue
  • Score
  • Rank
Scores and ranks (rank 1 = highest): the three 5s share rank 4

Score

A:
8
B:
7
C:
5
D:
5
E:
5
F:
4

Rank

A:
1
B:
2
C:
4
D:
4
E:
4
F:
6

Worked example

Scores 9,8,7,6,5,5,49,8,7,6,5,5,4 are ranked from the highest. Give the ranks.

Three equal scores would have taken ranks 4, 5 and 6. What rank does each get?

Pearson's or Spearman's?

Pearson's tests linearity; Spearman's tests any monotonic relationship.

Pearson's rr is suitable when the scatter diagram is close to a straight line. Spearman's rsr_s tests any monotonic relationship, linear or curved.

Bacteria counts 2,4,9,17,31,52,85,1402,4,9,17,31,52,85,140 at hours 11 to 88 always rise. The ranks are identical, so rs=1r_s=1. But the growth is curved, so Pearson's gives only r=0.911r=0.911.

So r<1r<1 does not mean the variables are unrelated; it may mean the relationship is not linear. Look at the scatter diagram first. A relationship that rises then falls is not monotonic.

Pearson's rr

Tests for:
A linear relationship
Uses:
Actual values
Sensitive to outliers:
More

Spearman's rsr_s

Tests for:
Any monotonic relationship
Uses:
Ranks only
Sensitive to outliers:
Less
02040608010012014012345678HourBacteria count
Bacteria count always rises, so the relationship is monotonic but curved.

A curve always rises. Which is 11?

Effect of outliers

Spearman's uses only ranks, so an outlier counts just as the highest or lowest rank.

An outlier is a point far from the others. Pearson's rr uses the actual values, so one outlier can change it greatly. Spearman's uses only ranks, so an outlier counts only as the highest or lowest rank.

Eight students' revision hours are 2,4,5,6,8,9,10,302,4,5,6,8,9,10,30 with scores 40,52,50,58,64,70,75,4540,52,50,58,64,70,75,45. The student with 30 hours is an outlier. With all eight, r=−0.0948r=-0.0948 and rs=0.476r_s=0.476. Without that student, r=0.987r=0.987 and rs=0.964r_s=0.964.

Even rsr_s is pulled down. Investigate outliers; do not delete them without a reason.

00.20.40.60.81Pearson's rSpearman's rsCoefficientValue
  • All eight students
  • Without the 30-hour student
Removing the outlier changes Pearson's r by about 1.08 but Spearman's by about 0.49.

Why is Spearman's less affected by an extreme point?

Interpreting and limitations

State direction and strength in context, and remember it shows association, not cause.

State the direction and strength of rsr_s, and give your conclusion in context: "students who rank highly in maths tend to rank highly in physics".

Limits:

  • Correlation does not prove one variable causes the other.
  • rsr_s describes only monotonic relationships; check the scatter diagram.
  • Small samples can mislead, and many tied ranks reduce reliability.
  • It ignores how far apart values are, only their order.
0.511.522.533.54102030405060xyy = eˣ
A monotonic but curved relationship: always increasing, so Spearman's r_s = 1, but the points do not lie on a straight line so Pearson's r < 1

Use Pearson's when

Shape:
Data roughly linear
Outliers:
No outliers

Use Spearman's when

Shape:
Curved but monotonic
Outliers:
Outliers present

Which data suit Spearman's better?

Try an exam question

Five students sit two tests. Test 1 scores: 12,15,9,20,1712,15,9,20,17. Test 2 scores: 30,28,22,40,3530,28,22,40,35. Find Spearman's rank correlation coefficient and interpret it.

[4 marks]

That's the notes covered.

Carry on to the next subtopic.

Try a question

What is the physics rank of the student who scored 6161?

1 mark, marked against the mark scheme

Revision notes