# Breusch–Godfrey test

In statistics, the Breusch–Godfrey test is used to assess the validity of some of the modelling assumptions inherent in applying regression-like models to observed data series. In particular, it tests for the presence of serial correlation that has not been included in a proposed model structure and which, if present, would mean that incorrect conclusions would be drawn from other tests or that sub-optimal estimates of model parameters would be obtained.
The regression models to which the test can be applied include cases where lagged values of the dependent variables are used as independent variables in the model's representation for later observations. This type of structure is common in econometric models.
The test is named after Trevor S. Breusch and Leslie G. Godfrey.

## Background

The Breusch–Godfrey test is a test for autocorrelation in the errors in a regression model. It makes use of the residuals from the model being considered in a regression analysis, and a test statistic is derived from these. The null hypothesis is that there is no serial correlation of any order up to p.
Because the test is based on the idea of Lagrange multiplier testing, it is sometimes referred to as an LM test for serial correlation.
A similar assessment can be also carried out with the Durbin–Watson test and the Ljung–Box test. However, the test is more general than that using the Durbin–Watson statistic (or Durbin's h statistic), which is only valid for nonstochastic regressors and for testing the possibility of a first-order autoregressive model (e.g. AR(1)) for the regression errors. The BG test has none of these restrictions, and is statistically more powerful than Durbin's h statistic. The BG test is considered to be more general than the Ljung-Box test because the latter requires the assumption of strict exogeneity, but the BG test does not. However, the BG test requires the assumptions of stronger forms of predeterminedness and conditional homoscedasticity.

## Procedure

Consider a linear regression of any form, for example
    $Y_{t}=\beta _{1}+\beta _{2}X_{t,1}+\beta _{3}X_{t,2}+u_{t}\,$
where the errors might follow an AR(p) autoregressive scheme, as follows:
    $u_{t}=\rho _{1}u_{t-1}+\rho _{2}u_{t-2}+\cdots +\rho _{p}u_{t-p}+\varepsilon _{t}.\,$
The simple regression model is first fitted by ordinary least squares to obtain a set of sample residuals ${\hat {u}}_{t}$.
Breusch and Godfrey proved that, if the following auxiliary regression model is fitted
    ${\hat {u}}_{t}=\alpha _{0}+\alpha _{1}X_{t,1}+\alpha _{2}X_{t,2}+\rho _{1}{\hat {u}}_{t-1}+\rho _{2}{\hat {u}}_{t-2}+\cdots +\rho _{p}{\hat {u}}_{t-p}+\varepsilon _{t}\,$
and if the usual Coefficient of determination ($R^{2}$ statistic) is calculated for this model:
    $R^{2}:={\frac {\sum _{j=1}^{T-p}(u_{T-j}-{\hat {u}}_{T-j})^{2}}{\sum _{j=1}^{T-p}(u_{T-j}-{\bar {u}})^{2}}}$,
where ${\bar {u}}$ stands for the arithmetic mean over the last $n=T-p$ samples, where $T$ is the total number of observations and $p$ is the number of error lags used in the auxiliary regression.
The following asymptotic approximation can be used for the distribution of the test statistic:
    $nR^{2}\,\sim \,\chi _{p}^{2},\,$
when the null hypothesis ${H_{0}:\lbrace \rho _{i}=0{\text{ for all }}i\rbrace }$ holds (that is, there is no serial correlation of any order up to p). Here n is

## Software

* In R, this test is performed by function bgtest, available in package lmtest.
* In Stata, this test is performed by the command estat bgodfrey.
* In SAS, the GODFREY option of the MODEL statement in PROC AUTOREG provides a version of this test.
* In Python Statsmodels, the acorr_breusch_godfrey function in the module statsmodels.stats.diagnostic
* In EViews, this test is already done after a regression, at "View" → "Residual Diagnostics" → "Serial Correlation LM Test".
* In Julia, the BreuschGodfreyTest function is available in the HypothesisTests package.
* In gretl, this test can be obtained via the modtest command, or under the "Test" → "Autocorrelation" menu entry in the GUI client.