statsmodels.stats.diagnostic.acorr_lm

statsmodels.stats.diagnostic.acorr_lm(resid, nlags=None, store=False, *, period=None, ddof=0, cov_type='nonrobust', cov_kwargs=None)[source]

Lagrange Multiplier tests for autocorrelation.

This is a generic Lagrange Multiplier test for autocorrelation. Returns Engle’s ARCH test if resid is the squared residual array. Breusch-Godfrey is a variation on this test with additional exogenous variables.

Parameters
residarray_like

Time series to test.

nlagsint, default None

Highest lag to use.

storebool, default False

If true then the intermediate results are also returned.

periodint, default none

The period of a Seasonal time series. Used to compute the max lag for seasonal data which uses min(2*period, nobs // 5) if set. If None, then the default rule is used to set the number of lags. When set, must be >= 2.

ddofint, default 0

The number of degrees of freedom consumed by the model used to produce resid. The default value is 0.

cov_typestr, default “nonrobust”

Covariance type. The default is “nonrobust` which uses the classic OLS covariance estimator. Specify one of “HC0”, “HC1”, “HC2”, “HC3” to use White’s covariance estimator. All covariance types supported by OLS.fit are accepted.

cov_kwargsdict, default None

Dictionary of covariance options passed to OLS.fit. See OLS.fit for more details.

Returns
lmfloat

Lagrange multiplier test statistic.

lmpvalfloat

The p-value for Lagrange multiplier test.

fvalfloat

The f statistic of the F test, alternative version of the same test based on F test for the parameter restriction.

fpvalfloat

The pvalue of the F test.

res_storeResultsStore, optional

Intermediate results. Only returned if store=True.

See also

het_arch

Conditional heteroskedasticity testing.

acorr_breusch_godfrey

Breusch-Godfrey test for serial correlation.

acorr_ljung_box

Ljung-Box test for serial correlation.

Notes

The test statistic is computed as (nobs - ddof) * r2 where r2 is the R-squared from a regression on the residual on nlags lags of the residual.