Spearman's rank correlation
In a minute
, , measures how well two rankings agree. You rank each variable, then your GDC finds 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 .
You'll be able to
- Rank a set of data, giving tied values the mean of the ranks they share.
- Find on your GDC from the ranks, with no formula or proof needed, and interpret it in context.
- Choose between Pearson's (straight-line links only) and (any link that always rises or always falls).
- Explain why an changes less than it changes .
Before you start3 quick questions on what this builds on
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 Rank can be the smallest or the largest value, but rank both variables the same way.
Try it first, then reveal one step at a time.
- Put them in order: .
- The two s would take ranks and . Each gets .
- Then is rank , is , is and is .
- Write each rank under its phone, in the original order: .
- Check: .
- In the original order, the ranks are 4, 1.5, 6, 1.5, 5, 3.
Try it first, then reveal one step at a time.
- Order from highest: .
- is rank . The two s take ranks and , so each gets .
- The three s take ranks , and , so each gets .
- Then is rank and is rank .
- In the original order: . They add up to .
- In the original order, the ranks are 5, 2.5, 7, 5, 1, 5, 8, 2.5.
Finding Spearman's coefficient
means the two rankings are identical: as one variable increases, the other always increases. means one ranking is the exact reverse of the other. A value near means the rankings show no clear agreement.
Find 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 it shows is .
Try it first, then reveal one step at a time.
- (a) The data are already ranks, with no ties. Enter P's ranks in one list and Q's ranks in another.
- Run linear regression on the two lists: , so .
- (b) is positive and close to : strong agreement. Cakes one judge rated highly, the other judge tended to rate highly too.
Try it first, then reveal one step at a time.
- (a) Hours: the two s take ranks and , so each gets . Hours ranks: .
- Times have no ties. Time ranks: .
- (b) Enter the two lists of ranks and run linear regression: , so .
- (c) Strong negative: swimmers who train more hours tend to have lower times, so they tend to be faster.
Pearson or Spearman?
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.
Try it first, then reveal one step at a time.
- (a) Linear regression on the data: .
- The area rises every day, so the area ranks are , the same as the day ranks. So .
- (b) The points curve upwards (diagram below), so a straight line is a poor fit. is better: it shows the area always increases with time.
Ranks also limit the effect of an . However extreme a value is, its rank can only be the top or bottom one. So is less sensitive to outliers than .
Try it first, then reveal one step at a time.
- (a) Rank both: is already in order, so its ranks are to . Time ranks: .
- Regression on the two lists of ranks: .
- (b) Regression on the raw data gives : only moderate. Yet seven of the points lie close to a rising line.
- The -minute order is an outlier (diagram below), and it drags down. In the ranks it just becomes rank , so still shows a strong positive trend: longer distances tend to take longer.
- Without that order, and . The outlier moved far more than .
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 and near . And neither coefficient shows that one variable causes the other.
Common mistakes
- Giving tied values different ranks, such as and . Tied values share the mean of their ranks: each.
- Ranking one variable from the smallest and the other from the largest. That flips the sign of , so rank both the same way.
- Running linear regression on the raw values. That gives Pearson's ; for 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 a measure of linear correlation. It measures how well the rankings agree: a monotonic trend.
- Rounding too early or too far, such as for . Give to 3 s.f.
Exam tips
- Interpret : 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 , then your conclusion. A conclusion with no reason earns no marks.
- If the question gives a table of strengths for , use its words ("moderate", "strong") in your answer.
Key takeaways
Practise this
23 past-paper questions on Correlation and regression in the AI HL bank, each with a mark scheme and a worked explanation.