# Fix seed for reproduceable simulations.
set.seed(123)
# Simulate two autoregressive time series of length n without trend (i.e., with zero trend)
# and apply the synchronism test.
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)))
X1 <- cbind(y1, y2)
## Not run:
# sync.test(X1, B=1000)
# ## End(Not run)
# Sample output:
##
## Non-parametric test for synchronism of parametric linear trends
##
##data: X1
##Test statistic = -0.0712, p-value = 0.452
##alternative hypothesis: trends are not synchronized.
##sample estimates:
##$common_trend_estimates
## Estimate Std. Error t value Pr(>|t|)
##(Intercept) 0.02944134 0.09871156 0.2982563 0.7658203
##t -0.05858974 0.17033482 -0.3439681 0.7312353
##
##$ar_order_used
## y1 y2
##ar_order 1 1
##
##$Window_used
## y1 y2
##Window 8 15
##
##$all_considered_windows
## Window Statistic p-value Asympt. p-value
## 8 -0.09419625 0.295 0.3423957
## 11 -0.08168139 0.363 0.4103374
## 15 -0.08831680 0.459 0.3733687
## 20 -0.09337623 0.451 0.3466142
# Add a time series y3 with a different linear trend and apply the synchronism test.
t <- c(1:n)/n
y3 <- 1 + 2*t + arima.sim(n=n, list(order=c(1,0,0), ar=c(-0.2)))
X2 <- cbind(y1, y3)
## Not run:
# sync.test(X2, B=1000)
# ## End(Not run)
# Sample output:
##
## Non-parametric test for synchronism of parametric linear trends
##
##data: X2
##Test statistic = 0.3027, p-value < 2.2e-16
##alternative hypothesis: trends are not synchronized.
##sample estimates:
##$common_trend_estimates
## Estimate Std. Error t value Pr(>|t|)
##(Intercept) -0.4047268 0.09862909 -4.103523 5.943524e-05
##t 0.8054264 0.17019251 4.732443 4.215118e-06
##
##$ar_order_used
## y1 y3
##ar_order 1 1
##
##$Window_used
## y1 y3
##Window 8 8
##
##$all_considered_windows
## Window Statistic p-value Asympt. p-value
## 8 0.3027026 0 3.464035e-04
## 11 0.3527386 0 3.055570e-05
## 15 0.3608431 0 1.998331e-05
## 20 0.3655885 0 1.552063e-05
Run the code above in your browser using DataLab