The Spearman Correlation of two sets of n numbers, say xj and yj (where j goes from 1 to n) is defined as the Pearson Correlation of the Ranks. If the numbers in each set are not repeated, then the Ranks for each set are just a reordering of the numbers 1, 2, 3, ... n.
Because the ranks are just the numbers 1, 2, 3, ... n, then the Mean of the Ranks isjust: [1] M = (1/n)(1+2+3+...+n) = (1/2) [ n(n+1)/2 ] = (n+1)/2
using the magic formula: 1+2+3+...+n = n(n+1)/2
For our n = 5 example, the numbers are 8, 17, 2, 5, 12 then their Ranks are 3, 1, 5, 4, 2 and the Mean of the Ranks is (5+1)/2 = 3. Furthermore, the Standard Deviation, S, of the Ranks can calculated like so (provided the ranks are not repeated): We know that S2 = (average of the squares) - (square of the average)
... see SD stuff,
[2] S2 = (1/n)Σ k2 - M2
= (1/n)[ n(n+1)(2n+1)/6 ] - M2 = (n+1)(2n+1)/6 - [(n+1)/2]2 = (n2 - 1)/2
The Pearson Correlation for two sets of numbers (say uj and vj) is R, defined by [3] SD[u] SD[v] R
= (1/n)Σ (uj-M[u]) (vj-M[v])
However, if we're talking about Ranks, then both the u-set and v-set are just reordering of the same numbers 1, 2, 3, ... n (provided the ranks are not repeated!!) and that means that M[u] = M[v] = M and that SD[u] = SD[v] = S ... given by [2], above. Then we may calculate R, the Pearson Correlation of Ranks (that's the Spearman Correlation!) from: [4] S2R
= (1/n)Σ (uj-M) (vj-M)
= (1/n)Σ ujvj
- (M/n)Σ uj - (M/n)Σ vj
+ (1/n)Σ M2
= (1/n)Σ ujvj - M2
Given the sequence of Ranks, we could use [4] to calculate the Spearman Correlation
(provided the ranks are not repeated!!).
Consider the average of the squares of the differences in the Ranks: [5] (1/n)Σ (uj - vj)2 = (1/n)Σ uj2 + (1/n)Σ vj2 - (2/n)Σ ujvj = (2/n)Σ k2 - (2/n)Σ ujvj But (1/n)Σ k2 = S2 + M2 from [2], above and we have expressions for both S and S in terms of the number n ... so we can (eventually) write:
P.S. If the ranks are repeated (meaning the original variables are not all different), then just use the Pearson Correlation of Ranks
|