算法手册/ 实验/医学研究/ 多样本Friedman

多样本Friedman

计算公式

符号

符号含义
n有效样本(行)数
k重复测量条件数
Rij第 i 行内第 j 个条件的秩
Rj第 j 个条件的秩和
t同一行内某个结包含的条件数
WKendall's W(和谐系数)

核心公式

公式 (1.1):逐行排秩后的 Friedman 统计量
\[ \chi^2=\frac{12}{nk(k+1)}\sum_{j=1}^{k}R_j^2-3n(k+1) \]
公式 (1.2):结校正
\[ C=1-\frac{\sum_t\left(t^3-t\right)}{n\left(k^3-k\right)},\qquad \chi_c^2=\frac{\chi^2}{C} \]
公式 (1.3):p 值、Kendall's W 与效应量
\[ p=P\left(\chi^2_{k-1}\ge\chi_c^2\right),\qquad W=\frac{\chi_c^2}{n(k-1)},\qquad \text{effect size}=\frac{\chi_c^2}{k(n-1)} \]

参考文献

  1. 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.
  2. Kendall, M. G., & Babington Smith, B. (1939). The problem of m rankings. Annals of Mathematical Statistics, 10(3), 275–287.
  3. Field, A. (2018). Discovering Statistics Using IBM SPSS Statistics (5th ed.). Sage.

算法参数

参数取值默认影响
事后比较 不做事后比较 / Nemenyi / Conover / Conover-Bonferroni / Siegel / Miller 不做事后比较 总体 χ² 显著后用于定位哪几个条件不同;本次验证不开启事后比较。

验证报告

数据与 R 包

数据文件 friedman.csv
样本与变量 N = 36;Y1、Y2、Y3 为同一批对象的三个重复测量条件
R 包 stats 4.6.2(R 基础包)

提示词

对 Y1、Y2、Y3 三个重复测量条件做 Friedman 检验,给出 χ²、自由度、p、Kendall's W 与效应量,不做事后比较,结果保留 10 位小数。

R 代码

options(digits = 15)
d <- read.csv("friedman.csv")
m <- as.matrix(d[, c("Y1", "Y2", "Y3")])
r <- friedman.test(m)
print(r, digits = 15)
n <- nrow(m); k <- ncol(m)
cat("chi", r$statistic, "df", r$parameter,
    "W", r$statistic / (n * (k - 1)),
    "effect", r$statistic / (k * (n - 1)), "\n")
cat("medians", apply(m, 2, median), "\n")
cat("rbar", colMeans(t(apply(m, 1, rank))), "\n")

对比结果

指标SPSSAUR差值
样本量36360
条件数3.00000000003.00000000000
χ² 值11.555555555611.55555555564.44e−11
自由度220
p 值3.095587e−33.095587e−36.68e−9
Kendall's W0.16049382720.16049382723.95e−11
效应量0.11005291010.11005291014.71e−11
中位数 Y153.837431500053.83743150000
中位数 Y255.312535500055.31253550000
中位数 Y354.936230500054.93623050000
秩均值 Y11.55555555561.55555555564.44e−11
秩均值 Y22.11111111112.11111111111.11e−11
秩均值 Y32.33333333332.33333333333.33e−11

结论:χ²、自由度、p 值、Kendall's W、效应量、三个条件的中位数与秩均值均与 R 一致;差值列均为 10 位小数输出带来的舍入误差。

操作手册 问题反馈

引用SPSSAU. 多样本Friedman:计算公式与参数[EB/OL]. SPSSAU算法手册, 2026-11-20. https://www.spssau.com/algorithm/general/friedman.html.