Spearman's rank correlation coefficient

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In mathematics and statistics, Spearman's rank correlation coefficient is a measure of correlation, named after its maker, Charles Spearman. It is written in short as the Greek letter rho (\rho) or sometimes as r_s. This means that it is a number that shows how closely two sets of data are linked. It only can be done on data that can be put in order, highest to lowest.

The general formula for r_s is \rho=1-\cfrac {6\sum d^2}{n(n^2-1)}.

For example, if you have data for how expensive different computers are, and data for how fast the computers are, you could see if they are linked, and how closely they are linked, using r_s.

Working it out[change | edit source]

Step one[change | edit source]

To work out r_s you first have to rank each piece of data. We are going to use the example from the intro of computers and their speed.

So, the computer with the lowest price would be rank 1. The one higher than that would have 2. Then, it goes up until it is all ranked. You have to do this to both sets of data.[1]

PC Price ($) Rank_1 Speed (GHz) Rank_2
A 200 1 1.80 2
B 275 2 1.60 1
C 300 3 2.20 4
D 350 4 2.10 3
E 600 5 4.00 5

Step two[change | edit source]

Next, we have to find the difference between the two ranks. Then, you multiply the difference times itself, which is called squaring the number. The difference is called d, and to show when you square d, you write d^2.[1]

Rank_1 Rank_2 d d^2
1 2 -1 1
2 1 1 1
3 4 -1 1
4 3 1 1
5 5 0 0

Step three[change | edit source]

Count how much data we have. This data has ranks 1 to 5, so we have 5 pieces of data. This number is called n.[1]

Step four[change | edit source]

Finally, use everything we have worked out so far in this formula:  r_s=1-\cfrac {6\sum d^2}{n(n^2-1)}.

\sum d^2 means that we take the total of all the numbers that were in the column d^2. This is because \sum means total.

So, \sum d^2 is 1+1+1+1 which is 4. The formula says multiply it by 6, which is 24.

n(n^2-1) is 5*(25-1) which is 120.

So, to find out r_s, we simply do 1-\cfrac {24}{120} = 0.8 .

Therefore, Spearman's rank correlation coefficient is 0.8 for this set of data.

What the numbers mean[change | edit source]

This scatter graph has positive correlation. The r_s value would be near 1 or 0.9. The red line is a line of best fit.

r_s always gives an answer between −1 and 1. The numbers between are like a scale, where −1 is a very strong link, 0 is no link, and 1 is also a very strong link. The difference between 1 and −1 is that 1 is a positive correlation, and −1 is a negative correlation. A graph of data with a r_s value of −1 would look like the graph shown except the line and points would be going from top left to bottom right.

For example, for the data that we did above, r_s was 0.8. So this means that there is a positive correlation. Because it is close to 1, it means that the link is strong between the two sets of data. So, we can say that those two sets of data are linked, and go up together. If it was −0.8, we could say it was linked and as one goes up, the other goes down.

If two numbers are the same[change | edit source]

Sometimes, when ranking data, there are two or more numbers that are the same. When this happens in r_s, we take the mean or average of the ranks that are the same. These are called tied ranks. To do this, we rank the tied numbers as if they were not tied. Then, we add up all the ranks that they would have, and divide it by how many there are.[2] For example, say we were ranking how well different people did in a spelling test.

Test score Rank Rank (with tied)
4 1 1
6 2 \tfrac {2+3+4}{3} = 3
6 3 \tfrac {2+3+4}{3} = 3
6 4 \tfrac {2+3+4}{3} = 3
8 5 \tfrac {5+6}{2} = 5.5
8 6 \tfrac {5+6}{2} = 5.5

These numbers are used in exactly the same way as normal ranks.

Related pages[change | edit source]

Notes and references[change | edit source]