sync_test | R Documentation |
Nonparametric test for synchronicity of parametric trends in multiple time series
\insertCiteLyubchich_Gel_2016_synchronismfuntimes.
The method tests whether N
observed time series exhibit the same trend
of some pre-specified smooth parametric form.
sync_test(
formula,
B = 1000,
Window = NULL,
q = NULL,
j = NULL,
ar.order = NULL,
ar.method = "HVK",
ic = "BIC"
)
formula |
an object of class " |
B |
number of bootstrap simulations to obtain empirical critical values. Default is 1000. |
Window |
scalar or |
q |
scalar from 0 to 1 to define the set of possible windows |
j |
numeric vector to define the set of possible windows |
ar.order |
order of the autoregressive filter when |
ar.method |
method of estimating autoregression coefficients.
Default |
ic |
information criterion used to select the order of autoregressive filter (AIC of BIC),
considering models of orders |
Arguments Window
, j
, and q
are used to set windows
for the local regression. Current version of the function assumes two options:
(1) user specifies one fixed window for each time series using the argument
Window
(if Window
is set, j
and q
are ignored),
and (2) user specifies a set of windows by j
and q
to apply
this set to each time series and to select an optimal window using a heuristic
m
-out-of-n
subsampling algorithm \insertCiteBickel_Sakov_2008funtimes.
The option of selecting windows automatically for some of the time series,
while for other time series the window is fixed, is not available yet.
If none of these three arguments is set, default j
and q
are used.
Values T*q^j
are mapped to the largest previous integer, then only
those greater than 2 are used.
See more details in \insertCiteLyubchich_Gel_2016_synchronism;textualfuntimes and \insertCiteLyubchich_2016_trends;textualfuntimes.
A list of 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 |
|
alternative |
alternative hypothesis. |
estimate |
list with elements |
Yulia R. Gel, Vyacheslav Lyubchich, Ethan Schaeffer, Xingyu Wang
ar
, HVK
, WAVK
,
wavk_test
#Fix seed for reproducible simulations:
set.seed(1)
# Simulate two autoregressive time series of length n without trend
#(i.e., with zero or constant trend)
# and arrange the series into a matrix:
n <- 200
y1 <- arima.sim(n = n, list(order = c(1, 0, 0), ar = c(0.6)))
y2 <- arima.sim(n = n, list(order = c(1, 0, 0), ar = c(-0.2)))
Y <- cbind(y1, y2)
plot.ts(Y)
#Test H0 of a common linear trend:
## Not run:
sync_test(Y ~ t, B = 500)
## End(Not run)
# Sample output:
## Nonparametric test for synchronism of parametric trends
##
##data: Y
##Test statistic = -0.0028999, p-value = 0.7
##alternative hypothesis: common trend is not of the form Y ~ t.
##sample estimates:
##$common_trend_estimates
## Estimate Std. Error t value Pr(>|t|)
##(Intercept) -0.02472566 0.1014069 -0.2438261 0.8076179
##t 0.04920529 0.1749859 0.2811958 0.7788539
##
##$ar.order_used
## y1 y2
##ar.order 1 1
##
##$Window_used
## y1 y2
##Window 15 8
##
##$all_considered_windows
## Window Statistic p-value Asympt. p-value
## 8 -0.000384583 0.728 0.9967082
## 11 -0.024994408 0.860 0.7886005
## 15 -0.047030164 0.976 0.6138976
## 20 -0.015078579 0.668 0.8714980
##
##$wavk_obs
##[1] 0.05827148 -0.06117136
# Add a time series y3 with a different linear trend and re-apply the test:
y3 <- 1 + 3*((1:n)/n) + arima.sim(n = n, list(order = c(1, 0, 0), ar = c(-0.2)))
Y2 <- cbind(Y, y3)
plot.ts(Y2)
## Not run:
sync_test(Y2 ~ t, B = 500)
## End(Not run)
# Sample output:
## Nonparametric test for synchronism of parametric trends
##
##data: Y2
##Test statistic = 0.48579, p-value < 2.2e-16
##alternative hypothesis: common trend is not of the form Y2 ~ t.
##sample estimates:
##$common_trend_estimates
## Estimate Std. Error t value Pr(>|t|)
##(Intercept) -0.3632963 0.07932649 -4.57976 8.219360e-06
##t 0.7229777 0.13688429 5.28167 3.356552e-07
##
##$ar.order_used
## Y.y1 Y.y2 y3
##ar.order 1 1 0
##
##$Window_used
## Y.y1 Y.y2 y3
##Window 8 11 8
##
##$all_considered_windows
## Window Statistic p-value Asympt. p-value
## 8 0.4930069 0 1.207378e-05
## 11 0.5637067 0 5.620248e-07
## 15 0.6369703 0 1.566057e-08
## 20 0.7431621 0 4.201484e-11
##
##$wavk_obs
##[1] 0.08941797 -0.07985614 0.34672734
#Other hypothesized trend forms can be specified, for example:
## Not run:
sync_test(Y ~ 1) #constant trend
sync_test(Y ~ poly(t, 2)) #quadratic trend
sync_test(Y ~ poly(t, 3)) #cubic trend
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.