算法手册/ 通用方法/ JT趋势检验

JT趋势检验

计算公式

符号

符号含义
k按组序排列的组数
ni第 i 组的样本量
N合计样本量
UJonckheere-Terpstra 统计量
yia第 i 组第 a 个观测
Ra观测 a 在合并样本中的平均秩
ta与观测 a 同值的观测个数(含自身)
qa、sa结校正的中间量
ai、bi第 i 组之前、之后各组的样本量之和
epair、eshare组对部分与组内秩部分的系数
Φ(·)标准正态分布的累积分布函数

核心公式

公式 (1.1):按组序的组对比较累加
\[ U=\sum_{1\le i\lt j\le k}\sum_{a=1}^{n_i}\sum_{b=1}^{n_j}\left[I\left(y_{ia}\lt y_{jb}\right)+\frac12I\left(y_{ia}=y_{jb}\right)\right] \]
公式 (1.2):期望与结校正方差
\[ E(U)=\frac{N^2-\sum_{i=1}^{k}n_i^2}{4} \]
公式 (1.3):结校正的精确零分布方差
\[ \begin{aligned} q_a&=\frac{N-t_a}{4},\qquad s_a=\frac{2R_a-N-1}{2},\\ e_{\mathrm{pair}}&=\frac{N^2-\sum_{i=1}^{k}n_i^2}{N(N-1)},\\ e_{\mathrm{share}}&=\sum_{i=1}^{k}\frac{n_i}{N}\cdot\frac{(b_i-a_i)^2-(N-n_i)}{(N-1)(N-2)},\\ \mathrm{Var}(U)&=e_{\mathrm{pair}}\cdot\frac12\sum_{a=1}^{N}q_a+e_{\mathrm{share}}\sum_{a=1}^{N}\left(s_a^2-q_a\right) \end{aligned} \]
公式 (1.4):z 值与双侧 p
\[ z=\frac{U-E(U)}{\sqrt{\mathrm{Var}(U)}},\qquad p=2\left[1-\Phi(|z|)\right] \]

参考文献

  1. Jonckheere, A. R. (1954). A distribution-free k-sample test against ordered alternatives. Biometrika, 41(1/2), 133–145.
  2. Terpstra, T. J. (1952). The asymptotic normality and consistency of Kendall's test against trend, when ties are present in one ranking. Indagationes Mathematicae, 14, 327–333.
  3. Hollander, M., & Wolfe, D. A. (1999). Nonparametric Statistical Methods (2nd ed.). Wiley.

算法参数

参数取值默认影响
组序 各组取值或标签的一个完整排列 类别升序 只改变趋势方向与 z 的符号,不改变 U 的绝对值;数据中的组序为 1、2、3。
缺失处理 成对剔除 / 按列表剔除 成对剔除 成对剔除时每个因变量用自己的有效样本;按列表剔除时所有变量共用一批样本。

验证报告

数据与 R 包

样本与变量 N = 90;G 为三组有序分组变量(1、2、3 各 30 例),Y 为定量变量
R 包 PMCMRplus 1.9.12

提示词

按 G 的 1、2、3 组序,对 Y 做 Jonckheere-Terpstra 趋势检验,给出 U、E(U)、方差、z、双侧 p 与各组中位数,结果保留 10 位小数。

R 代码

options(digits = 15)
library(PMCMRplus)
d <- read.csv("jonckheere_terpstra.csv")
r <- jonckheereTest(d$Y, d$G, alternative = "two.sided")
print(r, digits = 15)
ns <- table(d$G); N <- sum(ns)
e <- (N^2 - sum(ns^2)) / 4
cat("U", r$estimates, "E", e, "z", r$statistic,
    "var", ((r$estimates - e) / r$statistic)^2, "p", r$p.value, "\n")
cat("medians", tapply(d$Y, d$G, median), "\n")

对比结果

指标SPSSAUR差值
样本量 130300
样本量 230300
样本量 330300
统计量 U1772.00000000001772.00000000000
期望 E(U)1350.00000000001350.00000000000
方差18225.000000000018225.00000000000
z 值3.12592592593.12592592592.59e−11
双侧 p 值1.772462e−31.772462e−33.49e−9
中位数 143.115944500043.11594450000
中位数 243.889222500043.88922250000
中位数 348.168785000048.16878500000

结论:U、E(U)、方差、z、双侧 p 与三组中位数均与 R 一致。本数据各观测互不相同(无结),ta=1、qa=(N−1)/4,式 (1.3) 即化为无结形式;R 的 PMCMRplus 包采用同一正态近似口径。

操作手册 问题反馈

引用SPSSAU. JT趋势检验:计算公式与参数[EB/OL]. SPSSAU算法手册, 2026-11-20. https://www.spssau.com/algorithm/general/jonckheere_terpstra.html.