statsmodels.stats.diagnostic.acorr_breusch_godfrey#
- statsmodels.stats.diagnostic.acorr_breusch_godfrey(res, nlags=None, store=False, *, result_object=None)[source]#
Breusch-Godfrey Lagrange Multiplier tests for residual autocorrelation
- Parameters:
- res
RegressionResults Estimation results for which the residuals are tested for serial correlation.
- nlags
int,optional Number of lags to include in the auxiliary regression. (nlags is highest lag).
- storebool,
defaultFalse If store is true, then an additional class instance that contains intermediate results is returned.
- result_objectbool,
optional Flag indicating whether to return the results as an
LMTestResultNamedTuple instead of a plain tuple. Whenstore=Truethe NamedTuple holds the same five elements as the legacy tuple, so it unpacks identically and is always returned, with no warning. Whenstore=Falsethe legacy four-element tuple is returned by default and aFutureWarningis issued.Deprecated since version 0.15.0: In release 0.16.0 or after July 2027, whichever is later, the default will change to always return an
LMTestResult. Setresult_object=Trueto opt in now, orresult_object=Falseto silence the warning and keep the current return type.
- res
- Returns:
LMTestResultIf
result_object=True, a NamedTuple with fieldslm,lmpval,fval,fpval, andres_store(res_storeisNonewhen not computed). SeeLMTestResult.Otherwise(thedeprecateddefault),aplaintuplemadeupof:- lm
float Lagrange multiplier test statistic.
- lmpval
float The p-value for Lagrange multiplier test.
- fval
float The value of the f statistic for F test, alternative version of the same test based on F test for the parameter restriction.
- fpval
float The pvalue for F test.
- res_store
ResultsStore A class instance that holds intermediate results. Only returned if store=True.
Notes
BG adds lags of residual to exog in the design matrix for the auxiliary regression with residuals as endog. See [1], section 12.7.1.
References
[1]Greene, W. H. Econometric Analysis. New Jersey. Prentice Hall; 5th edition. (2002).