Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
Ljung–Box test
Statistical test

The Ljung–Box test (named for Greta M. Ljung and George E. P. Box) is a type of statistical test of whether any of a group of autocorrelations of a time series are different from zero. Instead of testing randomness at each distinct lag, it tests the "overall" randomness based on a number of lags, and is therefore a portmanteau test.

This test is sometimes known as the Ljung–Box Q test, and it is closely connected to the Box–Pierce test (which is named after George E. P. Box and David A. Pierce). In fact, the Ljung–Box test statistic was described explicitly in the paper that led to the use of the Box–Pierce statistic, and from which that statistic takes its name. The Box–Pierce test statistic is a simplified version of the Ljung–Box statistic for which subsequent simulation studies have shown poor performance.

The Ljung–Box test is widely applied in econometrics and other applications of time series analysis. A similar assessment can be also carried out with the Breusch–Godfrey test and the Durbin–Watson test.

We don't have any images related to Ljung–Box test yet.
We don't have any YouTube videos related to Ljung–Box test yet.
We don't have any PDF documents related to Ljung–Box test yet.
We don't have any Books related to Ljung–Box test yet.
We don't have any archived web articles related to Ljung–Box test yet.

Formal definition

The Ljung–Box test may be defined as:

H 0 {\displaystyle H_{0}} : The data is not correlated (i.e. the correlations in the population from which the sample is taken are 0, so that any observed correlations in the data result from randomness of the sampling process). H a {\displaystyle H_{a}} : The data exhibit serial correlation.

The test statistic is:4

Q = n ( n + 2 ) ∑ k = 1 h ρ ^ k 2 n − k {\displaystyle Q=n(n+2)\sum _{k=1}^{h}{\frac {{\hat {\rho }}_{k}^{2}}{n-k}}}

where n is the sample size, ρ ^ k {\displaystyle {\hat {\rho }}_{k}} is the sample autocorrelation at lag k, and h is the number of lags being tested. Under H 0 {\displaystyle H_{0}} the statistic Q asymptotically follows a χ ( h ) 2 {\displaystyle \chi _{(h)}^{2}} . For significance level α, the critical region for rejection of the hypothesis of randomness is:

Q > χ 1 − α , h 2 {\displaystyle Q>\chi _{1-\alpha ,h}^{2}}

where χ 1 − α , h 2 {\displaystyle \chi _{1-\alpha ,h}^{2}} is the (1 − α)-quantile5 of the chi-squared distribution with h degrees of freedom.

The Ljung–Box test is commonly used in autoregressive integrated moving average (ARIMA) modeling. Note that it is applied to the residuals of a fitted ARIMA model, not the original series, and in such applications the hypothesis actually being tested is that the residuals from the ARIMA model have no autocorrelation. When testing the residuals of an estimated ARIMA model, the degrees of freedom need to be adjusted to reflect the parameter estimation. For example, for an ARIMA(p,0,q) model, the degrees of freedom should be set to h − p − q {\displaystyle h-p-q} .6

Box–Pierce test

The Box–Pierce test uses the test statistic, in the notation outlined above, given by7

Q BP = n ∑ k = 1 h ρ ^ k 2 , {\displaystyle Q_{\text{BP}}=n\sum _{k=1}^{h}{\hat {\rho }}_{k}^{2},}

and it uses the same critical region as defined above.

Simulation studies have shown that the distribution for the Ljung–Box statistic is closer to a χ ( h ) 2 {\displaystyle \chi _{(h)}^{2}} distribution than is the distribution for the Box–Pierce statistic for all sample sizes including small ones.

Implementations in statistics packages

  • R: the Box.test function in the stats package8
  • Python: the acorr_ljungbox function in the statsmodels package9
  • Julia: the Ljung–Box tests and the Box–Pierce tests in the HypothesisTests package10
  • SPSS: the Box-Ljung statistic is included by default in output produced by the IBM SPSS Statistics Forecasting module.

See also

Further reading

 This article incorporates public domain material from the National Institute of Standards and Technology

References

  1. Box, G. E. P.; Pierce, D. A. (1970). "Distribution of Residual Autocorrelations in Autoregressive-Integrated Moving Average Time Series Models". Journal of the American Statistical Association. 65 (332): 1509–1526. doi:10.1080/01621459.1970.10481180. JSTOR 2284333. /wiki/Journal_of_the_American_Statistical_Association

  2. G. M. Ljung; G. E. P. Box (1978). "On a Measure of a Lack of Fit in Time Series Models". Biometrika. 65 (2): 297–303. doi:10.1093/biomet/65.2.297. /wiki/Biometrika

  3. Davies, Neville; Newbold, Paul (1979). "Some power studies of a portmanteau test of time series model specification". Biometrika. 66 (1): 153–155. doi:10.1093/biomet/66.1.153. https://academic.oup.com/biomet/article-abstract/66/1/153/223702

  4. G. M. Ljung; G. E. P. Box (1978). "On a Measure of a Lack of Fit in Time Series Models". Biometrika. 65 (2): 297–303. doi:10.1093/biomet/65.2.297. /wiki/Biometrika

  5. Brockwell, Peter J.; Davis, Richard A.; Davis, R. J. (2002-03-08). Introduction to Time Series and Forecasting. Taylor & Francis. p. 36. ISBN 978-0-387-95351-9. 978-0-387-95351-9

  6. Davidson, James (2000). Econometric Theory. Blackwell. p. 162. ISBN 978-0-631-21584-4. 978-0-631-21584-4

  7. Box, G. E. P.; Pierce, D. A. (1970). "Distribution of Residual Autocorrelations in Autoregressive-Integrated Moving Average Time Series Models". Journal of the American Statistical Association. 65 (332): 1509–1526. doi:10.1080/01621459.1970.10481180. JSTOR 2284333. /wiki/Journal_of_the_American_Statistical_Association

  8. "R: Box–Pierce and Ljung–Box Tests". stat.ethz.ch. Retrieved 2016-06-05. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/box.test.html

  9. "Python: Ljung–Box Tests". statsmodels.org. Retrieved 2018-07-23. https://www.statsmodels.org/dev/generated/statsmodels.stats.diagnostic.acorr_ljungbox.html

  10. "Time series tests". juliastats.org. Retrieved 2020-02-04. https://juliastats.org/HypothesisTests.jl/latest/time_series/