? Procedure to Compute Spatial Correlation Consistent Standard Errors ? for Linear Instrumental Variable Panel Data Models ? based on ? John C. Driscoll and Aart C. Kraay (1998) ? "Consistent-Covariance Matrix Estimation With ? Spatially Dependent Panel Data" ? Review of Economics and Statistics. November. pp. 549-560 ? Authors: ? John C. Driscoll ? Department of Economics ? Brown University, Box B ? Providence RI 02912 ? John_Driscoll@brown.edu ? Aart C. Kraay ? The World Bank ? Washington DC 20433 ? akraay@worldbank.org ? Notes: ? The procedure computes coefficient estimates and standard ? errors consistent for spatial correlation, autocorrelation and ? heteroskedasticity for linear instrument-variable panel data ? models of the form ? y(i,t)=x(i,t)'b+e(i,t) ? where x(i,t) is an Lx1 vector of explanatory variables; b is an ? Lx1 coefficient vector; e(i,t) is a residual; and i=1,...,N indexes ? cross-sectional units and t=1,...,T indexes time periods. The ? model is identified by a Kx1 vector of orthogonality conditions ? E[z(i,t)'e(i,t)]=0, where z(i,t) is a Kx1 vector of instrumental ? variables with K>=L. If the model contains individual effects, ? these must first be removed by the appropriate transformation ? (i.e. differencing or taking deviations from individual means). ? The procedure does not support missing values. ? The procedure takes the form ? scc y x z N T lag thetahat sdthetahat; ? where ? y is the dependent variable ? x is a list of L explanatory variables ? z is a list of K instrumental variables, K>=L ? N is the number of cross-sectional units ? T is the number of time-series observations ? lag is the lag-truncation parameter. ? thetahat, sdthetahat are matrices in which the IV coefficient ? estimates and standard errors will be returned ? The data must be supplied in series with the TSP frequency ? option set to "None" (i.e. FREQ N), and must be ordered ? as in paper (i.e. the first N element contain the N cross-sectional ? units for the first time period, the second N rows contain the N ? cross-sectional units for the second time period, etc.). ? We use the Bartlett kernel. The procedure outputs two-stage ? least squares estimates and spatial-correlation consistent ? standard errors. To obtain OLS estimates, simply use the same ? variables for z and x. proc scc yvars xvars zvars N T lag thetahat sdthetahat; regopt (noprint) @smpl; length xvars L; length zvars K; set NT=N*T; ? Obtain IV estimator thetahat and estimated residuals r ? freq n;smpl 1 NT; mmake ymat yvars;mmake xmat xvars;mmake zmat zvars; mat thetahat=((zmat'xmat)")*(zmat'ymat); mat resids=ymat-xmat*thetahat; unmake resids resids; ? Compute Omega(0) smpl 1 N; mmake zt zvars;mmake ehat resids; mat ht=zt'ehat/N; mat omega0=ht*ht'; do j=2 to T; set ll=(j-1)*N+1;set uu=j*N; smpl ll uu; mmake zt zvars;mmake ehat resids; mat ht=zt'ehat/N; mat omega0=omega0+ht*ht'; enddo; mat shat=omega0*(1/T); if lag>0;then;do; do s=1 to lag; set ll=s*N+1;set uu=(s+1)*N;smpl ll uu; mmake zt zvars;mmake ehat resids;mat ht=zt'ehat/N; smpl 1 N; mmake ztl zvars;mmake ehatl resids;mat htl=ztl'ehatl/N; mat omega=ht*htl'; set start=s+2; do j=start to T; set ll=(j-1)*N+1;set uu=j*N;smpl ll uu; mmake zt zvars;mmake ehat resids;mat ht=zt'ehat/N; set ll=(j-s-1)*N+1;set uu=(j-s)*N;smpl ll uu; mmake ztl zvars;mmake ehatl resids;mat htl=ztl'ehatl/N; mat omega=omega+ht*htl'; enddo; mat omega=(omega+omega')*(1/(T)); mat shat=shat+(1-s/(lag+1))*omega; enddo; enddo; mat mmat=(1/(N*T))*(xmat'zmat); mat vhat=(mmat*(shat")*mmat')"; mat vhat=vhat/T; mat vhat=diag(vhat); smpl 1 K; unmake vhat vhat; vhat=vhat**(1/2); mmake vhat vhat; mat sdthetahat=vhat; regopt (print) @smpl; endp;