Learn R Programming

funtimes (version 5.0)

wavk.test: WAVK Trend Test

Description

Non-parametric test to detect (non-)monotonic parametric trends in time series.

Usage

wavk.test(formula, factor.length = c("user.defined", "adaptive.selection"), 
          Window = NULL, q = 3/4, j = c(8:11), B = 1000, method = c("boot", "asympt"), 
          ar.order = NULL, ar.method = "HVK", BIC = TRUE, out = FALSE)

Arguments

formula

an object of class "formula", specifying the form of the parametric time trend to be tested. Variable \(t\) should be used to specify the form, where \(t\) is specified within the function as a regular sequence on the interval (0,1]. See `Examples'.

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. x is the time series tested.

Window

length of the local window (factor), default is round(0.1*length(x)), where x is the time series tested. 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.

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 round(10*log10(length(x))), where x is the time series tested.

ar.method

method of estimating autoregression coefficients. Default "HVK" delivers robust difference-based estimates by Hall and Van Keilegom (2003). Alternatively, options of ar function can be used, such as "burg", "ols", "mle", and "yw".

BIC

logical value indicates whether the order of autoregressive filter should be selected by Bayesian information criterion (BIC). If TRUE (default), models of orders 0,1,...,ar.order or 0,1,...,round(10*log10(length(x))) are considered, depending on whether ar.order is defined or not. x is the time series tested.

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 with the following elements: estimated trend coefficients; user-defined or BIC-selected AR order; estimated AR coefficients; and, if factor.length = "adaptive.selection", test results for all considered windows.

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.

Hall, P. and Van Keilegom, I. (2003). Using difference-based methods for inference in nonparametric regression with time series errors. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 65: 443--456. DOI: 10.1111/1467-9868.00395

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. DOI: 10.1002/env.2212

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. DOI: 10.1080/10485250802066112

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

ar, HVK, WAVK, sync.test

Examples

Run this code
# NOT RUN {
# Fix seed for reproducible simulations:
set.seed(1)

#Simulate autoregressive time series of length n with smooth quadratic trend:
n <- 100
tsTrend <- 1 + 2*(1:n/n) + 4*(1:n/n)^2
tsNoise <- arima.sim(n = n, list(order = c(2, 0, 0), ar = c(-0.7, -0.1)))
U <- tsTrend + tsNoise
plot.ts(U)


#Test H0 of a linear trend, with m-out-of-n selection of the local window:
# }
# NOT RUN {
wavk.test(U ~ t, factor.length = "adaptive.selection")
# }
# NOT RUN {
# Sample output:
##	Trend test by Wang, Akritas, and Van Keilegom (bootstrap p-values)
##
##data:  U 
##WAVK test statistic = 5.3964, adaptively selected window = 4, p-value < 2.2e-16
##alternative hypothesis: trend is not of the form U ~ t.


#Test H0 of a quadratic trend, with m-out-of-n selection of the local window 
#and output of all results:
# }
# NOT RUN {
wavk.test(U ~ poly(t, 2), factor.length = "adaptive.selection", out = TRUE)
# }
# NOT RUN {
# Sample output:
##	Trend test by Wang, Akritas, and Van Keilegom (bootstrap p-values)
##
##data:  U 
##WAVK test statistic = 0.40083, adaptively selected window = 4, p-value = 0.576
##alternative hypothesis: trend is not of the form U ~ poly(t, 2).
##sample estimates:
##$trend_coefficients
##(Intercept) poly(t, 2)1 poly(t, 2)2 
##   3.408530   17.681422    2.597213 
##
##$AR_order
##[1] 1
##
##$AR_coefficients
##         phi_1 
##[1] -0.7406163
##
##$all_considered_windows
## Window WAVK-statistic p-value
##      4     0.40083181   0.576
##      5     0.06098625   0.760
##      7    -0.57115451   0.738
##     10    -1.02982929   0.360


# Test H0 of no trend (constant trend) using asymptotic distribution of statistic.
wavk.test(U ~ 1, method = "asympt")
# Sample output:
##	Trend test by Wang, Akritas, and Van Keilegom (asymptotic p-values)
##
##data:  U 
##WAVK test statistic = 25.999, user-defined window = 10, p-value < 2.2e-16
##alternative hypothesis: trend is not of the form U ~ 1.
# }

Run the code above in your browser using DataLab