## Simulate autoregressive time series process with linear trend.
n=100
x <- 1:n; t <- x/n
U <- 1+2*t + arima.sim(n=n, list(order = c(2,0,0), ar = c(-0.7, -0.1)))
## Testing for presence of the trend.
wavk.test(U, factor.length = "adaptive.selection", B=100)
## Sample Output
##
## Trend test by Wang, Akritas and Van Keilegom
##
## data: U
## WAVK test statistic = -2.0502, adaptively selected window = 11, p-value = 0.01
## alternative hypothesis: presence of a trend
## Using the asymptotic distribution.
wavk.test(U, window=11, method="asympt")
## Sample Output
##
## Trend test by Wang, Akritas and Van Keilegom
##
## data: U
## WAVK test statistic = -2.0502, user-defined window = 11, p-value = 0.04034
## alternative hypothesis: presence of a trend
## Testing for linear trend with output of all results.
wavk.test(U, factor.length = "adaptive.selection", H0="linear", out=TRUE, B=100)
## Sample Output
##
## Trend test by Wang, Akritas and Van Keilegom
##
## data: U
## WAVK test statistic = -1.2729, adaptively selected window = 15, p-value = 0.254
## alternative hypothesis: presence of a nonlinear trend
## sample estimates:
## $linear_trend_coefficients
## (Intercept) t
## 0.8842473 2.1631535
##
## $AR_coefficients
## a1
## -0.5814447
##
## $all_considered_windows
## window WAVK-statistic p-value
## 8 -1.741544 0.062
## 11 -1.601250 0.100
## 15 -1.272851 0.254
## 20 -1.091175 0.406
Run the code above in your browser using DataLab