Title: | Non-Parametric Trend Tests and Change-Point Detection |
---|---|
Description: | The analysis of environmental data often requires the detection of trends and change-points. This package includes tests for trend detection (Cox-Stuart Trend Test, Mann-Kendall Trend Test, (correlated) Hirsch-Slack Test, partial Mann-Kendall Trend Test, multivariate (multisite) Mann-Kendall Trend Test, (Seasonal) Sen's slope, partial Pearson and Spearman correlation trend test), change-point detection (Lanzante's test procedures, Pettitt's test, Buishand Range Test, Buishand U Test, Standard Normal Homogeinity Test), detection of non-randomness (Wallis-Moore Phase Frequency Test, Bartels rank von Neumann's ratio test, Wald-Wolfowitz Test) and the two sample Robust Rank-Order Distributional Test. |
Authors: | Thorsten Pohlert [aut, cre] |
Maintainer: | Thorsten Pohlert <[email protected]> |
License: | GPL-3 |
Version: | 1.1.6 |
Built: | 2024-12-03 06:44:35 UTC |
Source: | CRAN |
Performes a rank version of von Neumann's ratio test as proposed by Bartels. The null hypothesis of randomness is tested against the alternative hypothesis
bartels.test(x)
bartels.test(x)
x |
a vector of class "numeric" or a time series object of class "ts" |
In this function, the test is implemented as given by Bartels (1982),
where the ranks of
the
are used for the statistic:
As proposed by Bartels (1982), the -value is calculated
for sample sizes in the range of
with
the non-standard beta distribution for the range
with parameters:
For sample sizes a normal approximation with
is used for
-value calculation.
A list with class "htest"
data.name |
character string that denotes the input data |
p.value |
the p-value |
statistic |
the test statistic |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
The current function is for complete observations only.
R. Bartels (1982), The Rank Version of von Neumann's Ratio Test for Randomness, Journal of the American Statistical Association 77, 40–46.
# Example from Schoenwiese (1992, p. 113) ## Number of frost days in April at Munich from 1957 to 1968 ## frost <- ts(data=c(9,12,4,3,0,4,2,1,4,2,9,7), start=1957) bartels.test(frost) ## Example from Sachs (1997, p. 486) x <- c(5,6,2,3,5,6,4,3,7,8,9,7,5,3,4,7,3,5,6,7,8,9) bartels.test(x) ## Example from Bartels (1982, p. 43) x <- c(4, 7, 16, 14, 12, 3, 9, 13, 15, 10, 6, 5, 8, 2, 1, 11, 18, 17) bartels.test(x)
# Example from Schoenwiese (1992, p. 113) ## Number of frost days in April at Munich from 1957 to 1968 ## frost <- ts(data=c(9,12,4,3,0,4,2,1,4,2,9,7), start=1957) bartels.test(frost) ## Example from Sachs (1997, p. 486) x <- c(5,6,2,3,5,6,4,3,7,8,9,7,5,3,4,7,3,5,6,7,8,9) bartels.test(x) ## Example from Bartels (1982, p. 43) x <- c(4, 7, 16, 14, 12, 3, 9, 13, 15, 10, 6, 5, 8, 2, 1, 11, 18, 17) bartels.test(x)
Performes the Buishand range test for change-point detection of a normal variate.
br.test(x, m = 20000)
br.test(x, m = 20000)
x |
a vector of class "numeric" or a time series object of class "ts" |
m |
numeric, number of Monte-Carlo replicates, defaults to 20000 |
Let denote a normal random variate, then the following model
with a single shift (change-point) can be proposed:
with . The null hypothesis
is tested against the alternative
.
In the Buishand range test, the rescaled adjusted partial sums are calculated as
The test statistic is calculated as:
.
The p.value
is estimated with a Monte Carlo simulation
using m
replicates.
Critical values based on Monte Carlo simulations
are tabulated for
by Buishand (1982).
A list with class "htest" and "cptest"
data.name |
character string that denotes the input data |
p.value |
the p-value |
statistic |
the test statistic |
null.value |
the null hypothesis |
estimates |
the time of the probable change point |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
data |
numeric vector of Sk for plotting |
The current function is for complete observations only.
T. A. Buishand (1982), Some Methods for Testing the Homogeneity of Rainfall Records, Journal of Hydrology 58, 11–27.
G. Verstraeten, J. Poesen, G. Demaree, C. Salles (2006), Long-term (105 years) variability in rain erosivity as derived from 10-min rainfall depth data for Ukkel (Brussels, Belgium): Implications for assessing soil erosion rates. Journal of Geophysical Research 111, D22109.
data(Nile) (out <- br.test(Nile)) plot(out) data(PagesData) ; br.test(PagesData)
data(Nile) (out <- br.test(Nile)) plot(out) data(PagesData) ; br.test(PagesData)
Performes the Buishand U test for change-point detection of a normal variate.
bu.test(x, m = 20000)
bu.test(x, m = 20000)
x |
a vector of class "numeric" or a time series object of class "ts" |
m |
numeric, number of Monte-Carlo replicates, defaults to 20000 |
Let denote a normal random variate, then the following model
with a single shift (change-point) can be proposed:
with . The null hypothesis
is tested against the alternative
.
In the Buishand U test, the rescaled adjusted partial sums are calculated as
The sample standard deviation is
The test statistic is calculated as:
.
The p.value
is estimated with a Monte Carlo simulation
using m
replicates.
Critical values based on Monte Carlo simulations
are tabulated for
by Buishand (1982, 1984).
A list with class "htest" and "cptest"
data.name |
character string that denotes the input data |
p.value |
the p-value |
statistic |
the test statistic |
null.value |
the null hypothesis |
estimates |
the time of the probable change point |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
data |
numeric vector of Sk for plotting |
The current function is for complete observations only.
T. A. Buishand (1982), Some Methods for Testing the Homogeneity of Rainfall Records, Journal of Hydrology 58, 11–27.
T. A. Buishand (1984), Tests for Detecting a Shift in the Mean of Hydrological Time Series, Journal of Hydrology 73, 51–69.
data(Nile) (out <- bu.test(Nile)) plot(out) data(PagesData) bu.test(PagesData)
data(Nile) (out <- bu.test(Nile)) plot(out) data(PagesData) bu.test(PagesData)
Performes the non-parametric Cox and Stuart trend test
cs.test(x)
cs.test(x)
x |
a vector or a time series object of class "ts" |
First, the series is devided by three. It is compared, whether the
data of the first third of the series are larger or smaller than the
data of the last third of the series.
The test statistic of the Cox-Stuart trend test for
is calculated as:
where denotes the maximum of the number of signs, i.e.
or
, respectively. The
-statistic is
normally distributed. For
a continuity correction of
is included in the denominator.
An object of class "htest"
method |
a character string indicating the chosen test |
data.name |
a character string giving the name(s) of the data |
statistic |
the Cox-Stuart z-value |
alternative |
a character string describing the alternative hypothesis |
p.value |
the p-value for the test |
NA values are omitted. Many ties in the series will lead to reject H0 in the present test.
L. Sachs (1997), Angewandte Statistik. Berlin: Springer.
C.-D. Schoenwiese (1992), Praktische Statistik. Berlin: Gebr. Borntraeger.
D. R. Cox and A. Stuart (1955), Quick sign tests for trend in location and dispersion. Biometrika 42, 80-95.
## Example from Schoenwiese (1992, p. 114) ## Number of frost days in April at Munich from 1957 to 1968 ## z = -0.5, Accept H0 frost <- ts(data=c(9,12,4,3,0,4,2,1,4,2,9,7), start=1957) cs.test(frost) ## Example from Sachs (1997, p. 486-487) ## z ~ 2.1, Reject H0 on a level of p = 0.0357 x <- c(5,6,2,3,5,6,4,3,7,8,9,7,5,3,4,7,3,5,6,7,8,9) cs.test(x) cs.test(Nile)
## Example from Schoenwiese (1992, p. 114) ## Number of frost days in April at Munich from 1957 to 1968 ## z = -0.5, Accept H0 frost <- ts(data=c(9,12,4,3,0,4,2,1,4,2,9,7), start=1957) cs.test(frost) ## Example from Sachs (1997, p. 486-487) ## z ~ 2.1, Reject H0 on a level of p = 0.0357 x <- c(5,6,2,3,5,6,4,3,7,8,9,7,5,3,4,7,3,5,6,7,8,9) cs.test(x) cs.test(Nile)
Performs a Seasonal Mann-Kendall test under the presence of correlated seasons.
csmk.test(x, alternative = c("two.sided", "greater", "less"))
csmk.test(x, alternative = c("two.sided", "greater", "less"))
x |
a time series object with class |
alternative |
the alternative hypothesis, defaults to |
The Mann-Kendall scores are first computed for each season seperately.
The variance - covariance matrix is computed according to Libiseller and Grimvall (2002).
Finally the corrected Z-statistics for the entire series
is calculated as follows, whereas a continuity correction is employed
for :
where
denotes the quantile of the normal distribution, 1 indicates a vector
with all elements equal to one,
is the vector of Mann-Kendall scores
for each season and
denotes the variance - covariance matrix.
An object with class "htest"
data.name |
character string that denotes the input data |
p.value |
the p-value for the entire series |
statistic |
the z quantile of the standard normal distribution for the entire series |
null.value |
the null hypothesis |
estimates |
the estimates S and varS for the entire series |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
cov |
the variance - covariance matrix |
Ties are not corrected. Current Version is for complete observations only.
Hipel, K.W. and McLeod, A.I. (1994), Time Series Modelling of Water Resources and Environmental Systems. New York: Elsevier Science.
Libiseller, C. and Grimvall, A., (2002), Performance of partial Mann-Kendall tests for trend detection in the presence of covariates. Environmetrics 13, 71–84, doi:10.1002/env.507.
cor
,
cor.test
,
mk.test
,
smk.test
csmk.test(nottem)
csmk.test(nottem)
Time series of monthly concentration of particle bound
Hexachlorobenzene (HCB) in g/kg at six different
monitoring sites at the River Rhine, 1995.1-2006.12
data(hcb)
data(hcb)
a time series object of class "mts"
we first column, series of station Weil (RKM 164.3)
ka second column, series of station Karlsruhe-Iffezheim (RKM 333.9)
mz third column, series of station Mainz (RKM 498.5)
ko fourth column, series of station Koblenz (RKM 590.3)
bh fith column, series of station Bad Honnef(RKM 645.8)
bi sixth column, series of station Bimmen (RKM 865.0)
NO DATA values in the series were filled with estimated values
using linear interpolation (see approx
.
The Rhine Kilometer (RKM) is in increasing order from source to mouth of the River Rhine.
International Commission for the Protection of the River Rhine
T. Pohlert, G. Hillebrand, V. Breitung (2011), Trends of persistent organic pollutants in the suspended matter of the River Rhine, Hydrological Processes 25, 3803–3817. doi:10.1002/hyp.8110
data(hcb) plot(hcb) mult.mk.test(hcb)
data(hcb) plot(hcb) mult.mk.test(hcb)
Performes a non-parametric test after Lanzante in order to test for a shift in the central tendency of a time series. The null hypothesis, no shift, is tested against the alternative, shift.
lanzante.test(x, method = c("wilcox.test", "rrod.test"))
lanzante.test(x, method = c("wilcox.test", "rrod.test"))
x |
a vector of class "numeric" or a time series object of class "ts" |
method |
the test method. Defaults to |
Let denote a continuous random variable, then the following model
with a single shift (change-point) can be proposed:
with . The null hypothesis, H:
is tested against the alternative A:
.
First, the data are transformed into increasing ranks and for each time-step the adjusted rank sum is computed:
The probable change point is located at the absolute maximum of the statistic:
.
For method = "wilcox.test"
the Wilcoxon-Mann-Whitney two-sample
test is performed, using to split the series. Otherwise,
the robust rank-order distributional test (
rrod.test
is
performed.
A list with class "htest" and "cptest".
Lanzante, J. R. (1996), Resistant, robust and non-parametric techniques for the analysis of climate data: Theory and examples, including applications to historical radiosonde station data, Int. J. Clim., 16, 1197–1226.
data(maxau) ; plot(maxau[,"s"]) s.res <- lanzante.test(maxau[,"s"]) n <- s.res$nobs i <- s.res$estimate s.1 <- mean(maxau[1:i,"s"]) s.2 <- mean(maxau[(i+1):n,"s"]) s <- ts(c(rep(s.1,i), rep(s.2,(n-i)))) tsp(s) <- tsp(maxau[,"s"]) lines(s, lty=2) print(s.res) data(PagesData) ; lanzante.test(PagesData)
data(maxau) ; plot(maxau[,"s"]) s.res <- lanzante.test(maxau[,"s"]) n <- s.res$nobs i <- s.res$estimate s.1 <- mean(maxau[1:i,"s"]) s.2 <- mean(maxau[(i+1):n,"s"]) s <- ts(c(rep(s.1,i), rep(s.2,(n-i)))) tsp(s) <- tsp(maxau[,"s"]) lines(s, lty=2) print(s.res) data(PagesData) ; lanzante.test(PagesData)
Annual time series of average suspended sediment concentration (s) in mg/l and average discharge (Q) in m^3 / s at the River Rhine, 1965.1-2009.1
data(maxau)
data(maxau)
a time series object of class "mts"
s. first column, suspended sediment concentration
Q. second column, average discharge
Bundesanstalt für Gewässerkunde, Koblenz, Deutschland (Federal Institute of Hydrology, Koblenz, Germany)
data(maxau) plot(maxau)
data(maxau) plot(maxau)
Performs the Mann-Kendall Trend Test
mk.test(x, alternative = c("two.sided", "greater", "less"), continuity = TRUE)
mk.test(x, alternative = c("two.sided", "greater", "less"), continuity = TRUE)
x |
a vector of class "numeric" or a time series object of class "ts" |
alternative |
the alternative hypothesis, defaults to |
continuity |
logical, indicates whether a continuity correction
should be applied, defaults to |
The null hypothesis is that the data come from a population with independent realizations and are identically distributed. For the two sided test, the alternative hypothesis is that the data follow a monotonic trend. The Mann-Kendall test statistic is calculated according to:
with the signum function (see
sign
).
The mean of is
. The variance including the
correction term for ties is
where is the number of the tied groups in the data set and
is the number of data points in the
-th tied group.
The statistic
is approximately normally distributed, with
If continuity = TRUE
then a continuity correction will be employed:
The statistic is closely related to Kendall's
:
where
A list with class "htest"
data.name |
character string that denotes the input data |
p.value |
the p-value |
statistic |
the z quantile of the standard normal distribution |
null.value |
the null hypothesis |
estimates |
the estimates S, varS and tau |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
Current Version is for complete observations only.
Hipel, K.W. and McLeod, A.I. (1994), Time Series Modelling of Water Resources and Environmental Systems. New York: Elsevier Science.
Libiseller, C. and Grimvall, A., (2002), Performance of partial Mann-Kendall tests for trend detection in the presence of covariates. Environmetrics 13, 71–84, doi:10.1002/env.507.
cor.test
,
MannKendall
,
partial.mk.test
,
sens.slope
data(Nile) mk.test(Nile, continuity = TRUE) ## n <- length(Nile) cor.test(x=(1:n),y=Nile, meth="kendall", continuity = TRUE)
data(Nile) mk.test(Nile, continuity = TRUE) ## n <- length(Nile) cor.test(x=(1:n),y=Nile, meth="kendall", continuity = TRUE)
Performs a Multivariate (Multisite) Mann-Kendall test.
mult.mk.test(x, alternative = c("two.sided", "greater", "less"))
mult.mk.test(x, alternative = c("two.sided", "greater", "less"))
x |
a time series object of class "ts" |
alternative |
the alternative hypothesis, defaults to |
The Mann-Kendall scores are first computed for each variate (side) seperately.
with the signum function (see
sign
).
The variance - covariance matrix is computed according to Libiseller and Grimvall (2002).
with
and
Finally, the corrected z-statistics for the entire series
is calculated as follows, whereas a continuity correction is employed
for :
where
denotes the quantile of the normal distribution
is the vector of Mann-Kendall scores
for each variate (site)
and
denotes symmetric variance - covariance matrix.
An object with class "htest"
data.name |
character string that denotes the input data |
p.value |
the p-value for the entire series |
statistic |
the z quantile of the standard normal distribution for the entire series |
null.value |
the null hypothesis |
estimates |
the estimates S and varS for the entire series |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
cov |
the variance - covariance matrix |
Ties are not corrected. Current Version is for complete observations only.
Hipel, K.W. and McLeod, A.I. (1994), Time Series Modelling of Water Resources and Environmental Systems. New York: Elsevier Science.
Lettenmeier, D.P. (1988), Multivariate nonparametric tests for trend in water quality. Water Resources Bulletin 24, 505–512.
Libiseller, C. and Grimvall, A. (2002), Performance of partial Mann-Kendall tests for trend detection in the presence of covariates. Environmetrics 13, 71–84, doi:10.1002/env.507.
cor
,
cor.test
,
mk.test
,
smk.test
data(hcb) mult.mk.test(hcb)
data(hcb) mult.mk.test(hcb)
Simulated data of Page (1955) as test-example for change-point detection taken from Table 1 of Pettitt (1979)
data(PagesData)
data(PagesData)
a vector that contains 40 elements
According to the publication of Pettitt (1979), the series comprise a
significant change-point at
. The function
pettitt.test
computes the same U statistics as given by
Pettitt (1979) in Table1, row 4.
Page, E. S. (1954), A test for a change in a parameter occuring at an unknown point. Biometrika 41, 100–114.
Pettitt, A. N., (1979). A non-parametric approach to the change point problem. Journal of the Royal Statistical Society Series C, Applied Statistics 28, 126–135.
data(PagesData) pettitt.test(PagesData)
data(PagesData) pettitt.test(PagesData)
Performs a partial correlation trend test with either Pearson's or
Spearman's correlation coefficients ().
partial.cor.trend.test(x, z, method = c("pearson", "spearman"))
partial.cor.trend.test(x, z, method = c("pearson", "spearman"))
x |
a "vector" or "ts" object that contains the variable, which is tested for trend (i.e. correlated with time) |
z |
a "vector" or "ts" object that contains the co-variate, which will be partialled out |
method |
a character string indicating which correlation coefficient is to be computed. One of "pearson" (default) or "spearman", can be abbreviated. |
This function performs a partial correlation trend test using either the "pearson" correlation coefficient, or the "spearman" rank correlation coefficient (Hipel and McLoed (1994), p. 882). The partial correlation coefficient for the response variable "x" with time "t", when the effect of the explanatory variable "z" is partialled out, is defined as:
The H0: (i.e. no trend for "x", when
effect of "z" is partialled out) is tested against the
alternate Hypothesis, that there is a trend for "x", when the effect of
"z" is partialled out.
The partial correlation coefficient is tested for significance with
the student t distribution on degree of freedom.
An object of class "htest"
method |
a character string indicating the chosen test |
data.name |
a character string giving the name(s) of the data |
statistic |
the value of the test statistic |
estimate |
the partial correlation coefficient |
parameter |
the degrees of freedom of the test statistic in the case that it follows a t distribution |
alternative |
a character string describing the alternative hypothesis |
p.value |
the p-value of the test |
null.value |
The value of the null hypothesis |
Current Version is for complete observations only.
Hipel, K.W. and McLeod, A.I. (1994), Time Series Modelling of Water Resources and Environmental Systems. New York: Elsevier Science.
Bahrenberg, G., Giese, E. and Nipper, J., (1992): Statistische Methoden in der Geographie, Band 2 Multivariate Statistik, Teubner, Stuttgart.
cor
,
cor.test
,
partial.r
,
partial.mk.test
,
data(maxau) a <- tsp(maxau) ; tt <- a[1]:a[2] s <- maxau[,"s"] ; Q <- maxau[,"Q"] maxau.df <- data.frame(Year = tt, s =s, Q = Q) plot(maxau.df) partial.cor.trend.test(s,Q, method="pearson") partial.cor.trend.test(s,Q, method="spearman")
data(maxau) a <- tsp(maxau) ; tt <- a[1]:a[2] s <- maxau[,"s"] ; Q <- maxau[,"Q"] maxau.df <- data.frame(Year = tt, s =s, Q = Q) plot(maxau.df) partial.cor.trend.test(s,Q, method="pearson") partial.cor.trend.test(s,Q, method="spearman")
Performs a partial Mann-Kendall Trend Test
partial.mk.test(x, y, alternative = c("two.sided", "greater", "less"))
partial.mk.test(x, y, alternative = c("two.sided", "greater", "less"))
x |
a "vector" or "ts" object that contains the variable, which is tested for trend (i.e. correlated with time) |
y |
a "vector" or "ts" object that contains the variable, which effect on "x" is partialled out |
alternative |
character, the alternative method; defaults to "two.sided" |
According to Libiseller and Grimvall (2002), the test statistic
for x
with its covariate y
is
where the correlation is calculated as:
The conditional covariance between and
is
with
and
A list with class "htest"
method |
a character string indicating the chosen test |
data.name |
a character string giving the name(s) of the data |
statistic |
the value of the test statistic |
estimate |
the Mann-Kendall score S, the variance varS and the correlation between x and y |
alternative |
a character string describing the alternative hypothesis |
p.value |
the p-value of the test |
null.value |
the null hypothesis |
Current Version is for complete observations only. The test statistic is not corrected for ties.
Libiseller, C. and Grimvall, A., (2002). Performance of partial Mann-Kendall tests for trend detection in the presence of covariates. Environmetrics 13, 71–84, doi:10.1002/env.507.
data(maxau) s <- maxau[,"s"]; Q <- maxau[,"Q"] partial.mk.test(s,Q)
data(maxau) s <- maxau[,"s"]; Q <- maxau[,"Q"] partial.mk.test(s,Q)
Performes a non-parametric test after Pettitt in order to test for a shift in the central tendency of a time series. The H0-hypothesis, no change, is tested against the HA-Hypothesis, change.
pettitt.test(x)
pettitt.test(x)
x |
a vector of class "numeric" or a time series object of class "ts" |
In this function, the test is implemented as given by Verstraeten et. al.
(2006), where the ranks of
the
are used for the statistic:
The test statistic is the maximum of the absolute value of the vector:
.
The probable change-point is located where
has its maximum.
The approximate probability for a two-sided test is calculated
according to
A list with class "htest" and "cptest"
The current function is for complete observations only.
The approximate probability is good for .
CHR (ed., 2010), Das Abflussregime des Rheins und seiner Nebenfluesse im 20. Jahrhundert, Report no I-22 of the CHR, p. 172.
Pettitt, A. N. (1979), A non-parametric approach to the change point problem. Journal of the Royal Statistical Society Series C, Applied Statistics 28, 126-135.
G. Verstraeten, J. Poesen, G. Demaree, C. Salles (2006), Long-term (105 years) variability in rain erosivity as derived from 10-min rainfall depth data for Ukkel (Brussels, Belgium): Implications for assessing soil erosion rates. Journal of Geophysical Research 111, D22109.
data(maxau) ; plot(maxau[,"s"]) s.res <- pettitt.test(maxau[,"s"]) n <- s.res$nobs i <- s.res$estimate s.1 <- mean(maxau[1:i,"s"]) s.2 <- mean(maxau[(i+1):n,"s"]) s <- ts(c(rep(s.1,i), rep(s.2,(n-i)))) tsp(s) <- tsp(maxau[,"s"]) lines(s, lty=2) print(s.res) data(PagesData) ; pettitt.test(PagesData)
data(maxau) ; plot(maxau[,"s"]) s.res <- pettitt.test(maxau[,"s"]) n <- s.res$nobs i <- s.res$estimate s.1 <- mean(maxau[1:i,"s"]) s.2 <- mean(maxau[(i+1):n,"s"]) s <- ts(c(rep(s.1,i), rep(s.2,(n-i)))) tsp(s) <- tsp(maxau[,"s"]) lines(s, lty=2) print(s.res) data(PagesData) ; pettitt.test(PagesData)
Plotting method for objects inheriting from class "cptest"
## S3 method for class 'cptest' plot(x, ...)
## S3 method for class 'cptest' plot(x, ...)
x |
an object of class "cptest" |
... |
further arguments, currently ignored |
data(Nile) (out <- br.test(Nile)) par(mfrow=c(2,1)) plot(Nile) ; plot(out)
data(Nile) (out <- br.test(Nile)) par(mfrow=c(2,1)) plot(Nile) ; plot(out)
Performs Fligner-Pollicello robust rank-order distributional test for location.
rrod.test(x, ...) ## Default S3 method: rrod.test(x, y, alternative = c("two.sided", "less", "greater"), ...) ## S3 method for class 'formula' rrod.test(formula, data, subset, na.action, ...)
rrod.test(x, ...) ## Default S3 method: rrod.test(x, y, alternative = c("two.sided", "less", "greater"), ...) ## S3 method for class 'formula' rrod.test(formula, data, subset, na.action, ...)
x |
a vector of data values. |
... |
further arguments to be passed to or from methods. |
y |
an optional numeric vector of data values. |
alternative |
the alternative hypothesis. Defaults to |
formula |
a formula of the form |
data |
an optional matrix or data frame (or similar: see
|
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
a function which indicates what should happen when
the data contain |
The non-parametric RROD two-sample test can be used to test for differences in location, whereas it does not assume variance homogeneity.
Let and
denote two samples with sizes
and
of a continuous variable.First, the combined sample is transformed
into ranks in increasing order.
Let
and
denote the counts of
values having a lower rank than
. The mean counts are:
The variances are:
The test statistic is:
The two samples have significantly different location parameters,
if .
The function calculates the
-values of the null hypothesis
for the selected alternative than can be
"two.sided"
, "greater"
or "less"
.
A list with class "htest"
.
Fligner, M. A., Pollicello, G. E. III. (1981), Robust Rank Procedures for the Behrens-Fisher Problem, Journal of the American Statistical Association, 76, 162–168.
Lanzante, J. R. (1996), Resistant, robust and non-parametric techniques for the analysis of climate data: Theory and examples, including applications to historical radiosonde station data, Int. J. Clim., 16, 1197–1226.
Siegel, S. and Castellan, N. (1988), Nonparametric Statistics For The Behavioural Sciences, New York: McCraw-Hill.
## Two-sample test. ## Hollander & Wolfe (1973), 69f. ## Permeability constants of the human chorioamnion (a placental ## membrane) at term (x) and between 12 to 26 weeks gestational ## age (y). The alternative of interest is greater permeability ## of the human chorioamnion for the term pregnancy. x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46) y <- c(1.15, 0.88, 0.90, 0.74, 1.21) rrod.test(x, y, alternative = "g") ## Formula interface. boxplot(Ozone ~ Month, data = airquality) rrod.test(Ozone ~ Month, data = airquality, subset = Month %in% c(5, 8))
## Two-sample test. ## Hollander & Wolfe (1973), 69f. ## Permeability constants of the human chorioamnion (a placental ## membrane) at term (x) and between 12 to 26 weeks gestational ## age (y). The alternative of interest is greater permeability ## of the human chorioamnion for the term pregnancy. x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46) y <- c(1.15, 0.88, 0.90, 0.74, 1.21) rrod.test(x, y, alternative = "g") ## Formula interface. boxplot(Ozone ~ Month, data = airquality) rrod.test(Ozone ~ Month, data = airquality, subset = Month %in% c(5, 8))
Computes seasonal Sen's slope for linear rate of change
sea.sens.slope(x)
sea.sens.slope(x)
x |
a time series object of class "ts" |
Acccording to Hirsch et al. (1982) the seasonal Sen's slope is calculated as follows:
for each
pair
,
where
and
is
the number of known values in the
season.
The seasonal slope estimator is the median of
the
values.
numeric, Seasonal Sen's slope.
Current Version is for complete observations only.
Hipel, K.W. and McLeod, A.I. (1994), Time Series Modelling of Water Resources and Environmental Systems. New York: Elsevier Science.
Hirsch, R., J. Slack, R. Smith (1982), T echniques of Trend Analysis for Monthly Water Quality Data. Water Resources Research 18, 107-121.
Sen, P.K. (1968), Estimates of the regression coefficient based on Kendall's tau, Journal of the American Statistical Association 63, 1379–1389.
sea.sens.slope(nottem)
sea.sens.slope(nottem)
Computes Sen's slope for linear rate of change and corresponding confidence intervalls
sens.slope(x, conf.level = 0.95)
sens.slope(x, conf.level = 0.95)
x |
numeric vector or a time series object of class "ts" |
conf.level |
numeric, the level of significance |
This test computes both the slope (i.e. linear rate of change) and confidence levels according to Sen's method. First, a set of linear slopes is calculated as follows:
for , where d
is the slope, x denotes the variable, n is the number of data, and i,
j are indices.
Sen's slope is then calculated as the median from all slopes:
.
This function also computes the upper and lower confidence limits for sens slope.
A list of class "htest".
estimates |
numeric, Sen's slope |
data.name |
character string that denotes the input data |
p.value |
the p-value |
statistic |
the z quantile of the standard normal distribution |
null.value |
the null hypothesis |
conf.int |
upper and lower confidence limit |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
Current Version is for complete observations only.
Hipel, K.W. and McLeod, A.I. (1994), Time Series Modelling of Water Resources and Environmental Systems. New York: Elsevier Science.
Sen, P.K. (1968), Estimates of the regression coefficient based on Kendall's tau, Journal of the American Statistical Association 63, 1379–1389.
data(maxau) sens.slope(maxau[,"s"]) mk.test(maxau[,"s"])
data(maxau) sens.slope(maxau[,"s"]) mk.test(maxau[,"s"])
Performs a Seasonal Mann-Kendall Trend Test (Hirsch-Slack Test)
smk.test(x, alternative = c("two.sided", "greater", "less"), continuity = TRUE)
smk.test(x, alternative = c("two.sided", "greater", "less"), continuity = TRUE)
x |
a time series object with class |
alternative |
the alternative hypothesis, defaults to |
continuity |
logical, indicates, whether a continuity correction
should be done; defaults to |
The Mann-Kendall statistic for the $g$-th season is calculated as:
with the signum function (see
sign
).
The mean of is
. The variance including the
correction term for ties is
The seasonal Mann-Kendall statistic for the entire series is calculated according to
The statistic is approximately normally distributed, with
If continuity = TRUE
then a continuity correction will be employed:
An object with class "htest" and "smktest"
data.name |
character string that denotes the input data |
p.value |
the p-value for the entire series |
statistic |
the z quantile of the standard normal distribution for the entire series |
null.value |
the null hypothesis |
estimates |
the estimates S and varS for the entire series |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
Sg |
numeric vector that contains S scores for each season |
varSg |
numeric vector that contains varS for each season |
pvalg |
numeric vector that contains p-values for each season |
Zg |
numeric vector that contains z-quantiles for each season |
Hipel, K.W. and McLeod, A.I. (1994), Time Series Modelling of Water Resources and Environmental Systems. New York: Elsevier Science.
Libiseller, C. and Grimvall, A. (2002), Performance of partial Mann-Kendall tests for trend detection in the presence of covariates. Environmetrics 13, 71–84, doi:10.1002/env.507.
R. Hirsch, J. Slack, R. Smith (1982), Techniques of Trend Analysis for Monthly Water Quality Data, Water Resources Research 18, 107–121.
res <- smk.test(nottem) ## print method res ## summary method summary(res)
res <- smk.test(nottem) ## print method res ## summary method summary(res)
Performes the Standard Normal Homogeinity Test (SNHT) for change-point detection of a normal variate.
snh.test(x, m = 20000)
snh.test(x, m = 20000)
x |
a vector of class "numeric" or a time series object of class "ts" |
m |
numeric, number of Monte-Carlo replicates, defaults to 20000 |
Let denote a normal random variate, then the following model
with a single shift (change-point) can be proposed:
with . The null hypothesis
is tested against the alternative
.
The test statistic for the SNHT test is calculated as follows:
where
The critical value is:
The p.value
is estimated with a Monte Carlo simulation
using m
replicates.
Critical values based on Monte Carlo simulations
are tabulated for
by Khaliq and Ouarda (2007).
A list with class "htest" and "cptest"
data.name |
character string that denotes the input data |
p.value |
the p-value |
statistic |
the test statistic |
null.value |
the null hypothesis |
estimates |
the time of the probable change point |
alternative |
the alternative hypothesis |
method |
character string that denotes the test |
data |
numeric vector of Tk for plotting |
The current function is for complete observations only.
H. Alexandersson (1986), A homogeneity test applied to precipitation data, Journal of Climatology 6, 661–675.
M. N. Khaliq, T. B. M. J. Ouarda (2007), On the critical values of the standard normal homogeneity test (SNHT), International Journal of Climatology 27, 681–687.
G. Verstraeten, J. Poesen, G. Demaree, C. Salles (2006), Long-term (105 years) variability in rain erosivity as derived from 10-min rainfall depth data for Ukkel (Brussels, Belgium): Implications for assessing soil erosion rates. Journal of Geophysical Research 111, D22109.
data(Nile) (out <- snh.test(Nile)) plot(out) data(PagesData) ; snh.test(PagesData)
data(Nile) (out <- snh.test(Nile)) plot(out) data(PagesData) ; snh.test(PagesData)
Generic function "summary" for objects of class smktest
.
## S3 method for class 'smktest' summary(object, ...)
## S3 method for class 'smktest' summary(object, ...)
object |
an object of class |
... |
further arguments, currently ignored |
Performes the non-parametric Wallis and Moore phase-frequency test for testing the H0-hypothesis, whether the series comprises random data, against the HA-Hypothesis, that the series is significantly different from randomness (two-sided test).
wm.test(x)
wm.test(x)
x |
a vector or a time series object of class "ts" |
The test statistic of the phase-frequency test for
is calculated as:
where denotes the number of phases, whereas the first and the
last phase is not accounted. The
-statistic is
normally distributed. For
a continuity correction of
is included in the denominator.
An object of class "htest"
method |
a character string indicating the chosen test |
data.name |
a character string giving the name(s) of the data |
statistic |
the Wallis and Moore z-value |
alternative |
a character string describing the alternative hypothesis |
p.value |
the p-value for the test |
NA values are omitted. Many ties in the series will lead to reject H0 in the present test.
L. Sachs (1997), Angewandte Statistik. Berlin: Springer.
C.-D. Schoenwiese (1992), Praktische Statistik. Berlin: Gebr. Borntraeger.
W. A. Wallis and G. H. Moore (1941): A significance test for time series and other ordered observations. Tech. Rep. 1. National Bureau of Economic Research. New York.
## Example from Schoenwiese (1992, p. 113) ## Number of frost days in April at Munich from 1957 to 1968 ## z = -0.124, Accept H0 frost <- ts(data=c(9,12,4,3,0,4,2,1,4,2,9,7), start=1957) wm.test(frost) ## Example from Sachs (1997, p. 486) ## z = 2.56, Reject H0 on a level of p < 0.05 x <- c(5,6,2,3,5,6,4,3,7,8,9,7,5,3,4,7,3,5,6,7,8,9) wm.test(x) wm.test(nottem)
## Example from Schoenwiese (1992, p. 113) ## Number of frost days in April at Munich from 1957 to 1968 ## z = -0.124, Accept H0 frost <- ts(data=c(9,12,4,3,0,4,2,1,4,2,9,7), start=1957) wm.test(frost) ## Example from Sachs (1997, p. 486) ## z = 2.56, Reject H0 on a level of p < 0.05 x <- c(5,6,2,3,5,6,4,3,7,8,9,7,5,3,4,7,3,5,6,7,8,9) wm.test(x) wm.test(nottem)
Performes the non-parametric Wald-Wolfowitz test for independence and stationarity.
ww.test(x)
ww.test(x)
x |
a vector or a time series object of class "ts" |
Let denote the sampled data, then the test
statistic of the Wald-Wolfowitz test is calculated as:
The expected value of R is:
The expected variance is:
with:
For the test statistic is normally distributed, with:
ww.test calculates p-values from the standard normal distribution for the two-sided case.
An object of class "htest"
method |
a character string indicating the chosen test |
data.name |
a character string giving the name(s) of the data |
statistic |
the Wald-Wolfowitz z-value |
alternative |
a character string describing the alternative hypothesis |
p.value |
the p-value for the test |
NA values are omitted.
R. K. Rai, A. Upadhyay, C. S. P. Ojha and L. M. Lye (2013), Statistical analysis of hydro-climatic variables. In: R. Y. Surampalli, T. C. Zhang, C. S. P. Ojha, B. R. Gurjar, R. D. Tyagi and C. M. Kao (ed. 2013), Climate change modelling, mitigation, and adaptation. Reston, VA: ASCE. doi = 10.1061/9780784412718.
A. Wald and J. Wolfowitz (1943), An exact test for randomness in the non-parametric case based on serial correlation. Annual Mathematical Statistics 14, 378–388.
WMO (2009), Guide to Hydrological Practices. Volume II, Management of Water Resources and Application of Hydrological Practices, WMO-No. 168.
ww.test(nottem) ww.test(Nile) set.seed(200) x <- rnorm(100) ww.test(x)
ww.test(nottem) ww.test(Nile) set.seed(200) x <- rnorm(100) ww.test(x)