排序题分析
计算公式
符号
| 符号 | 含义 |
|---|---|
| n | 有效作答份数 |
| m | 被排对象数 |
| rij | 第 i 份作答给对象 j 的名次 |
| Rj | 对象 j 的名次合计 |
| S | 名次合计与平均名次的离差平方和 |
| Ti | 第 i 份作答内的结校正项 |
| W | Kendall's W 一致性系数 |
| χ2 | 与 W 对应的卡方统计量 |
| ptopt | 对象进入前 t 名的比例 |
核心公式
公式 (1.1):平均名次与名次合计
\[
\bar R_{j}=\frac{1}{n}\sum_{i=1}^{n}r_{ij},\qquad R_{j}=\sum_{i=1}^{n}r_{ij}
\]
公式 (1.2):Kendall's W(含结校正)
\[
W=\frac{12S}{n^{2}(m^{3}-m)-n\sum_{i=1}^{n}T_{i}},\qquad S=\sum_{j=1}^{m}\left(R_{j}-\frac{n(m+1)}{2}\right)^{2},\qquad T_{i}=\sum_{t}(t^{3}-t)
\]
公式 (1.3):W 的卡方检验
\[
\chi^{2}=n(m-1)W,\qquad \mathrm{df}=m-1
\]
公式 (1.4):首位率与前 t 名比例
\[
p_{j}^{\mathrm{first}}=\frac{\#\{i:r_{ij}=1\}}{n},\qquad p_{j}^{\mathrm{top}\,t}=\frac{\#\{i:r_{ij}\le t\}}{n}
\]
参考文献
- Kendall, M. G., & Babington Smith, B. (1939). The problem of m rankings. The Annals of Mathematical Statistics, 10(3), 275–287.
- Friedman, M. (1937). The use of ranks to avoid the assumption of normality implicit in the analysis of variance. Journal of the American Statistical Association, 32(200), 675–701.
- Siegel, S., & Castellan, N. J. (1988). Nonparametric statistics for the behavioral sciences (2nd ed.). McGraw-Hill.
算法参数
| 参数 | 取值 | 默认 | 影响 |
|---|---|---|---|
| 名次方向 | 名次越小越靠前 / 分数越高越靠前 | 名次越小越靠前 | 选择“分数越高越靠前”时按 m+1−x 翻转,平均名次与 W 的方向随之改变。 |
验证报告
数据与 R 包
提示词
O1–O5 是 60 位受访者对 5 个对象的排序(1 = 最靠前),做排序题分析。
R 代码
library(DescTools)
d <- read.csv("ranking.csv")
m <- as.matrix(d)
cat("n", nrow(m), "m", ncol(m), "\n")
print(colMeans(m), digits = 15)
print(apply(m, 2, median), digits = 15)
print(colMeans(m == 1), digits = 15)
print(colMeans(m <= 2), digits = 15)
print(colMeans(m <= 3), digits = 15)
print(KendallW(t(m), correct = TRUE, test = TRUE))
对比结果
| 指标 | SPSSAU | R | 差值 |
|---|---|---|---|
| Kendall's W | 0.5807777778 | 0.5807777778 | 2.22e−11 |
| χ² | 139.3866666667 | 139.3866666667 | 3.3e−11 |
| 自由度 | 4 | 4 | 0 |
| O1 平均名次 | 1.3833333333 | 1.3833333333 | 3.33e−11 |
| O5 平均名次 | 4.5166666667 | 4.5166666667 | 3.33e−11 |
| O1 首位率(%) | 70.0000000000 | 70.0000000000 | 0 |
| O5 前二率(%) | 5.0000000000 | 5.0000000000 | 0 |
结论:Kendall's W、χ²、自由度、平均名次、首位率与前二率均与 R 一致,最大差 3e−11。名次按“1 = 最靠前”理解;数据无并列名次,W 的结校正项为 0。
引用SPSSAU. 排序题分析:计算公式与参数[EB/OL]. SPSSAU算法手册, 2026-11-20. https://www.spssau.com/algorithm/questionnaire/ranking.html.