4.10 · SLPaper 1Paper 2

Spearman's rank correlation

In a minute

, rsr_s, measures how well two rankings agree. You rank each variable, then your GDC finds rsr_s from the ranks. Use it when the data are ranks, when the link is curved but always rising or always falling, or when an would distort Pearson's rr.

You'll be able to

  • Rank a set of data, giving tied values the mean of the ranks they share.
  • Find rsr_s on your GDC from the ranks, with no formula or proof needed, and interpret it in context.
  • Choose between Pearson's rr (straight-line links only) and rsr_s (any link that always rises or always falls).
  • Explain why an changes rsr_s less than it changes rr.
Before you start3 quick questions on what this builds on
Check yourself
Find the of 44, 99, 1111 and 1515.
Check yourself
Points on a follow a clear U-shaped curve, and r=0.04r = 0.04. What can you conclude?
Check yourself
A data set has Q1=20Q_1 = 20 and Q3=28Q_3 = 28. Find the value above which a data point is an outlier.

Revise first: 4.1 Sampling, data quality and outliers, 4.2 Data presentation and 4.4 Correlation and regression (y on x)

Ranking data and tied ranks

Two judges place seven cakes in order. There are no measurements, only positions: 1st, 2nd, 3rd and so on. To see whether the judges agree, you compare their rankings.

Measured data can be ranked too. Put the values in order and number them 1,2,3,…1, 2, 3, \ldots Rank 11 can be the smallest or the largest value, but rank both variables the same way.

Worked exampleSix phones last these times, in hours, on one charge: 11.511.5, 9.09.0, 14.014.0, 9.09.0, 12.512.5, 10.010.0. Rank the times, with rank 11 for the shortest.

Try it first, then reveal one step at a time.

  1. Put them in order: 9.0,9.0,10.0,11.5,12.5,14.09.0, 9.0, 10.0, 11.5, 12.5, 14.0.
Worked exampleEight films have these average ratings: 7.27.2, 8.18.1, 6.56.5, 7.27.2, 9.09.0, 7.27.2, 5.85.8, 8.18.1. Rank them, with rank 11 for the highest rating.

Try it first, then reveal one step at a time.

  1. Order from highest: 9.0,8.1,8.1,7.2,7.2,7.2,6.5,5.89.0, 8.1, 8.1, 7.2, 7.2, 7.2, 6.5, 5.8.
Check yourself
Five hotel reviews score 33, 77, 77, 77 and 1010. With rank 11 for the lowest score, what rank does each 77 get?
Check yourself
Five cyclists ride 4040, 5555, 5555, 6161 and 7070 km. With rank 11 for the longest distance, what rank does each 5555 get?

Finding Spearman's coefficient

Learn this
−1≤rs≤1-1 \le r_s \le 1

rs=1r_s = 1 means the two rankings are identical: as one variable increases, the other always increases. rs=−1r_s = -1 means one ranking is the exact reverse of the other. A value near 00 means the rankings show no clear agreement.

Find rsr_s with your GDC. You don't need a formula for it, or a proof. Some books give a shortcut formula; it is only exact when there are no ties, so use the GDC.

1. Rank each variable separately, both in the same direction, averaging tied ranks.

2. Enter the two lists of ranks and run linear regression. The rr it shows is rsr_s.

Worked exampleTwo judges rank seven cakes, A to G, with rank 11 for the best. Judge P: A 33, B 11, C 44, D 22, E 66, F 55, G 77. Judge Q: A 22, B 11, C 55, D 33, E 77, F 44, G 66. (a) Find rsr_s. (b) Interpret it in context.

Try it first, then reveal one step at a time.

  1. (a) The data are already ranks, with no ties. Enter P's ranks 3,1,4,2,6,5,73, 1, 4, 2, 6, 5, 7 in one list and Q's ranks 2,1,5,3,7,4,62, 1, 5, 3, 7, 4, 6 in another.
Check yourself
Two food critics rank the same nine restaurants, and rs=−0.94r_s = -0.94. Which statement is correct?
Worked exampleA coach records, for eight swimmers, the hours trained per week xx and their best 100100 m time yy seconds. xx: 6,9,4,12,9,7,10,56, 9, 4, 12, 9, 7, 10, 5. yy: 69.8,66.8,73.5,67.9,68.4,70.3,64.1,72.669.8, 66.8, 73.5, 67.9, 68.4, 70.3, 64.1, 72.6. (a) Rank both variables, with rank 11 for the smallest. (b) Use your GDC to find rsr_s. (c) Interpret rsr_s in context.

Try it first, then reveal one step at a time.

  1. (a) Hours: the two 99s take ranks 55 and 66, so each gets 5.55.5. Hours ranks: 3,5.5,1,8,5.5,4,7,23, 5.5, 1, 8, 5.5, 4, 7, 2.
