statsmodels.stats.diagnostic.acorr_ljungbox¶

statsmodels.stats.diagnostic.
acorr_ljungbox
(x, lags=None, boxpierce=False)[source]¶ LjungBox test for no autocorrelation
Parameters: x : array_like, 1d
data series, regression residuals when used as diagnostic test
lags : None, int or array_like
If lags is an integer then this is taken to be the largest lag that is included, the test result is reported for all smaller lag length. If lags is a list or array, then all lags are included up to the largest lag in the list, however only the tests for the lags in the list are reported. If lags is None, then the default maxlag is 12*(nobs/100)^{1/4}
boxpierce : {False, True}
If true, then additional to the results of the LjungBox test also the BoxPierce test results are returned
Returns: lbvalue : float or array
test statistic
pvalue : float or array
pvalue based on chisquare distribution
bpvalue : (optionsal), float or array
test statistic for BoxPierce test
bppvalue : (optional), float or array
pvalue based for BoxPierce test on chisquare distribution
Notes
LjungBox and BoxPierce statistic differ in their scaling of the autocorrelation function. LjungBox test is reported to have better small sample properties.
TODO: could be extended to work with more than one series 1d or nd ? axis ? ravel ? needs more testing
‘’Verification’‘
Looks correctly sized in Monte Carlo studies. not yet compared to verified values
References
Greene Wikipedia
Examples
see example script