Menu
Sign up Sign in

AI HL · 13.4

Hypothesis Testing

13.4.7

Spearman's rank correlation

13.4.7

Spearman's rank correlation

Target: I can rank data, sharing the average rank between tied values, and find Spearman's r_s on the calculator. (+4 more)

By the end of this section

Key points

What r_s measures

  • Spearman's rank correlation coefficient r_s is Pearson's correlation of the ranks of the data. It lies between −1 and 1.
  • r_s measures how well the ranks agree: whether y tends to rise (or fall) as x rises, even if the points lie on a curve.
  • r_s = 1 means the ranks are identical. r_s = −1 means they are exactly reversed. Near 0 means no relationship in the ranks.
  • Pearson's r only measures straight-line correlation. Use r_s when the pattern is not straight, or when the data are ranks or grades.

Ranking the data

  • Give rank 1 to the smallest value. Rank each variable separately.
  • Tied values each get the average of the ranks they would have shared. Two values tied for 2nd and 3rd both get 2.5.
  • From two judges' ordered lists, find each competitor in each list. Their position is their rank. Then pair the two ranks of each competitor.
  • Do not pair 1st with 1st down the lists. Pair by competitor.

Testing with r_s

  • H0: there is no correlation between the two variables. H1 is positive correlation, negative correlation, or (two-tailed) correlation.
  • A critical value is given. Positive test: reject H0 if r_s is greater than the critical value. Negative test: reject H0 if r_s is less than minus the critical value. Two-tailed: reject if |r_s| is greater.
  • Write the conclusion in context. To test whether two markers agree, test for positive correlation between their marks.
  • A strong correlation shows a tendency. Do not write 'always', and do not say one variable causes the other.

Outliers and units

  • r_s uses only the order of the values, so it is less affected by an outlier than Pearson's r.
  • If a point is moved but keeps the same rank, r_s does not change. Pearson's r may change a lot.
  • Multiplying or dividing a variable by a positive number does not change the order, so r_s does not change.

On the calculator

Spearman's r_s from two lists

  • Rank each list, giving tied values the average rank.
  • Enter the two rank lists. Find the correlation of the ranks.
  • Read r_s. Check its sign against the pattern in the data.

Screenshot and video to come

Ranks from judges' lists

  • For each competitor, find the place given by each judge.
  • Enter the two rank lists in the same competitor order.
  • Find the correlation of the ranks.

Screenshot and video to come

Explore: Spearman's rank correlation

Drag a point on the top diagram, or change the numbers in the table. The ranks are worked out for you and drawn below, and Pearson's r and Spearman's rₛ are found side by side. Then add one extreme point.

xyRank of xRank of y

Pearson's r
Spearman's rₛ

Change a number in the table.

  1. Drag a point a little way without passing another point. Why does rₛ stay the same when r changes? Now drag it past a neighbour.
  2. Make two x values equal. What rank does each get? Do the ranks still add up to n(n + 1)/2?
  3. Press "Add an extreme point". Which of r and rₛ changes more? Look at the rank diagram: how far from the others is the new point?
  4. Press "Use a curve that always rises". Why is rₛ exactly 1 when r is not?

Worked examples

Problems like the ones in class. Pick one, try it, then open the working.
Spearman's coefficient with no ties

A dealer records the age of eight used cars and the price asked for each. Find Spearman's rank correlation coefficient.

Pair12345678Age (years)25386174Price (£000)14.57.912.15.29.816611
Working
  1. agepriceRank of ageRank of price214.52757.953312.13685.28169.86411618767241145
    Rank each variable

    Ranks of age: 2, 5, 3, 8, 6, 1, 7, 4 Ranks of price: 7, 3, 6, 1, 4, 8, 2, 5

    Rank 1 is the smallest value. Rank each list separately.

  2. Correlate the ranks

    From the calculator: r_s = −0.976

    The calculator has a Spearman option. It correlates the ranks for you.

  3. Interpret

    Strong negative correlation: older cars tend to cost less.

    r_s is close to −1, so the ranks are almost reversed. It is not exactly −1: two cars are out of order.

Video walkthrough coming
Tied values

Eight students sit a mathematics test and a music test. The marks are shown. Find Spearman's rank correlation coefficient.

Pair12345678Maths5662567148656280Music4045384535504745
Working
  1. mathsmusicRank of mathsRank of music56402.5362454.5556382.5271457548351165506862474.57804585
    Average the tied ranks

    Ranks of maths: 2.5, 4.5, 2.5, 7, 1, 6, 4.5, 8 Ranks of music: 3, 5, 2, 5, 1, 8, 7, 5

    Two 56s would take ranks 2 and 3, so each gets 2.5. Three 45s take ranks 4, 5 and 6, so each gets 5.

  2. Correlate the ranks

    From the calculator: r_s = 0.704

    Enter the ranks as two lists and find the correlation, or use the Spearman option.

  3. Interpret

    Moderate to strong positive correlation: students who do well in maths tend to do well in music.

    Say 'tend to'. A correlation does not mean one mark causes the other.

Video walkthrough coming
From two ordered lists

Two judges place eight dancers, A to H, in order. Each list shows the dancers from 1st place to 8th place. Find Spearman's rank correlation coefficient between the judges' placings.

