trend.test {aTSA} | R Documentation |
Trend Test
Description
Performs an approximate Cox-Stuart or Difference-Sign trend test.
Usage
trend.test(x, method = c("cox.stuart", "diff.sign"), plot = FALSE)
Arguments
x |
a numeric vector or univariate time series. |
method |
test method. The default is |
plot |
a logical value indicating to display the plot of data.
The default is |
Details
Cox-Stuart or Difference-Sign test is used to test whether the data have a
increasing or decreasing trend. They are useful to detect the linear or nonlinear trend.
The Cox-Stuart test is constructed as follows.
For the given data , one can divide them into two sequences with
equal number of observations cutted in the midpoint and then take the paired difference,
i.e.,
, where
is the index of
midpoint. Let
be the number of positive or negative values in
. Under the
null hypothesis that data have no trend, for large
= length(x),
is
approximately distributed as
, such that one can immediately obtain
the p value. The exact Cox-Stuart trend test can be seen in
cs.test
of
snpar
package.
The Difference-Sign test is constructed as the similar way as Cox-Stuart test. We first
let for
and then
count the number of positive or negative values in
, defined as
.
Under the null hypothesis,
is approximately distributed as
. Thus, p-value can be calculated based on the null distribution.
Value
A list with class "htest
" containing the following components:
data.name |
a character string giving the names of the data. |
method |
the type of test applied. |
alternative |
a character string describing the alternative hypothesis. |
p.value |
the p-value for the test. |
statistic |
the value of the test statistic with a name describing it. |
Note
Missing values are removed.
Author(s)
Debin Qiu
References
D.R. Cox and A. Stuart (1955). Some quick sign tests for trend in location and dispersion. Biometrika, Vol. 42, pp. 80-95.
P.J. Brockwell, R.A. Davis, Time Series: Theory and Methods, second ed., Springer, New York, 1991. (p. 37)
Examples
x <- rnorm(100)
trend.test(x,plot = TRUE) # no trend
x <- 5*(1:100)/100
x <- x + arima.sim(list(order = c(1,0,0),ar = 0.4),n = 100)
trend.test(x,plot = TRUE) # increasing trend