lbtest: Modified Ljung-Box Test and Volatility Clustering Test for...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/lbtest.R

Description

Modified Ljung-Box test and volatility clustering test for time series. Time series can be univariate or multivariate. The modified Ljung-Box test checks whether there is linear autocorrelation in the time series. The volatility clustering test checks whether the time series has squared autocorrelation, which would indicate a presence of volatility clustering.

Usage

1
2
3
4
lbtest(X, k, type = c("squared", "linear"))

## S3 method for class 'lbtest'
print(x, digits = 3, ...)

Arguments

X

A numeric vector/matrix or a univariate/multivariate time series object of class ts, xts or zoo. Missing values are not allowed.

k

A vector of lags.

type

The type of the autocorrelation test. Options are Modified Ljung-Box test ("linear") or volatility clustering test ("squared") autocorrelation. Default is "squared".

In methods for class 'lbtest' only:

x

An object of class lbtest

digits

The number of digits when printing an object of class lbtest. Default is 3

...

Further arguments to be passed to or from methods.

Details

Assume all the individual time series X_i in X with T observations are scaled to have variance 1.

Then the modified Ljung-Box test statistic for testing the existence of linear autocorrelation in X_i (option = "linear") is

T*sum_j(sum_t (X_it X_(i, t + j))/(T - j))^2/V_j.

Here

V_j = sum_t (x_t^2 x_(t+j)^2)/(n-j) + 2*sum_k (n - k)/n * sum_s (x_s x_(s+j) x_(s+k) x_(s+k+j))/(n - k - j),

where t = 1, …, n - j, k = 1, …, n - j - 1 and s = 1, …, n - k - j.

The volatility clustering test statistic (option = "squared") is

T*sum_j(sum_t (X_it^2 X_(i, t + j)^2)/(T - j) - 1)^2/4.

Test statistic related to each time series X_i is then compared to χ^2-distribution with length(k) degrees of freedom, and the corresponding p-values are produced. Small p-value indicates the existence of autocorrelation.

Value

A list of class 'lbtest' containing the following components:

TS

The values of the test statistic for each component of X as a vector.

p_val

The p-values based on the test statistic for each component of X as a vector.

Xname

The name of the data used as a character string.

varnames

The names of the variables used as a character string vector.

k

The lags used for testing the serial autocorrelation as a vector.

K

The total number of lags used for testing the serial autocorrelation.

type

The type of the autocorrelation test.

Author(s)

Markus Matilainen, Jari Miettinen

References

Miettinen, M., Matilainen, M., Nordhausen, K. and Taskinen, S. (2020), Extracting Conditionally Heteroskedastic Components Using Independent Component Analysis, Journal of Time Series Analysis, 41, 293–311.

See Also

FixNA, gFOBI, gJADE, vSOBI, gSOBI

Examples

1
2
3
4
5
6
7
8
9
if(require("stochvol")) {
n <- 10000
s1 <- svsim(n, mu = -10, phi = 0.95, sigma = 0.1)$y
s2 <- rnorm(n)
S <- cbind(s1, s2)

lbtest(S, 1:3, type = "squared")
# First p-value should be very close to zero, as there exists stochastic volatility
}

Example output

Loading required package: ICtest
Loading required package: JADE
Loading required package: ICS
Loading required package: mvtnorm
Loading required package: ggplot2
Registered S3 method overwritten by 'GGally':
  method from   
  +.gg   ggplot2
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
Loading required package: stochvol

	Serial autocorrelation test for S

Testing for squared autocorrelations based on lag(s) 1 2 3 
Based on a chi squared test with 3 degrees of freedom 

The test statistic and the corresponding p-value for each series: 
 Series Statistic  p-value
     s1    39.796 1.18e-08
     s2       0.2    0.978

For each series the alternative hypothesis is: serial squared correlation exists 

tsBSS documentation built on July 10, 2021, 9:07 a.m.