Correlation and Regression
Spearman's Rank Coefficient of Correlation

This is a method used to assign a meaning to the correlation between pairs of data points.
Such a coefficient, call it r, is designed so that

−1 ≤ r ≤ 1

and r = −1 corresponds to perfect negative correlation, r = 0 to no correlation and r = 1 to perfect positive correlation (as illustrated below).

Spearman's rank correlation coefficient is based on the squares of the differences between data points when they have been ranked – that is, put in numerical order and then given the values 1, 2, 3, ..., etc. The formula is

r=1-\frac{6\sum_{\ }^{\ }d^2}{n(n^2-1)}

Here n is the number of data points and d the difference between values

You will see a justification for this in the final worked example, but first we will see how to use the formula.

Worked Examples

1

At the Deepdale 'Best of British Pie' competition two judges award marks for nine different pies as follows:

PieABCDEFGHI
Judge 1182423132719301020
Judge 27189417829510
(a)

What do the scores tell you about the two judges?

Show me The first judge appears to be using much higher scores than the second judge.
(b)
(i)

Calculate Spearman's coefficient of rank correlation between the two judges.

Show me

We first find the 'ranks' and then the differences, and square them (note that squaring a negative number results in a positive value).

PieABCDEFGHI
Judge 1182423132719301020
Judge 27189417829510
Rank 1376284915
Rank 2385174926
d0–111100–1–1
d2011110011

Summing the d^2 gives

\sum_{\ }^{\ }d^2 = 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 1 = 6

and, using the formula,

r=1-\frac{6\sum_{\ }^{\ }d^2}{n(n^2-1)} with \sum_{\ }^{\ }d^2 = 6 and n = 9 gives

r=1-\frac{6\times6}{9\times80}=1-0.05=0.95

(ii)

What does your result tell you about the judges' decision?

Show me

The value of r is very close to 1, showing that there is highly positive correlation between the two judges' rankings (but not in their actual scores).

2

An investigation was conducted by a company on the value of various assessment methods for recruiting employees. The data are shown in this table.

EmployeeEducational Test
Score
Assessment Score
by Personnel
Officer
A912
B1014
C1516
D1415
E1617
F1110
G1211
H1718

This is based on 8 employees, giving their educational test scores, together with an assessment score by the Personnel Officer of their ability one year after joining the company. Possible test scores in each case can range from a low of 1 to a high of 20.

(a)

Rank each employee in terms of Educational Test score and Assessment score by the Personnel Officer.

Show me
EmployeeEducational Test
Score
Assessment Score
by Personnel
Officer
RERAdd2
A91213–24
B101424–24
C15166600
D14155500
E16177700
F11103124
G12114224
H17188800
(b)

Hence for these scores calculate, to 2 decimal places, the Spearman rank correlation coefficient.

Show me

n = 8 and \sum_{\ }^{\ } d^2 = 16, so

r = 1 - \frac{6 × 16}{8 × 63} = 1 - 0.19 = 0.81

(c)

The recruits also took an aptitude test and the comparable value for the rank coefficient based on aptitude test score and assessment score by the Personnel Officer was –0.21.

With reference to this result and your answer in (b) comment on the effectiveness of the tests in providing the Personnel Officer with an indication of the suitability of applicants for employment.

Show me

The educational test seems to work well (fairly positive correlation) but the aptitude test does not work well (slightly negative correlation).

3

In a music festival, each competitor is judged on his performance on two different musical instruments. The judge awards marks out of 100 for each instrument, as follows.

CompetitorABCDEF
1st Instrument907562707556
2nd Instrument957664768660
(a)

Complete a table of ranks.

Show me
CompetitorABCDEF
1st Instrument907562707556
2nd Instrument957664768660
Rank 112.5542.56
Rank 213.553.526

(Note that we have marked the highest rather than the lowest as 1; this is not a problem provided that both sets of rankings are done in the same way.

Also, if there are two tied ranks, we use the average of the two values, here 2 and 3, so we use 2.5 for each.)

The rank correlation coefficient for these data was found to be 0.96.

It was later discovered that the marks from one of the judges, for one competitor, had been misread. This competitor should have had 10 more marks on his second instrument.

The mark was changed and on recalculation it was found that the correlation coefficient remained the same at 0.96.

(b)
(i)

Which competitor's mark was originally incorrect?

Show me

Competitor C

(ii)

Give a reason for your answer.

Show me

Only the '64' entry (i.e. competitor C, 2nd instrument) will not have their rank affected by an increase of 10 marks. Hence competitor C must have the incorrect mark.

4

For sets of paired data, find the value of \sum_{\ }^{\ }d^2 for

(i) perfect positive correlation,

(ii) perfect negative correlation when n = 2, 3, 4, . . . , 8 .

Hence deduce Spearman's rank correlation coefficient formula, assuming it is of the form

r = 1 - k \sum_{\ }^{\ }d^2

Show me

Assume that Spearman's correlation coefficient takes the form

r=1-k\sum_{\ }^{\ }d^2

(since this gives r = 1 when \sum_{\ }^{\ }d^2 = 0, i.e. perfect positive correlation).

Now the constant k will depend on n (the number of data points) and must be chosen so that when there is perfect negative correlation, then r = -1 ; i.e.

-1=1-k\sum_{\ }^{\ }d^2\ ⇒\ k=\frac{2}{\sum_{\ }^{\ }d^2}

Tabulating the values obtained gives

n\sum_{\ }^{\ }d^2
22
38
420
540
670
7112
8168

from which you can see that fits these values. (You could in fact first deduce that it is a cubic expression since the third differences are constant, and then fit a general cubic to the data.)

Hence, using the formula for \sum_{\ }^{\ }d^2,

k=\frac{6}{n(n^2-1)}

and

r=1-\frac{6\sum_{\ }^{\ }d^2}{n(n^2-1)}

(which is Spearman's formula).

Exercises

There was a vacancy for a typist at Betterprint.

Six people applied for the job.

The manager gave each applicant a test, which consisted of typing a page of writing.
Marks were awarded for the speed and for the accuracy of the typing.

The following table shows the results of the test.

(a)

Complete the following table of ranks.

ABCDEF
Rank Time
Rank errors
d
d2
(b)

Given that Spearman's rank correlation coefficient is

1-\frac{6\sum_{\ }^{\ }d^2}{n(n^2-1)}

use the table to calculate this coefficient for these data.

(c)

To which applicant should the manager offer the typist vacancy?

Mrs Maden is a wine expert. At a wine tasting evening she is asked to taste the wines of a producer taken from each of ten different years and place them in order of quality. She regards 1983 as the best drink and ranks it 1.

Calculate Spearman's coefficient of rank correlation between the age and the quality of the wine. The formula for calculating Spearman's rank correlation coefficient is

p=1-\frac{6\sum_{\ }^{\ }d^2}{n(n^2-1)}

p =

The following table shows the positions in a Sunday league of 8 cricket clubs at the end of a season together with the average attendances (in hundreds) at their home matches during the season.

(a)

Complete the table.

ClubABCDEFGH
Position in league13627854
Average attendance3412183215252719
Rank of attendance18
Difference in ranks (d)05
d2025
(b)

Using the formula 1-\frac{6\sum_{\ }^{\ }d^2}{n(n^2-1)} calculate Spearman's rank correlation coefficient for these data.

(c)

Explain what the value you have calculated in (b) shows.

(d)

If the value of the rank correlation coefficient had been +0.95 describe what this would have implied in relation to position in the league and average league attendance for each club.