The Ljung–Box test may be defined as:
The test statistic is:4
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:
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
The Box–Pierce test uses the test statistic, in the notation outlined above, given by7
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.
This article incorporates public domain material from the National Institute of Standards and Technology
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 ↩
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 ↩
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 ↩
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 ↩
Davidson, James (2000). Econometric Theory. Blackwell. p. 162. ISBN 978-0-631-21584-4. 978-0-631-21584-4 ↩
"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 ↩
"Python: Ljung–Box Tests". statsmodels.org. Retrieved 2018-07-23. https://www.statsmodels.org/dev/generated/statsmodels.stats.diagnostic.acorr_ljungbox.html ↩
"Time series tests". juliastats.org. Retrieved 2020-02-04. https://juliastats.org/HypothesisTests.jl/latest/time_series/ ↩