View source: R/hsic_serial_test_curve.R
| hsic_serial_test | R Documentation |
Test whether a univariate time series exhibits serial dependence using a portmanteau-type test based on Hilbert-Schmidt Independence Criterion (HSIC) statistics over a set of lags.
hsic_serial_test(
x,
B = 499L,
lags = NULL,
normalize = TRUE,
type = c("H96", "BP"),
kernel = "bartlett",
seed = NULL
)
x |
A numeric vector, or a one-column numeric matrix, containing a univariate time series. |
B |
Number of permutation resamples used to approximate the null distribution. |
lags |
Integer vector of lags to include in the test statistic. If
|
normalize |
Logical; if |
type |
Character string specifying the portmanteau statistic. Either
|
kernel |
Character string specifying the kernel used when
|
seed |
Optional random seed. |
For each lag k, the procedure computes a dependence measure
D_k between X_t and X_{t+k}. The measure D_k is
either HSIC or normalized HSIC, depending on the value of
normalize. By default, normalize = TRUE.
If type = "BP", the test statistic is the Box–Pierce type statistic
T_{BP} = n \sum_{k \in \mathcal{L}} D_k^2,
where \mathcal{L} is the set of selected lags.
If type = "H96", the test statistic is the kernel-weighted
Hong-type statistic
T_{H96} = n \sum_{k \in \mathcal{L}} 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 = "H96", 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 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.
An object of classes "sdt" and "htest" with components:
Observed test statistic.
Permutation p-value.
Description of the procedure.
Name of the supplied data object.
HSIC or normalized HSIC values at the selected lags.
Number of resamples, number of lags used and whether normalization was used.
Null hypothesis value.
The alternative hypothesis.
Integer vector of lags used in the test.
Name of the dependence measure.
Type of portmanteau statistic.
Hong, Y. (1996). Consistent testing for serial correlation of unknown form. Econometrica, 64(4), 837–864. doi:10.2307/2171847.
Gretton, A., Bousquet, O., Smola, A., and Schölkopf, B. (2005). Measuring statistical dependence with Hilbert-Schmidt norms. Algorithmic Learning Theory, 63–77. doi:10.1007/11564089_7.
x <- rnorm(80)
hsic_serial_test(x, B = 99)
y <- as.numeric(arima.sim(list(ar = 0.6), n = 80))
# Default: normalized HSIC with H96-type statistic
hsic_serial_test(y, B = 99, lags = 1:3)
# Unnormalized HSIC with H96-type statistic
hsic_serial_test(y, B = 99, normalize = FALSE)
# Normalized HSIC with kernel-weighted H96-type statistic
hsic_serial_test(y, B = 99, type = "H96")
# Compare both statistic types
hsic_serial_test(y, B = 99, type = "BP")
hsic_serial_test(y, B = 99, type = "H96")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.