Place1st2nd3rd4th5th6th7th8thJudge 1CAFBHDEGJudge 2ACBFDHGE
Working
  1. DancerABCDEFGHJudge 124167385Judge 213258476
    Rank for each dancer

    Judge 1 ranks A to H: 2, 4, 1, 6, 7, 3, 8, 5 Judge 2 ranks A to H: 1, 3, 2, 5, 8, 4, 7, 6

    Find each dancer in each list. Dancer C is 1st for Judge 1 (rank 1) and 2nd for Judge 2 (rank 2).

  2. Correlate the ranks

    From the calculator: r_s = 0.905

    Put the two rank lists in the calculator, in the same dancer order.

  3. Interpret

    The judges largely agree.

    A value near 1 means the judges placed the dancers in nearly the same order.

Video walkthrough coming
A one-tailed test for positive correlation

Nine students record the hours they spent revising for a test and their marks. Use Spearman's rank correlation to test, at the 5% significance level, whether there is a positive correlation between hours and mark. The critical value for this test is 0.600.

Pair123456789Hours352864715Mark486245807152664158
Working
  1. Hypotheses

    H0: there is no correlation between hours revised and mark. H1: there is a positive correlation between hours revised and mark.

    'Positive correlation' makes the test one-tailed.

  2. Calculate r_s

    Ranks of hours (the two 5s share 5.5): 3, 5.5, 2, 9, 7, 4, 8, 1, 5.5 From the calculator: r_s = 0.979

    The tied hours share an average rank.

  3. Compare

    r_s = 0.979 > 0.600, so reject H0.

    For a positive test, reject H0 if r_s is greater than the critical value.

  4. In context

    There is sufficient evidence, at the 5% significance level, of a positive correlation between hours revised and mark.

    Write the conclusion about hours and marks.

Video walkthrough coming
A one-tailed test for negative correlation

The table shows the number of students taking Chemistry HL and Art HL in seven schools. Use Spearman's rank correlation to test, at the 10% significance level, whether there is a negative correlation between the numbers. The critical value for this test is 0.571.

Pair1234567Chemistry21182516231820Art69511788
Working
  1. Hypotheses

    H0: there is no correlation between the numbers taking Chemistry and the numbers taking Art. H1: there is a negative correlation between the numbers taking Chemistry and the numbers taking Art.

    'Negative correlation' makes the test one-tailed, in the negative direction.

  2. Calculate r_s

    Ranks of Chemistry: 5, 2.5, 7, 1, 6, 2.5, 4 Ranks of Art: 2, 6, 1, 7, 3, 4.5, 4.5 From the calculator: r_s = −0.936

    Both lists have ties, so use average ranks.

  3. Compare

    r_s = −0.936 < −0.571, so reject H0.

    For a negative test, reject H0 if r_s is less than minus the critical value.

  4. In context

    There is sufficient evidence, at the 10% significance level, of a negative correlation between the numbers taking Chemistry and the numbers taking Art.

    Schools with more Chemistry students tend to have fewer Art students.

Video walkthrough coming
A two-tailed test

A teacher records the number of hours of homework set (x) and the time each of eight students spent on social media (y, hours a week). She tests, at the 5% significance level, whether there is any correlation between them. The critical value for this two-tailed test is 0.738.

Pair12345678Homework121592017111418Social media3022352826243331
Working
  1. Hypotheses

    H0: there is no correlation between homework hours and social media time. H1: there is a correlation between homework hours and social media time.

    'Any correlation' means the test is two-tailed: H1 allows positive or negative.

  2. Calculate r_s

    From the calculator: r_s = −0.238

    Rank both lists first if you are entering ranks.

  3. Compare

    |r_s| = 0.238 < 0.738, so do not reject H0.

    In a two-tailed test, compare the size of r_s, ignoring the sign, with the critical value.

  4. In context

    There is insufficient evidence, at the 5% significance level, of a correlation between homework hours and social media time.

    Do not say there is no correlation. Say there is insufficient evidence of one.

Video walkthrough coming
Do two markers agree?

Two examiners mark seven essays out of 20. Test, at the 5% significance level, whether the examiners tend to agree. The critical value for this one-tailed test is 0.714.

Pair1234567Examiner 11417111691315Examiner 215161218131015
Working
  1. Hypotheses

    H0: there is no correlation between the examiners' marks. H1: there is a positive correlation between the examiners' marks.

    Agreeing means that a high mark from one goes with a high mark from the other: positive correlation, one-tailed.

  2. Calculate r_s

    Ranks of Examiner 1: 4, 7, 2, 6, 1, 3, 5 Ranks of Examiner 2: 4.5, 6, 2, 7, 3, 1, 4.5 From the calculator: r_s = 0.811

    The marks 15 and 15 for Examiner 2 are tied.

  3. Compare

    r_s = 0.811 > 0.714, so reject H0.

    A positive one-tailed test.

  4. In context

    There is sufficient evidence, at the 5% significance level, that the two examiners tend to agree.

    Agreement means a positive correlation between the two sets of marks.

Video walkthrough coming
An outlier, and changing units

For the ten points shown, Pearson's r = 0.712 and Spearman's r_s = 0.964. The highest point, (16, 150), was recorded wrongly. Its correct value is (16, 48). (a) Without calculating, say how the new value of r compares with the old value. (b) Without calculating, say how the new value of r_s compares with the old value. (c) The values of y are converted from grams to kilograms. How does this change r_s?

5101520406080100120140160xy
Working
  1. 51015102030405060xy
    Pearson's r

    r increases, closer to 1.

    The point (16, 150) was far above the rest. Once it is moved onto the pattern, the points lie closer to a straight line.

  2. Spearman's r_s

    r_s stays the same: 0.964.

    The point was the largest y before and is still the largest y after (48 is more than 41). No rank changes, so r_s does not change. This is why r_s is less affected by outliers.

  3. Changing units

    r_s does not change.

    Dividing every y by 1000 keeps the order of the values, so the ranks are the same.

Video walkthrough coming