算法手册/ 综合评价/ Mann Kendall检验

Mann Kendall检验

计算公式

符号

符号含义
xi第 i 期的观测值
n样本量
SMann-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 \]

参考文献

  1. Mann, H. B. (1945). Nonparametric tests against trend. Econometrica, 13(3), 245–259.
  2. Kendall, M. G. (1975). Rank Correlation Methods (4th ed.). Charles Griffin.
  3. 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 包

数据文件 mann_kendall.csv
样本与变量 N = 120;time 为 1–120 的期数,Y 为带稳定上升趋势与噪声的序列
R 包 trend 1.1.10

提示词

以 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")

对比结果

指标SPSSAUR差值
S6460.00000000006460.00000000000
Var(S)194366.6666666667194366.66666666703.2e−10
Z14.650565593214.65056559321.18e−11
Kendall's Tau0.90476190480.90476190483.81e−11
Sen 斜率0.35318945990.35318945996.95e−12
截距39.808223136439.80822313643.64e−11
p 值<0.0011.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.