序列的趋势存在性检验:Cox-Stuart test和Mann-Kendall test

本文介绍了用于检验序列趋势存在的两种非参数统计方法——Cox-Stuart趋势检验和Mann-Kendall趋势检验。通过比较数据中正负差异的分布来判断上升或下降趋势,并提供了R语言的实现示例。虽然两者结果可能略有不同,但都作为线性回归的补充,用于科学地识别趋势。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我们经常听这样的描述,数据呈上升/下降/无明显趋势,这个结论往往是靠人眼观察出来的,不够严谨。我们需要更科学的方法,下面就借助非参里的符号检验,来谈谈检验趋势存在性的两种常用方法。

  1. Cox-Stuart趋势检验
  • 原理
    对于数据序列x1,x2,x3,……,xn,我们以位置中间数c为界把该序列分成两部分,并两两配对成(x1,xc+1),(x2,xc+2),……(xc,xn)的形式。接着我们以每一组中后一个数减去前一个数并记下正负性,s+表示得到正数的个数,s-表示得到负数的个数。如果s+远远大于s-,则我们认为序列存在上升趋势,反之序列存在下降趋势,如果s+与s-很接近,那就无明显趋势,这里度量s+和s-有无明显差异性靠的是binom.test()。

  • 实现
    R语言里没有现成的函数,需要自己编写,这里给出一种作为参考。案例结果表明,置信水平为0.05时,测试序列customers呈下降趋势,但趋势并不显著(P值0.1094)

cox.stuart.test =
function (x)
{
  method = "Cox-Stuart test for trend analysis"
  leng = length(x)
  apross = round(leng) %% 2
  if (apross == 1) {
    delete = (length(x)+1)/2
    x = x[ -delete ] 
  }
  half = length(x)/2
  x1 = x[1:half]
  x2 = x[(half+1):(length(x))]
  difference = x1-x2
  signs = sign(difference)
  signcorr = signs[signs != 0]
  pos = signs[signs>0]
  neg = signs[signs<0]
  if (length(pos) < length(neg)) {
    prop = pbinom(length(pos), length(signcorr), 0.5)
    names(prop) = "Increasing trend, p-value"
    rval <- list(method = method, statistic = prop)
    class(rval) = "htest"
    return(rval)
  }
  else {
    prop = pbinom(length(neg), length(signcorr), 0.5)
    names(prop) = "Decreasing trend, p-value"
    rval <- list(method = method, statistic = prop)
    class(rval) = "htest"
    return(rval)
  }
}
#We can now use the function just created:


customers = c(5, 9, 12, 18, 17, 16, 19, 20, 4, 3, 18, 16, 17, 15, 14)
cox.stuart.test(customers)

        Cox-Stuart test for trend analysis

data:  
Decreasing trend, p-value = 0.1094
  1. Mann-Kendall趋势检验
  • 原理
    比较复杂,具体请参考python中的Mann-Kendall单调趋势检验–及原理说明

  • 实现
    好在R语言里现成的函数,可直接用。依然使用测试序列customers,结果跟上面有点不同,大于0的z值表明呈上升趋势,不过P值也说明了趋势并不显著,也不能说跟Cox-Stuart test的结果有矛盾。

library(trend)  
customers = c(5, 9, 12, 18, 17, 16, 19, 20, 4, 3, 18, 16, 17, 15, 14)
mk.test(customers, continuity = TRUE)
	
	Mann-Kendall trend test

data:  customers
z = 0.24835, n = 15, p-value = 0.8039
alternative hypothesis: true S is not equal to 0
sample estimates:
          S        varS         tau 
  6.0000000 405.3333333   0.0579771 

以上就是关于趋势存在性检验的两种非参统计方法:Cox-Stuart趋势检验和Mann-Kendall趋势检验的大致内容,可作为人眼观察识别趋势(不科学、不精确)参数线性回归,利用k值的正负性和显著性来判断趋势(只能识别线性趋势,且要满足一系列经典假定前提)的重要补充。

参考链接:
Mann-Kendall趋势检验-学术百科-知网空间
Analysis with the Cox-Stuart test in R | R-bloggers
python中的Mann-Kendall单调趋势检验–及原理说明_python_留下的,留不下的-CSDN博客
使用R语言进行Mann-Kendall趋势检验 - 知乎

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值