```.-
help for ^bgtest^         (STB-55, updated by SSC distribution 11 August 2002)
.-

Calculate the Breusch-Godfrey LM statistic after @regress@ or @newey@
-----------------------------------------------------------------

^bgtest^  [, lags(p) force]

^bgtest^ is for use after ^regress^ or ^newey^; see help @regress@ or @newey@.

^bgtest^ is for use with time-series data.  You must ^tsset^ your data before
using ^bgtest^; see help @tsset@.

Description
-----------

^bgtest^ computes the Breusch (1978)-Godfrey (1978) Lagrange multiplier test
for nonindependence in the error distribution. For a specified number of lags
p, the test's null of independent errors has alternatives of either AR(p) or
MA(p). The test statistic, a T R^2 measure, is distributed Chi-squared(p)
under the null hypothesis. The test is asymptotically equivalent to the Box-
Pierce portmanteau test, or Q statistic (@wntestq@), for p lags, but unlike
the Q statistic, the Breusch-Godfrey test is valid in the presence of
stochastic regressors such as lagged values of the dependent variable.

For p=1, the test is asymptotically equivalent to the Durbin-Watson 'h'
statistic (@durbinh@), which may be considered a special case of the
Breusch-Godfrey test statistic. See Greene (2000), Chapter 13.

This version, updated from that published in STB-55, follows the convention
that lagged values of the estimated residual vector are set to zero, per
Greene (2000), so that the auxiliary regression has the same number of degrees
of freedom as the regression generating the residuals. The two computations
are asymptotically equivalent and we know their distribution under the null
only asymptotically. In small samples, this convention will prevent the loss
of degrees of freedom experienced under the former version of the test.

The command displays the test statistic, degrees of freedom and P-value,
and places values in the return array. @return list@ for details.

Options
-------

The ^lags^ option specifies p, the number of lags to be included in the auxilia
> ry
regression. It must be less than 25% of the sample size.

The ^force^ option specifies that the test is to be allowed after
@regress ..., robust@ and @newey@; by default it is not allowed.  In
these cases the test statistic is exactly the same as if standard OLS were
performed using @regress@.  This is true because the test is based on the
residuals from the regression and they are the same for @regress@,
@regress ..., robust@, and @newey@.  There is no way the test can
utilize any of the information used to make the standard errors robust after
estimation with @newey@ or @regress ..., robust@.  It is best to view
the test as a test of the OLS disturbances whether estimation is by
@regress@, @regress ..., robust@, or @newey@.

Examples
--------

. ^use http://fmwww.bc.edu/ec-p/data/macro/wgmacro.dta^
. ^regress  consumption L(1/4).income^
. ^bgtest, lags(4)^
. ^g Lincome = L.income^
. ^newey  consumption Lincome, lag(4)^
. ^bgtest, lags(4) force^

References
----------

Breusch, T. "Testing for autocorrelation in dynamic linear models."
Australian Economic Papers, 17, 1978, pp. 334-355.

Godfrey, L. "Testing against general autoregressive and moving average
error models when the regressors include lagged dependent variables."
Econometrica, 46, 1978, 1293-1302.

Greene, W. Econmetric Analysis. 4th ed., 2000. New York: Prentice-Hall.

Authors
-------

Christopher F Baum, Boston College, USA
baum@@bc.edu

Vince Wiggins, Stata Corporation
vwiggins@@stata.com

Acknowledgement
---------------
We are grateful to Richard Sperling for suggesting that the zero-fill
convention should be employed in this routine.

Also see
--------

Manual:  ^[R] regress^, ^[R] regression diagnostics^
On-line:  help for @regdiag@, @regress@, @time@, @tsset@; @dwtest@; @newey@;
@durbinh@ (if installed)

```