StatTimeSerAnalysis.BoxLjung Method

Double BoxLjung(TVec X, Int32 h)

The box-Ljung statistics.

#NameDescription
1XDefines the residuals of predicted values.
2hDefines the number of lags used in statistics.

Returns: Double - the Box-Ljung statistics.

Remarks:

The Ljung-Box test is based on the autocorrelation plot. However, instead of testing randomness at each distinct lag, it tests the "overall" randomness based on a number of lags. For this reason, it is often referred to as a "portmanteau" test. The Ljung-Box test statistics can be defined as follows:

QLB=n(n+2)j=1hρ2(j)nj.\text{Q}_{LB} = n(n+2) \sum _{j=1} ^h \cfrac{\rho ^2 (j)}{n-j} \quad .

where n is the sample size, rho(j) is the autocorrelation at lag j, and h is the number of lags being tested. Actually we are testing the hypothesis:

  • H: The data are random.
  • Ha: The data are not random.

The Ljung-Box test is commonly used in ARIMA modeling. Note that it is applied to the residuals of a fitted ARIMA model, not the original series.