? ============================= lm2test2 ========================== proc lm2test2 ; ? ? Procedure to perform tests for 1st and 2nd order serial ? correlation after GMM estimation with panel data. ? It is the same asymptotically as the Arellano-Bond test (REStud 1991) ? and easier to compute; also it is defined when the model is ? nonlinear. In the cases checked, it was the same as A-B to ? at least 5%, which is good enough. It does not seem to be biased. ? by Bronwyn H. Hall, Jan. 97; revised by Clint Cummins 10/97 ? requires TSP 4.3 or later (list(first=,last=) options) ? local savsmp nob neq maxlag tlag ntlag test armom ilag ilag1 nu us umat u ulag; mat neq = ncol(@res) ; if neq = 1; then; goto 900; ? give up if no possible lags set maxlag = (neq-1); if maxlag .gt. 2; then; set maxlag = 2; ? max lag of 2 here, but ? it could be set higher if desired (could be an argument of the proc) list(last=neq,prefix=nu) nulist ; local nulist ; copy @smpl savsmp ; ? Save sample. set nob = @nob ; smpl 1 nob ; ? This procedure expects contiguous data. unmake @res nulist ; ? Put the residuals in the variables in nulist. do ilag=1,maxlag; set tlag = neq-ilag ; set ntlag = nob*tlag ; ? Number of obs with lag ilag. set ilag1 = ilag+1; list(first=ilag1,last=neq, prefix=nu) us; ? unlagged residuals smpl 1,nob; mmake umat us; smpl 1,ntlag; unmake umat u; list(first=1, last=tlag,prefix=nu) us; ? lagged residuals smpl 1,nob; mmake umat us; smpl 1,ntlag; unmake umat ulag; ? Test for Lag ilag Serial Correlation. armom = u*ulag ; ? serial correlation estimate msd(silent,terse) armom ; set test = @mean / (@stddev/sqrt(ntlag)) ; title "Standard LM Test for Serial Correlation with HS" ; write(format="(' Order of Serial Correlation:',F3.0)") ilag; cdf(normal) test ; ? Standard LM test. enddo ; smpl savsmp ; ? Restore the sample. 900 endproc lm2test2 ; ? =============================================================