library(Kendall) library(mblm) # the CO2 data has too much trend; Instead # Kendall library includes an example data set # of precipitation for the entire Great Lakes watershed # 1900 - 1986 data(PrecipGL) # PrecipGL is a time series, so it has a year attribute PrecipGL # which we can extract and store precip.year <- time(PrecipGL) # and a plot works nicely without an X variable plot(PrecipGL) # can convert to vectors precip <- as.vector(PrecipGL) precip.year <- as.vector(precip.year) plot(precip.year,precip) # Kendall's tau for any x and y Kendall(precip.year,precip) # or when obs are sequential over time MannKendall(precip) # if data are monthly (and only monthly) # SeasonalMannKendall(X) # Theil-Sen estimate of slope library(mblm) precip.theil <- mblm(precip~precip.year,repeated=F) # have print, summary and confint methods precip.theil summary(precip.theil) confint(precip.theil) # use for data with a single dl value < any obs value # by replacing with all < dl values by some thing smaller # then any observed value. Kendall correct, but Theil Sen approximate