This is a test for monotonic trend in a time series z[t] based on
the Kendall rank correlation of z[t] and t.
Usage
MannKendall(x)
Arguments
x
a vector of data, often a time series
Details
The test was suggested by Mann (1945) and has been extensively used with
environmental time series (Hipel and McLeod, 2005).
For autocorrelated time series, the block bootstrap may be used
to obtain an improved signficance test.
Value
A list with class Kendall.
tau
Kendall's tau statistic
sl
two-sided p-value
S
Kendall Score
D
denominator, tau=S/D
varS
variance of S
Generic function print.Kendall and summary.Kendall are provided to
print the output.
Note
If you want to use the output from MannKendall,
save the result as in res<-MannKendall(x,y) and then select from the list res the
value(s) needed.
Author(s)
A.I. McLeod, aimcleod@uwo.ca
References
Davison, A.C. and Hinkley, D.V. (1997) Bootstrap Methods and Their Application. Cambridge University Press.
Hipel, K.W. and McLeod, A.I., (2005).
Time Series Modelling of Water Resources and Environmental Systems.
Electronic reprint of our book orginally published in 1994.
http://www.stats.uwo.ca/faculty/aim/1994Book/.
Mann, H.B. (1945), Nonparametric tests against trend, Econometrica, 13, 245-259.
See Also
Kendall, SeasonalMannKendalltsboot
Examples
# Annual precipitation entire Great Lakes
# The time series plot with lowess smooth suggests an upward trend
# The autocorrelation in this data does not appear significant.
# The Mann-Kendall trend test confirms the upward trend.
data(PrecipGL)
plot(PrecipGL)
lines(lowess(time(PrecipGL),PrecipGL),lwd=3, col=2)
acf(PrecipGL)
MannKendall(PrecipGL)
#
#Use block bootstrap
library(boot)
data(PrecipGL)
MKtau<-function(z) MannKendall(z)$tau
tsboot(PrecipGL, MKtau, R=500, l=5, sim="fixed")
#
# Deseasonalize a monthly time series and use the block bootstrap
library(boot)
data(manaus)
z<-matrix(manaus, ncol=12, byrow=12)
zm<-apply(z, MARGIN=2, FUN=mean)
zs<-apply(z, MARGIN=2, FUN=sd)
z2<-sweep(z, MARGIN=2, STATS=zm) #subtract monthly means
z3<-sweep(z2, MARGIN=2, STATS=zs, FUN="/") #divide by monthly sd
zds<-c(t(z3))
attributes(zds)<-attributes(manaus)
plot(zds)
#do Mann-Kendall trend test
MannKendall(zds)
#check robustness by applying block bootstrap
MKtau<-function(z) MannKendall(z)$tau
tsboot(zds, MKtau, R=500, l=12, sim="fixed")
#the significance level has dropped!
#it is significant now at about 2 sd
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Kendall)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Kendall/MannKendall.Rd_%03d_medium.png", width=480, height=480)
> ### Name: MannKendall
> ### Title: Mann-Kendall trend test
> ### Aliases: MannKendall
> ### Keywords: nonparametric ts
>
> ### ** Examples
>
> # Annual precipitation entire Great Lakes
> # The time series plot with lowess smooth suggests an upward trend
> # The autocorrelation in this data does not appear significant.
> # The Mann-Kendall trend test confirms the upward trend.
> data(PrecipGL)
> plot(PrecipGL)
> lines(lowess(time(PrecipGL),PrecipGL),lwd=3, col=2)
> acf(PrecipGL)
> MannKendall(PrecipGL)
tau = 0.265, 2-sided pvalue =0.00029206
> #
> #Use block bootstrap
> library(boot)
> data(PrecipGL)
> MKtau<-function(z) MannKendall(z)$tau
> tsboot(PrecipGL, MKtau, R=500, l=5, sim="fixed")
BLOCK BOOTSTRAP FOR TIME SERIES
Fixed Block Length of 5
Call:
tsboot(tseries = PrecipGL, statistic = MKtau, R = 500, l = 5,
sim = "fixed")
Bootstrap Statistics :
original bias std. error
t1* 0.2645801 -0.2756006 0.08727978
> #
> # Deseasonalize a monthly time series and use the block bootstrap
> library(boot)
> data(manaus)
> z<-matrix(manaus, ncol=12, byrow=12)
> zm<-apply(z, MARGIN=2, FUN=mean)
> zs<-apply(z, MARGIN=2, FUN=sd)
> z2<-sweep(z, MARGIN=2, STATS=zm) #subtract monthly means
> z3<-sweep(z2, MARGIN=2, STATS=zs, FUN="/") #divide by monthly sd
> zds<-c(t(z3))
> attributes(zds)<-attributes(manaus)
> plot(zds)
> #do Mann-Kendall trend test
> MannKendall(zds)
tau = 0.0893, 2-sided pvalue =1.1206e-05
> #check robustness by applying block bootstrap
> MKtau<-function(z) MannKendall(z)$tau
> tsboot(zds, MKtau, R=500, l=12, sim="fixed")
BLOCK BOOTSTRAP FOR TIME SERIES
Fixed Block Length of 12
Call:
tsboot(tseries = zds, statistic = MKtau, R = 500, l = 12, sim = "fixed")
Bootstrap Statistics :
original bias std. error
t1* 0.08928069 -0.09215171 0.05245418
> #the significance level has dropped!
> #it is significant now at about 2 sd
>
>
>
>
>
> dev.off()
null device
1
>