? ============================ cov1step ========================= proc cov1step neq ninst mask ivs an1 ; ? Procedure to compute the estimated one-step covariance matrix for ? GMM estimation; see Arellano and Bond (REStud 91 for details). ? Benchmarked with Steve Bond using DPD and these give estimates that ? match his. ? This version by Bronwyn H. Hall, based on a program by Benoit Mulkay. ? Minor revisions by Clint Cummins 3/97 ? Requires TSP 4.3 or later (nooptcov option in GMM, when an1 is used) ? Note that sample must be contiguous and start at 1 in this version. ? neq - number of equations (time periods T-2). ? ninst - number of instruments per equation. ? mask - a ninst by neq matrix of zeros and ones that specifies ? which instruments are used for which equation. ? ivs - a list of instrumental variables (ninst long). ? an1 - the covariance matrix estimate (returned). local nob noc h i1 mz im ineq idt i z zi zm zj ; copy @smpl savsmp ; ? Save the current sample. copy @nob nob ; ? Make the theoretical covariance matrix of the equation residuals ? (MA(1)). mat h = 2*ident(neq) ; if neq .gt. 1 ; then ; do ; do i = 2 neq ; set i1 = i-1 ; set h(i,i1) = -1 ; enddo ; enddo ; ? Now compute the estimate of An by looping over the panel and ? summing over the individual estimate (this version is ? heteroskedastic-consistent). mat im = vech(ident(ninst)) ; ? ninst x 1 unit vector. mat idt = ident(neq) ; mat mz = idt # im ; mat ineq = vech(idt) ; ? neq x 1 unit vector ? Make sure mask is a row vector. set noc = neq*ninst ; mform (nrow=noc,ncol=1) mask ; mform(nrow=noc,type=sym) an1 = 0 ; do i = 1 nob ; smpl i i ; mmake z ivs ; mat zi = ineq # z' ; mat zm = zi % mask ; mform (nrow=noc,ncol=1) zm ; mat zj = mz % (ineq'#zm) ; mat an1 = an1+(zj*h*zj') ; ? Second method of computation - more space but simpler. ? May be easier to follow. It gives identical results. ? mat zs = (idt # z)*diag(mask); ? mat an1 = an1 + (zs'h*zs) ; enddo ; smpl savsmp ; mat an1 = an1/nob ; endproc cov1step ; ? ==================================================================