Spearman's rank correlation coefficient is a measure of rank correlation under the following circumstance; n individuals are ranked from 1 to n according to some specified characteristics by 2 observers. and we wish to know if the 2 rankings are substantially in agreement with one another.rs = 1 indicates complete agreement in order of ranks and rs = -1 indicates complete agreement in the opposite order of the ranks.z is approximately a standardized normal variable (for large n; say n >= 10)-- Prepare test dataDECLARE @Stats TABLE (PersonID INT, Rank1 INT, Rank2 INT)INSERT @StatsSELECT 1, 6, 7 UNION ALLSELECT 2, 14, 11 UNION ALLSELECT 3, 3, 4 UNION ALLSELECT 4, 1, 2 UNION ALLSELECT 5, 11, 8 UNION ALLSELECT 6, 15, 15 UNION ALLSELECT 7, 4, 1 UNION ALLSELECT 8, 2, 9 UNION ALLSELECT 9, 9, 6 UNION ALLSELECT 10, 10, 10 UNION ALLSELECT 11, 5, 5 UNION ALLSELECT 12, 8, 13 UNION ALLSELECT 13, 13, 12 UNION ALLSELECT 14, 7, 3 UNION ALLSELECT 15, 12, 14-- Set up environmentDECLARE @n INT, @z FLOAT, @rs FLOAT-- Number of observationsSELECT @n = COUNT(PersonID)FROM @Stats-- Do the calculationsSELECT @rs = 1.0E - 6.0E * SUM(1.0E * POWER(Rank1 - Rank2, 2.0E) / @n / (POWER(@n, 2.0E) - 1.0E)), @z = @rs * SQRT(@n - 1.0E)FROM @StatsSELECT @rs, @z
Peter LarssonHelsingborg, Sweden