A combination of time series trend tests for testing the null hypothesis of no trend, versus the alternative hypothesis of a linear trend (Student's t-test), or monotonic trend (Mann--Kendall test), or more general, possibly non-monotonic trend (WAVK test).
notrend_test(
x,
B = 1000,
test = c("t", "MK", "WAVK"),
ar.method = "HVK",
ar.order = NULL,
BIC = TRUE,
factor.length = c("user.defined", "adaptive.selection"),
Window = NULL,
q = 3/4,
j = c(8:11)
)
a vector containing a univariate time series. Missing values are not allowed.
number of bootstrap simulations to obtain empirical critical values. Default is 1000.
trend test to implement: Student's t-test ("t"
, default),
Mann--Kendall test ("MK"
), or
WAVK test ("WAVK"
, see WAVK
).
method of estimating autoregression coefficients.
Default "HVK"
delivers robust difference-based estimates by
Hall_VanKeilegom_2003;textualfuntimes. Alternatively,
options of ar
function can be used, such as "burg"
,
"ols"
, "mle"
, and "yw"
.
order of autoregressive model when BIC = FALSE
, or
the maximal order for BIC-based filtering. Default is
round(10*log10(length(x)))
, where x
is the time series.
logical value indicates whether the order of autoregressive
filter should be selected by Bayesian information criterion (BIC).
If TRUE
(default), models of orders ar.order
or round(10*log10(length(x)))
are considered,
depending on whether ar.order
is defined or not
(x
is the time series).
method to define the length of local windows (factors).
Used only if test = "WAVK"
. Default option "user.defined"
allows
to set only one value of the argument Window
. The option
"adaptive.selection"
sets method = "boot"
and employs
heuristic length(x)*q^j
whose values are mapped to the largest
previous integer and greater than 2. Vector x
is the time series tested.
length of the local window (factor), default is
round(0.1*length(x))
. Used only if test = "WAVK"
.
This argument is ignored if factor.length = "adaptive.selection"
.
scalar from 0 to 1 to define the set of possible windows when
factor.length =
"adaptive.selection"
.
Used only if test = "WAVK"
. Default is factor.length =
"user.defined"
.
numeric vector to define the set of possible windows when
factor.length =
"adaptive.selection"
.
Used only if test = "WAVK"
. Default is c(8:11)
.
This argument is ignored if factor.length =
"user.defined"
.
A list with class "htest"
containing the following components:
name of the method.
name of the data.
value of the test statistic.
alternative hypothesis.
list with the following elements: employed AR order and estimated AR coefficients.
window that was used in WAVK test, included in the output only
if test = "WAVK"
.
This function tests the null hypothesis of no trend
versus different alternatives.
To set some other shape of trend as the null hypothesis, use wavk_test
.
Note that wavk_test
employs hybrid bootstrap, which is alternative
to the sieve bootstrap employed by the current function.
ar
, HVK
, WAVK
,
wavk_test
, vignette("trendtests", package = "funtimes")
# NOT RUN {
# Fix seed for reproducible simulations:
set.seed(1)
#Simulate autoregressive time series of length n with smooth linear trend:
n <- 200
tsTrend <- 1 + 2*(1:n/n)
tsNoise <- arima.sim(n = n, list(order = c(2, 0, 0), ar = c(0.5, -0.1)))
U <- tsTrend + tsNoise
plot.ts(U)
#Use t-test
notrend_test(U)
#Use Mann--Kendall test and Yule-Walker estimates of the AR parameters
notrend_test(U, test = "MK", ar.method = "yw")
#Use WAVK test for the H0 of no trend, with m-out-of-n selection of the local window:
notrend_test(U, test = "WAVK", factor.length = "adaptive.selection")
# Sample output:
## Sieve-bootstrap WAVK trend test
##
##data: U
##WAVK test statistic = 21.654, moving window = 15, p-value < 2.2e-16
##alternative hypothesis: (non-)monotonic trend.
##sample estimates:
##$AR_order
##[1] 1
##
##$AR_coefficients
## phi_1
##0.4041848
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab