Mann Kendall检验
计算公式
符号
| 符号 | 含义 |
|---|---|
| xi | 第 i 期的观测值 |
| n | 样本量 |
| S | Mann-Kendall 秩和统计量 |
| tp | 第 p 个结(相同值)组的长度 |
| Z | 标准化检验统计量 |
| τ | Kendall 秩相关系数(tau-a) |
| β | Sen 斜率 |
核心公式
公式 (1.1):S 统计量
\[
S=\sum_{i=1}^{n-1}\sum_{j=i+1}^{n}\mathrm{sgn}\left(x_j-x_i\right)
\]
公式 (1.2):含结校正的方差
\[
\mathrm{Var}\left(S\right)=\frac{n\left(n-1\right)\left(2n+5\right)-\sum_{p}t_p\left(t_p-1\right)\left(2t_p+5\right)}{18}
\]
公式 (1.3):标准化统计量
\[
Z=\begin{cases}\left(S-1\right)/\sqrt{\mathrm{Var}\left(S\right)}, & S\gt 0\\0, & S=0\\\left(S+1\right)/\sqrt{\mathrm{Var}\left(S\right)}, & S\lt 0\end{cases}
\]
公式 (1.4):Kendall τ 与 Sen 斜率
\[
\tau=\frac{S}{n\left(n-1\right)/2},\qquad \beta=\mathrm{median}\left(\frac{x_j-x_i}{j-i}\right),\quad 1\leq i\lt j\leq n
\]
参考文献
- Mann, H. B. (1945). Nonparametric tests against trend. Econometrica, 13(3), 245–259.
- Kendall, M. G. (1975). Rank Correlation Methods (4th ed.). Charles Griffin.
- Sen, P. K. (1968). Estimates of the regression coefficient based on Kendall's tau. Journal of the American Statistical Association, 63(324), 1379–1389.
算法参数
| 参数 | 取值 | 默认 | 影响 |
|---|---|---|---|
| 检验类型 | 原始检验 | 原始检验 | 标准 Mann-Kendall 检验;SPSSAU 还提供其他趋势检验类型,本次只验证原始检验。 |
验证报告
数据与 R 包
提示词
以 Y 为分析序列、time 为时间变量做原始 Mann-Kendall 趋势检验,报告 S、Var(S)、Z、Kendall's tau、Sen 斜率、截距与 p 值。
R 代码
options(digits = 15)
library(trend)
d <- read.csv("mann_kendall.csv")
m <- mk.test(d$Y)
s <- sens.slope(d$Y)
icpt <- median(d$Y) - s$estimates * (length(d$Y) - 1) / 2
cat("S =", m$estimates["S"], " varS =", m$estimates["varS"], "\n")
cat("Z =", m$statistic, " p =", m$p.value,
" tau =", m$estimates["tau"], "\n")
cat("slope =", s$estimates, " intercept =", icpt, "\n")
对比结果
| 指标 | SPSSAU | R | 差值 |
|---|---|---|---|
| S | 6460.0000000000 | 6460.0000000000 | 0 |
| Var(S) | 194366.6666666667 | 194366.6666666670 | 3.2e−10 |
| Z | 14.6505655932 | 14.6505655932 | 1.18e−11 |
| Kendall's Tau | 0.9047619048 | 0.9047619048 | 3.81e−11 |
| Sen 斜率 | 0.3531894599 | 0.3531894599 | 6.95e−12 |
| 截距 | 39.8082231364 | 39.8082231364 | 3.64e−11 |
| p 值 | <0.001 | 1.33599e−48 | 均小于 0.001 |
结论:S、Var(S)、Z、Kendall's tau、Sen 斜率与截距均与 R 的 trend 包一致,按 10 位小数输出逐位相同。p 值在 SPSSAU 中显示为 <0.001,R 为 1.33599e−48,属于双精度下溢与显示规则差异,不影响“存在显著上升趋势”的结论。Sen 截距按 0 基期下标计算:median(Y) − β × (n−1)/2;SPSSAU 的期数下标从 0 开始,R 也按此换算,因此截距为 39.8082。数据无结,tau-a 与含结校正公式一致。
引用SPSSAU. Mann Kendall检验:计算公式与参数[EB/OL]. SPSSAU算法手册, 2026-11-20. https://www.spssau.com/algorithm/econometrics/mann_kendall.html.