hsic_serial_test: Test Serial Dependence Using HSIC

View source: R/hsic_serial_test_curve.R

hsic_serial_testR Documentation

Test Serial Dependence Using HSIC

Description

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.

Usage

hsic_serial_test(
  x,
  B = 499L,
  lags = NULL,
  normalize = TRUE,
  type = c("H96", "BP"),
  kernel = "bartlett",
  seed = NULL
)

Arguments

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 NULL, the default is 1:floor(n^(2/5)). In case of subject knowledge it is recommended not to use the default but a vector of the form 1:m, where m is the largest meaningful lag of interest strictly smaller than the length of the time series.

normalize

Logical; if TRUE, the test statistic is based on the normalized HSIC values computed by nHSIC. If FALSE, the unnormalized HSIC values returned by dhsic are used.

type

Character string specifying the portmanteau statistic. Either "BP" for a Box–Pierce type statistic or "H96" for a kernel-weighted Hong-type statistic.

kernel

Character string specifying the kernel used when type = "H96". Currently only "bartlett" is implemented.

seed

Optional random seed.

Details

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.

Value

An object of classes "sdt" and "htest" with components:

statistic

Observed test statistic.

p.value

Permutation p-value.

method

Description of the procedure.

data.name

Name of the supplied data object.

estimate

HSIC or normalized HSIC values at the selected lags.

parameter

Number of resamples, number of lags used and whether normalization was used.

null.value

Null hypothesis value.

alternative

The alternative hypothesis.

lags

Integer vector of lags used in the test.

measure_name

Name of the dependence measure.

type

Type of portmanteau statistic.

References

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.

Examples

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")



dcorBSS documentation built on Nov. 10, 2026, 5:07 p.m.