# 斯皮尔曼等级相关系数

## 定义和计算

${\displaystyle r_{s}=\rho _{\operatorname {R} (X),\operatorname {R} (Y)}={\frac {\operatorname {cov} (\operatorname {R} (X),\operatorname {R} (Y))}{\sigma _{\operatorname {R} (X)}\sigma _{\operatorname {R} (Y)}}},}$

${\displaystyle \rho }$皮尔逊积矩相关系数，但使用等级变量来计算，
${\displaystyle \operatorname {cov} (\operatorname {R} (X),\operatorname {R} (Y))}$为等级变量的协方差
${\displaystyle \sigma _{\operatorname {R} (X)}}$${\displaystyle \sigma _{\operatorname {R} (Y)}}$为等级变量的标准差

（仅示意，不使用）

（使用）
18 1 1
2.3 2 2
1.2 3 ${\displaystyle {\frac {4+3}{2}}=3.5\ }$
1.2 4 ${\displaystyle {\frac {4+3}{2}}=3.5\ }$
0.8 5 5

${\displaystyle r_{s}=1-{\frac {6\sum d_{i}^{2}}{n(n^{2}-1)}},}$

${\displaystyle d_{i}=\operatorname {R} (X_{i})-\operatorname {R} (Y_{i})}$为每组观测中两个变量的等级差值，
n为观测数。

${\displaystyle r_{s}={\frac {{\frac {1}{n}}\sum _{i=1}^{n}R_{i}S_{i}-{\overline {R}}\,{\overline {S}}}{{\sqrt {\sigma _{R}}}{\sqrt {\sigma _{S}}}}},}$

{\displaystyle {\begin{aligned}{\frac {1}{n}}\sum _{i=1}^{n}R_{i}S_{i}-{\overline {R}}{\overline {S}}&={\frac {1}{n}}\sum _{i=1}^{n}{\frac {1}{2}}(R_{i}^{2}+S_{i}^{2}-d_{i}^{2})-{\overline {R}}^{2}\\&={\frac {1}{2}}{\frac {1}{n}}\sum _{i=1}^{n}R_{i}^{2}+{\frac {1}{2}}{\frac {1}{n}}\sum _{i=1}^{n}S_{i}^{2}-{\frac {1}{2n}}\sum _{i=1}^{n}d_{i}^{2}-{\overline {R}}^{2}\\&=({\frac {1}{n}}\sum _{i=1}^{n}R_{i}^{2}-{\overline {R}}^{2})-{\frac {1}{2n}}\sum _{i=1}^{n}d_{i}^{2}\\&=\sigma _{R}^{2}-{\frac {1}{2n}}\sum _{i=1}^{n}d_{i}^{2}\\&=\sigma _{R}\sigma _{S}-{\frac {1}{2n}}\sum _{i=1}^{n}d_{i}^{2}\\\end{aligned}}}

${\displaystyle r_{s}={\frac {\sigma _{R}\sigma _{S}-{\frac {1}{2n}}\sum _{i=1}^{n}d_{i}^{2}}{\sigma _{R}\sigma _{S}}}=1-{\frac {\sum _{i=1}^{n}d_{i}^{2}}{2n\cdot {\frac {n^{2}-1}{12}}}}=1-{\frac {6\sum _{i=1}^{n}d_{i}^{2}}{n(n^{2}-1)}}.}$

## 示例

106 7
86 0
100 27
101 50
99 28
103 29
97 20
113 12
112 6
110 17

1. 排列第一列数据（${\displaystyle X_{i}}$）。创建新列 ${\displaystyle x_{i}}$ 并赋以等级值1、2、3……n
2. 然后，排列第二列数据（${\displaystyle Y_{i}}$）。创建第四列 ${\displaystyle y_{i}}$ 并相似地赋以等级值1、2、3……n
3. 创建第五列${\displaystyle d_{i}}$，填入两个等级列（${\displaystyle x_{i}}$${\displaystyle y_{i}}$）的差值。
4. 创建最后一列${\displaystyle d_{i}^{2}}$填入${\displaystyle d_{i}}$的平方。