Check yourself
For the swimmers, a student ranks hours with 11 for the fewest, but times with 11 for the slowest. What value of rsr_s does the student get?
Check yourself
Five plants have heights 12,15,9,20,1712, 15, 9, 20, 17 cm and 30,41,28,39,4530, 41, 28, 39, 45 leaves. Find rsr_s, to 3 s.f.

Pearson or Spearman?

rr measures how close the points are to a straight line. Some links are clearly curved, yet one variable still always rises as the other rises.

Worked exampleThe area of a patch of mould is measured on days 11 to 66: 3,5,9,16,30,553, 5, 9, 16, 30, 55 cm². (a) Find rr and rsr_s. (b) Which describes the relationship better? Give a reason.

Try it first, then reveal one step at a time.

  1. (a) Linear regression on the data: r=0.919722…≈0.920r = 0.919722\ldots \approx 0.920.
Scatter diagram of mould area in square centimetres against day, for days 1 to 6. The six points rise more and more steeply along a curve: 3, 5, 9, 16, 30 and 55. A dashed straight regression line runs through them; the middle points lie below it and the end points above it. 1 2 3 4 5 6 0 10 20 30 40 50 60 day x area y (cm²) Always rising: rs = 1 Not a straight line: r ≈ 0.920
Always rising, so rs=1r_s = 1. Not a straight line, so r<1r < 1.

Ranks also limit the effect of an . However extreme a value is, its rank can only be the top or bottom one. So rsr_s is less sensitive to outliers than rr.

Worked exampleA delivery app records the distance xx km and the delivery time yy minutes for eight orders. xx: 1.5,3,4.5,6,7.5,9,10.5,121.5, 3, 4.5, 6, 7.5, 9, 10.5, 12. yy: 17,29,24,31,87,37,39,4417, 29, 24, 31, 87, 37, 39, 44. One order was held up by a road closure. (a) Use your GDC to find rsr_s. (b) Explain why rsr_s describes the trend better than rr.

Try it first, then reveal one step at a time.

  1. (a) Rank both: xx is already in order, so its ranks are 11 to 88. Time ranks: 1,3,2,4,8,5,6,71, 3, 2, 4, 8, 5, 6, 7.
Scatter diagram of delivery time in minutes against distance in kilometres for eight orders. Seven points rise steadily from 17 minutes at 1.5 kilometres to 44 minutes at 12 kilometres. One point, 87 minutes at 7.5 kilometres, sits far above the rest and is circled as an outlier. 2 4 6 8 10 12 14 0 20 40 60 80 100 distance x (km) time y (min) outlier: 87 min
One outlier pulls rr down to 0.4550.455; rsr_s stays at 0.8330.833.

Spearman's has limits too. It ignores how far apart the values are, only their order. A link that rises then falls can give both rr and rsr_s near 00. And neither coefficient shows that one variable causes the other.

Check yourself
The points on a scatter diagram rise steeply at first, then more and more slowly, but never fall. There are no outliers. Which statement is true?
Check yourself
In the swimmers' data, the fastest time, 64.164.1 s, is mistyped as 54.154.1 s. What happens to rsr_s?

Common mistakes

  • Giving tied values different ranks, such as 22 and 33. Tied values share the mean of their ranks: 2.52.5 each.
  • Ranking one variable from the smallest and the other from the largest. That flips the sign of rsr_s, so rank both the same way.
  • Running linear regression on the raw values. That gives Pearson's rr; for rsr_s the lists must hold the ranks.
  • Copying ranks from a table that lists items in finishing order. Write each item's rank under that item before you enter the lists.
  • Calling rsr_s a measure of linear correlation. It measures how well the rankings agree: a monotonic trend.
  • Rounding too early or too far, such as 0.830.83 for 0.8333…0.8333\ldots. Give rsr_s to 3 s.f.

Exam tips

  • Interpret rsr_s: give its strength and direction, then say what it means for the variables in context, such as "cakes one judge ranked highly, the other ranked highly too".
  • Comment on whether a claim is supported: give a reason based on the value of rsr_s, then your conclusion. A conclusion with no reason earns no marks.
  • If the question gives a table of strengths for rsr_s, use its words ("moderate", "strong") in your answer.

Key takeaways

Learn thisRank each variable separately, both in the same direction. Tied values each get the mean of the ranks they share.
Learn thisrsr_s is Pearson's rr calculated on the ranks. On the GDC: enter the two lists of ranks, run linear regression, read rr.
Learn this−1≤rs≤1-1 \le r_s \le 1. rs=1r_s = 1: the rankings are identical. rs=−1r_s = -1: one is the exact reverse of the other.
Learn thisPearson's rr measures only linear correlation. rsr_s measures any monotonic relationship, straight or curved.
Learn thisrsr_s is less sensitive to outliers than rr: an extreme value can only take the top or bottom rank.
Learn thisA link that rises then falls can give rr and rsr_s near 00, and neither coefficient shows causation.

Practise this

23 past-paper questions on Correlation and regression in the AI HL bank, each with a mark scheme and a worked explanation.

Practise Correlation and regression →