Learn R Programming

funtimes (version 2.2)

wavk.test: WAVK trend test

Description

Non-parametric test to detect possibly non-monotonic parametric trend in a time series.

Usage

wavk.test(x, factor.length=c("user.defined", "adaptive.selection"), Window=round(0.1*length(x)), q=3/4, j=c(8:11), B=1000, H0=c("no trend","linear"), method=c("boot", "asympt"), ar.order=NULL, BIC=TRUE, robust=TRUE, out=FALSE)

Arguments

x
univariate time series. Missing values are not allowed.
factor.length
method to define the length of local windows (factors). Default option "user.defined" allows to set only one value of the argument Window. The option "adaptive.selection" sets method = "boot" and employs heuristic $m$-out-of-$n$ subsampling algorithm (Bickel and Sakov, 2008) to select an optimal window from the set of possible windows length(x)*q^j whose values are mapped to the largest previous integer and greater than 2.
Window
length of the local window (factor), default is round(0.1*length(x)). This argument is ignored if factor.length = "adaptive.selection".
q
scalar from 0 to 1 to define the set of possible windows when factor.length = "adaptive.selection". Default is $3/4$. This argument is ignored if factor.length = "user.defined".
j
numeric vector to define the set of possible windows when factor.length = "adaptive.selection". Default is c(8:11). This argument is ignored if factor.length = "user.defined".
B
number of bootstrap simulations to obtain empirical critical values. Default is 1000.
H0
null hypothesis: "no trend" (default) for testing the absence of trend (in other words, constant trend) vs. any, possibly non-monotonic, trend; "linear" for testing the presence of parametric linear trend vs. alternative nonlinear trend.
method
method of obtaining critical values: from asymptotical ("asympt") or bootstrap ("boot") distribution. If factor.length = "adaptive.selection" the option "boot" is used.
ar.order
order of autoregressive filter when BIC = FALSE, or the maximal order for BIC-based filtering. Default is floor(10*log10(length(x))).
BIC
logical value indicates whether the order of autoregressive filter should be selected by Bayesian information criterion (BIC). If TRUE (default), models of orders 1,...,ar.order or 1,...,floor(10*log10(length(x))) are be considered, depending on whether ar.order is defined or not.
robust
logical value indicates whether to use robust estimates of autoregression coefficients using HVK function (default), or to use Yule-Walker estimates delivered by ar function.
out
logical value indicates whether full output should be shown. Default is FALSE.

Value

A list with class htest containing the following components:
method
name of the method.
data.name
name of the data.
statistic
value of the test statistic.
p.value
$p$-value of the test.
alternative
alternative hypothesis.
parameter
window that was used.
estimate
list, containing the estimated coefficients of linear trend (if H0="linear"); estimated AR coefficients; test results for all considered windows (if factor.length = "adaptive.selection").

References

Bickel, P. J. and Sakov, A. (2008) On the choice of $m$ in the $m$ out of $n$ bootstrap and confidence bounds for extrema. Statistica Sinica 18, 967--985.

Lyubchich, V., Gel, Y. R. and El-Shaarawi, A. (2013) On detecting non-monotonic trends in environmental time series: a fusion of local regression and bootstrap. Environmetrics 24, 209--226.

Wang, L., Akritas, M. G. and Van Keilegom, I. (2008) An ANOVA-type nonparametric diagnostic test for heteroscedastic regression models. Journal of Nonparametric Statistics 20(5), 365--382.

Wang, L. and Van Keilegom, I. (2007) Nonparametric test for the form of parametric regression with time series errors. Statistica Sinica 17, 369--386.

See Also

HVK, WAVK, sync.test.

Examples

Run this code

# Fix seed for reproduceable simulations.
set.seed(123)

# Simulate autoregressive time series of length n with linear trend 1+2*t, 
# where t is a regular sequence on the interval (0,1].
n <- 100
t <- c(1:n)/n
U <- 1+2*t + arima.sim(n=n, list(order = c(2,0,0), ar = c(-0.7, -0.1)))

# Test for linear trend with output of all results.
## Not run: 
# wavk.test(U, factor.length = "adaptive.selection", H0="linear", out=TRUE, B=1000)
# ## End(Not run)
# Sample output:
##
##  Trend test by Wang, Akritas and Van Keilegom
##
##data:  U
##WAVK test statistic = 0.8562, adaptively selected window = 4, p-value = 0.356
##alternative hypothesis: presence of a nonlinear trend
##sample estimates:
##$linear_trend_coefficients
##(Intercept)           t 
##  0.9917251   2.0224272 
##
##$AR_coefficients
##     phi_1      phi_2 
##-0.6814546 -0.2404422 
##
##$all_considered_windows
## Window WAVK-statistic p-value
##      4      0.8561654   0.356
##      5      0.8620023   0.320
##      7      0.8691870   0.288
##     10      0.6837790   0.306


# Test H0 of absence of a trend using asymptotic distribution of statistic.
wavk.test(U, method="asympt")

# Sample output:
##
##        Trend test by Wang, Akritas and Van Keilegom
##
##data:  U
##WAVK test statistic = 18.4712, user-defined window = 10, p-value < 2.2e-16
##alternative hypothesis: presence of a trend
 

Run the code above in your browser using DataLab