statsmodels.stats.diagnostic.acorr_lm#
- statsmodels.stats.diagnostic.acorr_lm(resid, nlags=None, store=False, *, period=None, ddof=0, cov_type='nonrobust', cov_kwds=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.
- nlags
int,defaultNone Highest lag to use.
- storebool,
defaultFalse If true then the intermediate results are also returned.
- period
int,defaultNone 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.
- ddof
int,default0 The number of degrees of freedom consumed by the model used to produce resid. The default value is 0.
- cov_type
str,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.fitare accepted.- cov_kwds
dict,defaultNone Dictionary of covariance options passed to
OLS.fit. See OLS.fit for more details.
- Returns:
- lm
float Lagrange multiplier test statistic.
- lmpval
float The p-value for Lagrange multiplier test.
- fval
float The f statistic of the F test, alternative version of the same test based on F test for the parameter restriction.
- fpval
float The pvalue of the F test.
- res_store
ResultsStore,optional Intermediate results. Only returned if store=True.
- lm
See also
het_archConditional heteroskedasticity testing.
acorr_breusch_godfreyBreusch-Godfrey test for serial correlation.
acorr_ljungboxLjung-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.