On Tue, 3 Dec 2013, Gregory Chaudoin wrote:
 I am teaching an econometrics course where we are testing for
 autorcorrelation.
 In GRETL the Breusch-Godrey test is in TESTS--Autocorrelation and you set
 the number of lags.
 The problem is that the Gretl BG test does not adjust of the number of
 lags.  For example, suppose we have a sample of 100 observations.
 The BG test (using 4 lags of the residual) regresses the current residual
 against the x variables and 4 lagged residuals.  We can then use the LM
 test statistics = (100- 4)*R^2.
 The problem that I have with GRETL is that its test statistics uses T=100
 in the auxiliary regression instead of the proper 96 (we use up 4
 observations with the lags.)
 Why does Gretl do this? 
Gretl uses one of the existing variants to this test: you substitute zeros 
for pre-sample residuals. Of course, the difference you get with the 
procedure you're suggesting are asymptotically negligible. See the 
following script for an example:
<hansl>
nulldata 100
setobs 1 1 --special-time-series
x = normal()
y = normal() + 1 + x
ols y 0 x
u = $uhat
list U = null
loop i=1..4 --quiet
     u$i = misszero(u(-i))
     U += u$i
endloop
ols u 0 x U
T1 = $rsq * $T
ols u 0 x u(-1 to -4)
T2 = $rsq * $T
</hansl>
Oh, and before you say: "yes, but in finite samples the two variants may 
be very different", let me just remind you taht if you really cared about 
what happens in finite samples, you shouldn't be using LM tests anyway :)
-------------------------------------------------------
   Riccardo (Jack) Lucchetti
   Dipartimento di Scienze Economiche e Sociali (DiSES)
   Università Politecnica delle Marche
   (formerly known as Università di Ancona)
   r.lucchetti(a)univpm.it
   
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------