IB Applications and Interpretation SL · Regression and linear correlation · Section 4 of 4

Spearman's rank correlation coefficient

3 worked examples · By Álvaro López

Key idea

Pearson's coefficient only detects linear relationships. Spearman's, , measures something broader: whether one variable always increases (or always decreases) when the other increases, even if the rate of change varies. To do this it does not use the data values themselves, but their positions in an ordering (the ranks). In the IB exam you are asked to calculate (by hand or with the GDC) and to interpret it in context.

Monotonic relationships and ranks

A relationship is monotonic increasing if, as one variable increases, the other never decreases; it is monotonic decreasing if the other never increases. Every linear relationship is monotonic, but the reverse is not true: a curve that rises ever more steeply is monotonic without being a straight line.

That is why Pearson's coefficient can be far from for a curve that rises without ever falling, whereas Spearman's rates it at the maximum.

Scatter diagram of eight points forming an increasing curve that rises ever more steeply, from (1, 2) to (8, 130); Pearson r = 0.852 and Spearman rs = 1

A concrete case: the values ordered from largest to smallest are ; they receive the ranks .

Spearman's coefficient

How to read it:

  • : the ranks coincide in every pair; as increases, always increases (a perfect increasing monotonic relationship).
  • : the ranks are completely reversed; as increases, always decreases.
  • close to : the positions of one variable say almost nothing about the positions of the other.
  • The closer to , the stronger the association; the sign gives the direction. Describe it with the same words as for Pearson: positive or negative, and strong, moderate or weak.

The formula makes sense: if all the ranks coincide, all the differences are and . The more the orderings disagree, the larger becomes and the lower falls.

When to use Spearman and when to use Pearson

  • Pearson when the scatter of points looks like a straight line and the data are measured numerical values. It measures the strength of the linear relationship.
  • Spearman when the relationship looks monotonic but curved, when the data are ordinal (positions, rankings, ratings from 1 to 10) or when there is an extreme value that would distort Pearson. Because it works with positions, an odd value counts for much less.

If the relationship is linear and has no extreme values, the two coefficients come out similar. If is much larger in absolute value than , that is a sign of a monotonic but non-linear relationship.

Worked examples

Example 1 Basic

Practice hours and results

Seven members of a chess club record the hours they train each week () and the points they scored in a tournament ():

Student A B C D E F G
Hours 12 7 15 9 4 10 6
Points 78 65 71 60 52 84 58

a) Assign ranks to each variable (rank for the largest value) and calculate .

b) Calculate Spearman's coefficient and describe it.

Solution

a) Ordering from largest to smallest, the ranks of the hours are: . Those of the points are: .

Student A B C D E F G
Rank 2 5 1 4 7 3 6
Rank 2 4 3 5 7 1 6
0 1 0 2 0
0 1 4 1 0 4 0

b) With :

There is a strong positive association between training hours and points: in general, those who train more score more, although the order does not match exactly.

Example 2 Medium

Tied ranks

Eight students record the hours they spent studying for an exam () and the mark they obtained out of 100 ():

(hours) 3 5 8 5 10 2 8 6
(mark) 40 55 70 62 66 35 70 52

a) With rank for the largest value, what rank does each of the two students who studied for 8 hours receive?

b) Calculate Spearman's coefficient, using as the Pearson coefficient of the ranks.

Solution

a) Ordered from largest to smallest, the hours are . The two 8s occupy positions and , so each receives .

b) Do the same with both variables. The two 5s of occupy positions and (rank ), and the two 70s of occupy positions and (rank ):

Rank 7 5.5 2.5 5.5 1 8 2.5 4
Rank 7 5 1.5 4 3 8 1.5 6

Using the GDC, enter these two lists of ranks, ask for the linear regression and read off the correlation coefficient:

There is a strong positive association between hours of study and marks.

(Check: , and the formula would give , a very close value but not exact, because there are ties.)

Example 3 Hard

A decline that is not a straight line

A coffee shop chain studies six branches. For each one it records the distance to the city centre (, in km) and the mean number of customers per day ():

Distance (km) 2 4 5 7 9 12
Customers 95 60 50 28 22 15

a) Calculate Spearman's coefficient.

b) Using the GDC, calculate Pearson's correlation coefficient for the original data.

c) Explain why the two coefficients do not coincide.

d) The director concludes: “Moving a branch away from the centre makes it lose customers.” Does the data support that conclusion?

Solution

a) With rank for the largest value, the ranks of are and those of are . The differences are , and With :

b) Entering the two lists of original data into the GDC and asking for the linear regression:

c) Customers always fall as the distance increases: the relationship is a perfect monotonic decrease, which is why . But the fall is rapid at first and then levels off; the scatter is a curve, not a straight line. Pearson's coefficient measures the fit to a straight line, which is why it comes out at : strong, but not perfect.

d) No. The data show a very strong negative association, but with only six branches and without controlling for other factors (rent, competition, office area) a cause-and-effect relationship cannot be claimed.

In the exam: give the numerical value to 3 significant figures and always interpret the sign and the strength in context. If you are asked to compare Pearson and Spearman, the answer that earns marks is that indicates a perfect monotonic relationship whereas does not, because the relationship is not linear. In cause-and-effect questions, do not claim causation.

Common mistakes

Summary

  • Spearman's coefficient measures the strength and direction of a monotonic relationship using the ranks of the data, not the data values themselves.
  • Ranks: order the values with the same convention for and ; if there are ties, each tied value is given the mean of the positions it occupies.
  • Formula, without ties: , with the difference of ranks for each pair and the number of pairs.
  • : is a perfect monotonic relationship (increasing or decreasing), and means no association between the ranks.
  • With ties (or in Paper 2), calculate Pearson's coefficient of the ranks with the GDC: that value is .
  • Use Spearman's for curved but monotonic relationships, ordinal data or extreme values; use Pearson's for linear relationships. Association is not causation.
Maths classes in Aldaia and online

Want to work on it together?

Free first consultation: we look at your level and your exam, and build a plan. Álvaro replies on WhatsApp.

Message us on WhatsApp