TheLjung–Box test (named forGreta M. Ljung andGeorge E. P. Box) is a type ofstatistical test of whether any of a group ofautocorrelations of atime series are different from zero. Instead of testingrandomness at each distinct lag, it tests the "overall" randomness based on a number of lags, and is therefore aportmanteau test.
This test is sometimes known as theLjung–Box Q test, and it is closely connected to theBox–Pierce test (which is named afterGeorge 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,[1][2] 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.[3]
The Ljung–Box test is widely applied ineconometrics and other applications oftime series analysis. A similar assessment can be also carried out with theBreusch–Godfrey test and theDurbin–Watson test.
The Ljung–Box test may be defined as:
The test statistic is:[2]
wheren is the sample size, is the sample autocorrelation at lagk, andh is the number of lags being tested. Under the statistic Q asymptotically follows a. Forsignificance level α, thecritical region for rejection of the hypothesis of randomness is:
where is the (1 − α)-quantile[4] of thechi-squared distribution withh degrees of freedom.
The Ljung–Box test is commonly used inautoregressive integrated moving average (ARIMA) modeling. Note that it is applied to theresiduals 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.[5]
The Box–Pierce test uses the test statistic, in the notation outlined above, given by[1]
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 distribution than is the distribution for the Box–Pierce statistic for all sample sizes including small ones.[citation needed]
Box.test function in the stats package[6]acorr_ljungbox function in thestatsmodels package[7]HypothesisTests package[8]
This article incorporatespublic domain material from the National Institute of Standards and Technology