View source: R/dcor_serial_test.R
| dcor_serial_test | R Documentation |
Test whether a univariate time series exhibits serial dependence using a portmanteau-type test based on lagwise distance covariance or distance correlation statistics.
dcor_serial_test(
x,
transform = c("none", "bowl", "biloop"),
measure = c("dcov", "dcor"),
type = c("FP", "BP"),
kernel = "bartlett",
B = 499L,
lags = NULL,
seed = NULL,
block_size = NULL,
...
)
x |
A numeric vector, or a one-column numeric matrix, containing a univariate time series. |
transform |
Character string indicating whether the data should be
transformed before computing the lagwise dependence measure. One of
|
measure |
Character string specifying the lagwise dependence measure.
Either |
type |
Character string specifying the portmanteau statistic. Either
|
kernel |
Character string specifying the kernel used when
|
B |
Number of permutation resamples used to approximate the null distribution. |
lags |
Integer vector of lags to include in the test statistic. If
|
seed |
Optional random seed. |
block_size |
Either |
... |
Additional arguments passed to |
For each lag k, the procedure computes a dependence measure
D_k between X_t and X_{t+k}. The measure is either
distance covariance or distance correlation.
If type = "BP", the test statistic is
T_{BP} = n \sum_{k \in \mathcal{L}} D_k^2.
If type = "FP", the test statistic is
T_{FP} = \sum_{k \in \mathcal{L}} (n-k) K^2(k/m) D_k^2,
where K is a kernel function and m is the number of selected
lags. Currently, the Bartlett kernel is used:
K(z) =
\begin{cases}
1 - |z|, & |z| \le 1 \\
0, & \text{otherwise}
\end{cases}
Hence, for type = "FP", lags larger than m and the largest lag
of 1:m get weight zero. A warning is given if selected lags other than
the largest lag of 1:m do not contribute to the test statistic.
The null distribution is approximated by random permutations of the observed series. This targets the null hypothesis of serial independence. The procedure is simple and broadly applicable, but it is computationally more intensive than classical autocorrelation-based tests.
The procedure assumes that the time series is completely observed. Missing observations should therefore be handled before applying the test.
In practical applications, a larger number of permutation resamples is
recommended to obtain stable and reliable p-values. The default
B = 499 is intended for exploratory use, whereas values such as
B = 2000 or larger are recommended for reporting final results.
If transform = "bowl" or transform = "biloop", the series is
first transformed and the distance correlation is then computed on the
transformed data. By default, scaling is enabled for these transformations,
unless the user explicitly supplies do_scale = FALSE.
Robust scaling can be supplied through the location and scale
arguments. For example, for univariate data one may use the sample median
together with robustbase::Qn.
An object of classes "sdt" and "htest".
Fokianos, K. and Pitsillou, M (2017). Consistent testing for pairwise dependence in time series. Technometrics, 59(2), 262–270 doi:10.1080/00401706.2016.1156024
Székely, G. J., Rizzo, M. L., and Bakirov, N. K. (2007). Measuring and testing dependence by correlation of distances. Annals of Statistics, 35(6), 2769–2794. doi:10.1214/009053607000000505.
Székely, G. J. and Rizzo, M. L. (2009). Brownian distance covariance. Annals of Applied Statistics, 3(4), 1236–1265. doi:10.1214/09-AOAS312.
x <- rnorm(200)
dcor_serial_test(x, B = 99)
y <- as.numeric(arima.sim(list(ar = 0.6), n = 200))
dcor_serial_test(y, B = 99)
dcor_serial_test(y, B = 99, measure = "dcor")
dcor_serial_test(y, B = 99, type = "FP")
dcor_serial_test(y, B = 99, transform = "biloop")
# robust scaling example
if (requireNamespace("robustbase", quietly = TRUE)) {
ymat <- matrix(y, ncol = 1)
loc <- apply(ymat, 2, stats::median)
sc <- apply(ymat, 2, robustbase::Qn)
dcor_serial_test(
y,
transform = "bowl",
B = 99,
location = loc,
scale = sc
)
}
dcor_serial_test(y, B = 99, block_size = 64L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.