? ============================= lm2test ========================== proc lm2test ; ? ? 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; minor revisions by Clint Cummins 3/97 ? requires TSP 4.4 or later (subscripted list feature) ? local nob neq t1 t2 savsmp j j1 test nu1nu nu2nu nu nul2 nul1 nu2star nu2star1 nulist ; mat neq = ncol(@res) ; list(last=neq,prefix=nu) nulist ; local nulist ; set nob = @nob ; set t1 = neq-1 ; set t2 = neq-2 ; ? For 2nd order test, T-2 residuals. copy @smpl savsmp ; ? Save sample. smpl 1 nob ; ? This procedure expects contiguous data. unmake @res nulist ; ? Put the residuals in the variables in nulist. if neq .gt. 1 ; then ; do ; list nu1list nulist(1) ; ? Make a list of the first T-1 residuals. list nu1stlst nulist(2) ; ? Make a list of the last T-1 residuals. if neq .gt. 2 ; then ; do ; list nu2list nulist(1) ; ? Make a list of the first T-2 residuals. list nu2stlst nulist(3) ; ? Make a list of the last T-2 residuals. do j = 2 to t1 ; set j1 = j+1 ; list nu1list nu1list nulist(j) ; list nu1stlst nu1stlst nulist(j1) ; enddo ; if neq .gt. 3 ; then ; do ; do j = 2 to t2 ; set j1 = j+2; list nu2list nu2list nulist(j) ; list nu2stlst nu2stlst nulist(j1) ; enddo ; enddo ; enddo ; enddo ; mmake nul2 nu2list ; ? The lag 2 residuals (T-2 of them). mmake nul1 nu1list ; ? The lag 1 residuals (T-1 of them). mmake nu2star nu2stlst ; ? The last T-2 residuals. mmake nu1star nu1stlst ; ? The last T-1 residuals. set nt2 = nob*t2 ; ? Number of obs with lag 2. set nt1 = nob*t1 ; ? Number of obs with lag 1. ? Test for Lag 1 Serial Correlation. smpl 1 nt1 ; unmake nul1 nul1 ; unmake nu1star nu1star ; nu1nu = nul1*nu1star ; ? First order serial correlation estimate nu1nu = nu1nu*(nu1nu~=0) + @mv*(nu1nu=0) ; ? For unbalanced panels where nu==0. msd (pair,silent) nu1nu ; set test = sqrt(@nobmsd)*@mean/@stddev ; title "Standard LM Test for First Order Serial Correlation with HS" ; cdf(normal) test ; ? Standard LM test. ? Test for Lag 2 Serial Correlation. smpl 1 nt2 ; unmake nul2 nul2 ; unmake nu2star nu2star ; nu2nu = nul2*nu2star ; ? Second order serial correlation estimate nu2nu = nu2nu*(nu2nu~=0) + @mv*(nu2nu=0) ; ? For unbalanced panels where nu==0. msd (pair,silent) nu2nu ; set test = sqrt(@nobmsd)*@mean/@stddev ; title "Standard LM Test for Second Order Serial Correlation with HS" ; cdf(normal) test ; ? Standard LM test. smpl savsmp ; ? Restore the sample. endproc abtest ; ? =============================================================