86 0 1 1 0 0
97 20 2 6 −4 16
99 28 3 8 −5 25
100 27 4 7 −3 9
101 50 5 10 −5 25
103 29 6 9 −3 9
106 7 7 3 4 16
110 17 8 5 3 9
112 6 9 2 7 49
113 12 10 4 6 36

${\displaystyle \rho =1-{\frac {6\times 194}{10(10^{2}-1)}}}$

ρ = −0.175757575...，p-value = 0.627188（使用t分布

## 显著性的确定

${\displaystyle F(r)={1 \over 2}\ln {1+r \over 1-r}=\operatorname {arctanh} (r).}$

${\displaystyle z={\sqrt {\frac {n-3}{1.06}}}F(r)}$

rz-值，其中，r统计独立性ρ = 0[7][8]零假设下近似服从标准正态分布

${\displaystyle t=r{\sqrt {\frac {n-2}{1-r^{2}}}}}$

## 参考文献

1. Myers, Jerome L.; Well, Arnold D., Research Design and Statistical Analysis 2nd, Lawrence Erlbaum: 508, 2003, ISBN 0-8058-4037-0
2. ^ Dodge, Yadolah. The Concise Encyclopedia of Statistics. Springer-Verlag New York. 2010: 502. ISBN 978-0-387-31742-7.
3. ^ Maritz. J.S. (1981) Distribution-Free Statistical Methods, Chapman & Hall. ISBN 0-412-15940-6. (page 217)
4. ^ Al Jaber, Ahmed Odeh; Elayyan, Haifaa Omar. Toward Quality Assurance and Excellence in Higher Education. River Publishers. 2018: 284. ISBN 978-87-93609-54-9.
5. ^ Yule, G.U and Kendall, M.G. (1950), "An Introduction to the Theory of Statistics", 14th Edition (5th Impression 1968). Charles Griffin & Co. page 268
6. ^ Piantadosi, J.; Howlett, P.; Boland, J. (2007) "Matching the grade correlation coefficient using a copula with maximum disorder", Journal of Industrial and Management Optimization, 3 (2), 305–312
7. ^ Choi, S.C. (1977) Test of equality of dependent correlations. Biometrika, 64 (3), pp. 645–647
8. ^ Fieller, E.C.; Hartley, H.O.; Pearson, E.S. (1957) Tests for rank correlation coefficients. I. Biometrika 44, pp. 470–481
9. ^ Press, Vettering, Teukolsky, and Flannery (1992) Numerical Recipes in C: The Art of Scientific Computing, 2nd Edition, page 640
10. ^ Kendall, M.G., Stuart, A. (1973)The Advanced Theory of Statistics, Volume 2: Inference and Relationship, Griffin. ISBN 0-85264-215-6 (Sections 31.19, 31.21)
11. ^ Page, E. B. Ordered hypotheses for multiple treatments: A significance test for linear ranks. Journal of the American Statistical Association. 1963, 58 (301): 216–230. doi:10.2307/2282965.
12. ^ Kowalczyk, T.; Pleszczyńska E. , Ruland F. (eds.). Grade Models and Methods for Data Analysis with Applications for the Analysis of Data Populations. Studies in Fuzziness and Soft Computing vol. 151. Berlin Heidelberg New York: Springer Verlag. 2004. ISBN 978-3-540-21120-4.
• G.W. Corder, D.I. Foreman, "Nonparametric Statistics for Non-Statisticians: A Step-by-Step Approach", Wiley (2009)
• C. Spearman, "The proof and measurement of association between two things" Amer. J. Psychol., 15 (1904) pp. 72–101
• M.G. Kendall, "Rank correlation methods", Griffin (1962)
• M. Hollander, D.A. Wolfe, "Nonparametric statistical methods", Wiley (1973)
• J. C. Caruso, N. Cliff, "Empirical Size, Coverage, and Power of Confidence Intervals for Spearman's Rho", Ed. and Psy. Meas., 57 (1997) pp. 637–654