TSP Version 4.5 (03/30/00) DOS/Win 20MB Copyright (C) 2000 TSP International ALL RIGHTS RESERVED 12/01/03 0:50 AM In case of questions or problems, see your local TSP consultant or send a description of the problem and the associated TSP output to: TSP International P.O. Box 61015, Station A Palo Alto, CA 94306 USA PROGRAM COMMAND *************************************************************** 1 options crt memory=20 ; 2 ? ================================================== 2 ? [Dynamic Panel Data Estimation Using GMM (SYS)] 2 ? [without Time Dummies] 2 ? ================================================== 2 ? Designed by Yoshitsugu Kitazawa 2 ? First Design: 2003.11.29 Last Update: 2003.11.29 2 ? E-mail: kitazawa@ip.kyusan-u.ac.jp 2 ? ================================================== 2 ? ** This script realizes almost the same results 2 ? ** as Ox version DPD except for the serial correlation 2 ? ** tests. 2 ? ** This script is written on the accumulation of 2 ? ** the past technical supports by 2 ? ** Professor Bronwyn Hall and Dr. Clint Cummins. 2 ? ================================================== 2 ? * T=6: All time periods used for the estimation 2 ? * N=47: Number of individuals 2 ? * t = 1 to T and i = 1 to N 2 ? 2 ? * Estimation Model without Time Dummy 2 ? For all i (individual) and t (time), 2 ? y_{it} = alp * y_{i,t-1} + bet * x_{it} + u_{it} 2 ? and 2 ? u_{it} = eta_i + v_{it} 2 ? where y_{it} is the dependent variable, x_{it} is 2 ? the explanatory variable, alp and beta are the 2 ? parameter of interest to be estimated, eta_i is 2 ? the fixed effect (the nuisance parameter), and 2 ? v_{it} is the disturbance. In this model, x_{it} 2 ? is endogenous and E[u_{it} x_{is}]=0 for s=1 to t-1. 2 ? Further, it is supposed that y_{it} and x_{it} are 2 ? mean-stationary. 2 ? 2 ? * Moment Restrictions to be used for GMM (SYS) 2 ? * when estimating alp and bet in the model above. ? E[ du_{it} * y_{is} ] = 0, for s <= t-2 ; t = 3,...,T ? E[ du_{it} * x_{is} ] = 0, for s <= t-2 ; t = 3,...,T ? and 2 ? E[ u_{it} * dy_{i,t-1} ] = 0, for t=3,...,T 2 ? E[ u_{it} * dx_{i,t-1} ] = 0, for t=3,...,T 2 ? 2 ? * References 2 ? Arellano (2003): "Panel Data Econometrics", Oxford 2 ? University Press, Great Britain. 2 ? Arellano and Bond (1991): "Some test of specification 2 ? for panel data: Monte Carlo evidence and an application 2 ? to employment equations", Review of Economic Studies, 2 ? 58, 277-297. 2 ? Arellano and Bover (1995): "Another look at the 2 ? instrumental variables estimation of error-components 2 ? models", Journal of Econometrics, 68, 29-51. 2 ? Blundell and Bond (1998): "Initial conditions and 2 ? moment restrictions in dynamic panel data models", 2 ? Journal of Econometrics, 87, 115-143. 2 ? Doornik, Arellano, and Bond (2002): "Panel Data 2 ? estimation using DPD for Ox", 2 ? http://www.nuff.ox.ac.uk/Users/Doornik/papers/dpd.pdf 2 ? 2 ? * See on detail 2 ? http://www.ip.kyusan-u.ac.jp/J/keizai/kitazawa/SOFT/TSP_DPD1/index.htm 2 ? ===================================================== 2 2 input "cov1ssys.tsp" ; 2 ? ============================ cov1ssys ========================= 2 proc cov1ssys neq ivs imask an1 ; 3 3 ? This procedure makes a covariance matrix for the system GMM 3 ? estimator. The structure of the covariance matrix is the same 3 ? as one in p9 in "Panel Data estimation using DPD for Ox", 3 ? edited by Doornik, Arellano, and Bond (June 20, 2001), except 3 ? for the scaling. 3 ? The system GMM estimator is introduced in Blundell and Bond 3 ? (Journal of Econometrics, 1998) in detail. 3 ? 3 ? That is, for example, when T= 5, 3 ? 3 ? | 2 -1 0 0 0 | 3 ? | -1 2 -1 0 0 | 3 ? HD = | 0 -1 2 -1 0 | 3 ? | 0 0 -1 2 -1 | 3 ? | 0 0 0 -1 2 | 3 ? 3 ? | 1 0 0 0 0 | 3 ? | 0 1 0 0 0 | 3 ? I = | 0 0 1 0 0 | 3 ? | 0 0 0 1 0 | 3 ? | 0 0 0 0 1 | 3 ? 3 ? | 0 0 0 0 0 | 3 ? | 0 0 0 0 0 | 3 ? O = | 0 0 0 0 0 | 3 ? | 0 0 0 0 0 | 3 ? | 0 0 0 0 0 | 3 ? 3 ? H = | HD O | 3 ? | O I | 3 ? 3 ? Remark: Write the ivs list in the following order: 3 ? [Instruments List for Difference Equation] 3 ? [Instruments List for Level Equation] 3 ? and 3 ? in gmm command, write the equation list 3 ? in the following order: 3 ? gmm(...) difference_eq_list level_eq_list ; 3 ? 3 ? This procedure is made by Yoshitsgu Kitazawa 3 ? (probably August/03), refering to the cov1step.tsp 3 ? procedure designed by Clint Cummins (12/17/97). 3 3 ? neq - number of equations (time periods (T-2)*2), 3 ? where first T-2 is number of 1st dif eq while 3 ? last T-2 is number of level eq. 3 ? ivs - a list of instrumental variables. 3 ? imask - a ninst by neq matrix of zeros and ones that specifies 3 ? which instruments are used for which equation. 3 ? an1 - the covariance matrix estimate (returned). 3 3 local h i i1 diagm ; 4 local neqh neqhp1 ; 5 5 ? Make the theoretical covariance matrix of the equation residuals 5 ? (MA(1)). 5 5 ? In TSP 4.4 (rev. 8/97), this can be done with the BAND option to 5 ? MFORM: 5 ?mmake i 2 -1; ? vector of band values, starting with main diagonal 5 ?mform(band,nrow=neq) h = i; 5 5 set neqh = neq / 2 ; 6 set neqhp1 = neqh + 1 ; 7 7 mat h = 2*ident(neq) ; 8 if neq .gt. 2 ; then ; do ; 11 do i = 2 neqh ; 12 set i1 = i-1 ; 13 set h(i,i1) = -1 ; 14 enddo ; 15 do i = neqhp1 neq ; 16 set h(i,i) = h(i,i) / 2 ; 17 enddo ; 18 enddo ; 19 19 moment(noprint) ivs ; ? @mom = (z'z)/@nob 20 mat an1 = sym(h) # @mom ; 21 ? 21 ? Apply the mask to an1, to work around a bug in GMM 21 ? that was fixed on 12/17/97 21 ? 21 mat diagm = diag(vec(imask)); 22 mat an1 = diagm'an1*diagm; 23 23 endproc cov1ssys ; 24 ? ================================================================== 24 input "cov2stpm.tsp" ; 24 ? ============================ cov2stpm ========================= 24 proc cov2stpm eqs ivs imask an2 ; 25 25 ? This is as same as cov2step procedure by Dr. Clint Cummins, only 25 ? changing name of procedure, etc. see 25 ? http://www.stanford.edu/~clint/tspex/group.htm#G 25 ? The description below is the description in cov2step procedure 25 ? made by Dr. Clint Cummins. 25 25 ? Procedure to compute the estimated two-step covariance matrix for 25 ? GMM estimation (after first step estimation). 25 ? see Arellano and Bond (REStud 91 for details). 25 ? Benchmarked with Steve Bond using DPD and these give estimates that 25 ? match his. TSP's default GMM estimator does not match the cov2step 25 ? results - the default GMM is more like a 3-step estimator since it 25 ? does 2SLS, 3SLS, and then GMM. 25 ? simple version, by Clint Cummins 9/97 25 25 ? This procedure is preferable in terms of controlling for 25 ? missing values. 25 25 ? eqs - equations (number of column of mask matrix, imask) 25 ? ivs - a list of instrumental variables 25 ? imask - a ninst by neq matrix of zeros and ones that specifies 25 ? which instruments are used for which equation. 25 ? an2 - the covariance matrix estimate (returned). 25 25 ? supres nob phi gmmovid coef; 25 gmm(covoc=own,hetero,maxit=0,nolsqstart,silent,inst=ivs,mask=imask) eqs; 26 ? nosupres nob phi gmmovid coef; 26 mat an2 = @covoc; 27 endproc cov2stpm ; 28 ? ================================================================== 28 28 28 28 input "evdgen.tsp" ; 28 ? ================== evdgen =================== 28 proc evdgen sigres ; 29 ? procedure to generate sigma_v in Arellano and Bond (1991) for 29 ? 1-step estimator for the dynamic panel data model. 29 ? This is used for estimating the variance of the parameter estimate 29 ? and for generating the Sargan test for 1-step estimation. 29 ? It is assumed that the disturbances in the model is homoscedastic 29 ? cross-sectionally and over time. 29 ? The sigma_v is the estimate of the variance of the disturbance 29 ? for the first-differenced equations. 29 ? sig_v = residual' residual / (#eq * #obs - #param) 29 ? where residual is ((#eq * #obs) by 1) vector. 29 ? When GMM 1-step estimation, implement 29 ? cov1stpd ... ani1 ; 29 ? mat ani1 = ani1 / 2 ; 29 ? gmm(..optcov ..) eqn ; 29 ? evdgen sr1 ; 29 ? set @gmmovid = @gmmovid / sr1 ; 29 ? mat @vcov = @vcov * sr1 ; 29 ? by Yoshitsugu Kitazawa, (2001, 11, 2) 29 ? --------------------------------------------- 29 local resv sigresp np tn ; 30 mat resv = vec(@res) ; 31 mat sigresp = resv' resv ; 32 mat tn = nrow(resv) ; 33 length @rnms np ; 34 set sigres = sigresp / (tn - np) ; 35 endproc evdgen ; 36 ? ================== evdgen =================== 36 input "lm2test2.tsp" ; 36 ? ============================= lm2test2 ========================== 36 proc lm2test2 ; 37 ? 37 ? Procedure to perform tests for 1st and 2nd order serial 37 ? correlation after GMM estimation with panel data. 37 ? It is the same asymptotically as the Arellano-Bond test (REStud 1991) 37 ? and easier to compute; also it is defined when the model is 37 ? nonlinear. In the cases checked, it was the same as A-B to 37 ? at least 5%, which is good enough. It does not seem to be biased. 37 37 ? by Bronwyn H. Hall, Jan. 97; revised by Clint Cummins 10/97 37 ? requires TSP 4.3 or later (list(first=,last=) options) 37 ? 37 local savsmp nob neq maxlag tlag ntlag test armom ilag ilag1 37 nu us umat u ulag; 38 38 mat neq = ncol(@res) ; 39 if neq = 1; then; goto 900; ? give up if no possible lags 42 set maxlag = (neq-1); 43 if maxlag .gt. 2; then; set maxlag = 2; ? max lag of 2 here, but 46 ? it could be set higher if desired (could be an argument of the proc) 46 list(last=neq,prefix=nu) nulist ; 47 local nulist ; 48 copy @smpl savsmp ; ? Save sample. 49 49 set nob = @nob ; 50 smpl 1 nob ; ? This procedure expects contiguous data. 51 unmake @res nulist ; ? Put the residuals in the variables in nulist. 52 do ilag=1,maxlag; 53 set tlag = neq-ilag ; 54 set ntlag = nob*tlag ; ? Number of obs with lag ilag. 55 set ilag1 = ilag+1; 56 list(first=ilag1,last=neq, prefix=nu) us; ? unlagged residuals 57 smpl 1,nob; mmake umat us; 59 smpl 1,ntlag; unmake umat u; 61 list(first=1, last=tlag,prefix=nu) us; ? lagged residuals 62 smpl 1,nob; mmake umat us; 64 smpl 1,ntlag; unmake umat ulag; 66 66 ? Test for Lag ilag Serial Correlation. 66 66 armom = u*ulag ; ? serial correlation estimate 67 msd(silent,terse) armom ; 68 set test = @mean / (@stddev/sqrt(ntlag)) ; 69 title "Standard LM Test for Serial Correlation with HS" ; 70 write(format="(' Order of Serial Correlation:',F3.0)") ilag; 71 cdf(normal) test ; ? Standard LM test. 72 72 enddo ; 73 73 smpl savsmp ; ? Restore the sample. 74 900 endproc lm2test2 ; 75 ? ============================================================= 75 75 frml du2 0 ; ? dummy equation 76 frml du3 dy3 - ( alp * dy2 + bet * dx3 ) ; 77 frml du4 dy4 - ( alp * dy3 + bet * dx4 ) ; 78 frml du5 dy5 - ( alp * dy4 + bet * dx5 ) ; 79 frml du6 dy6 - ( alp * dy5 + bet * dx6 ) ; 80 80 frml u2 y2 - ( alp * y1 + bet * x2 ) ; 81 frml u3 y3 - ( alp * y2 + bet * x3 ) ; 82 frml u4 y4 - ( alp * y3 + bet * x4 ) ; 83 frml u5 y5 - ( alp * y4 + bet * x5 ) ; 84 frml u6 y6 - ( alp * y5 + bet * x6 ) ; 85 85 list eq_sys du2-du6 u2-u6 ; 86 86 list zc_sys y1-y4 x1-x4 dy2-dy5 dx2-dx5 ; 87 87 load(nrow=16, ncol=10) zm_sys; 87 0 1 1 1 1 0 0 0 0 0 87 0 0 1 1 1 0 0 0 0 0 87 0 0 0 1 1 0 0 0 0 0 87 0 0 0 0 1 0 0 0 0 0 87 ? --- 87 0 1 1 1 1 0 0 0 0 0 87 0 0 1 1 1 0 0 0 0 0 87 0 0 0 1 1 0 0 0 0 0 87 0 0 0 0 1 0 0 0 0 0 87 ? --- 87 0 0 0 0 0 0 1 0 0 0 87 0 0 0 0 0 0 0 1 0 0 87 0 0 0 0 0 0 0 0 1 0 87 0 0 0 0 0 0 0 0 0 1 87 ? --- 87 0 0 0 0 0 0 1 0 0 0 87 0 0 0 0 0 0 0 1 0 0 87 0 0 0 0 0 0 0 0 1 0 87 0 0 0 0 0 0 0 0 0 1 87 ; 88 88 mat neqx = ncol(zm_sys) ; 89 89 89 freq n ; 90 smpl 1 47 ; 91 read(file="ydata.txt") code y1-y6 ; 92 read(file="xdata.txt") code x1-x6 ; 93 93 ? print y1-y6 ; 93 ? print x1-x6 ; 93 93 genr dy2 = y2 -y1 ; 94 genr dy3 = y3 -y2 ; 95 genr dy4 = y4 -y3 ; 96 genr dy5 = y5 -y4 ; 97 genr dy6 = y6 -y5 ; 98 98 genr dx2 = x2 -x1 ; 99 genr dx3 = x3 -x2 ; 100 genr dx4 = x4 -x3 ; 101 genr dx5 = x5 -x4 ; 102 genr dx6 = x6 -x5 ; 103 103 103 param alp bet ; 104 title "" ; 105 cov1ssys neqx zc_sys zm_sys ani1 ; 106 mat ani1 = ani1 / 2 ; 107 gmm(covoc=ani1, noiteroc, nooptcov, hetero, nma=0, 107 maxit=100, silent, inst=zc_sys, mask=zm_sys) eq_sys ; 108 print alp bet ; 109 tstats(name=@rnms) @coef @vcov ; 110 title "Sargan Test for 1 step estimation" ; 111 copy @res restmp ; unmake @res r1-r10 ; mmake @res r6-r10 ; evdgen sr1 ; 115 set sargan = @gmmovid / sr1 ; 116 copy restmp @res ; 117 print sargan ; cdf(chi, df=@novid) sargan ; 119 title "Serial Correlation Tests, AR(1) and AR(2)" ; 120 copy @res restmp ; unmake @res r1-r10 ; mmake @res r2-r5 ; 123 regopt(noprint) all ; lm2test2 ; regopt ; 126 copy restmp @res ; 127 127 127 title "" ; 128 regopt(noprint) all ; 129 cov2stpm eq_sys zc_sys zm_sys ani2 ; 130 regopt ; 131 gmm(covoc=ani2, noiteroc, optcov, hetero, nma=0, 131 maxit=100, silent, inst=zc_sys, mask=zm_sys) eq_sys ; 132 print alp bet ; 133 tstats(name=@rnms) @coef @vcov ; 134 title "Sargan Test for 2 step estimation" ; 135 set sargan = @gmmovid ; 136 print sargan ; cdf(chi, df=@novid) sargan ; 138 title "Serial Correlation Tests, AR(1) and AR(2)" ; 139 copy @res restmp ; unmake @res r1-r10 ; mmake @res r2-r5 ; 142 regopt(noprint) all ; lm2test2 ; regopt ; 145 copy restmp @res ; 146 146 stop ; 147 end ; EXECUTION ******************************************************************************* Current sample: 1 to 47 ===================== ALP BET Value -0.48592 -0.017177 Standard Parameter Estimate Error t-statistic P-value ALP -.485923 .072969 -6.65928 [.000] BET -.017177 .047384 -.362503 [.717] Sargan Test for 1 step estimation ================================= SARGAN = 49.08770 CHISQ(26) Test Statistic: 49.08770, Upper tail area: .00403 Serial Correlation Tests, AR(1) and AR(2) ========================================= Univariate statistics ===================== Number of Observations: 141 Mean Std Dev Minimum Maximum ARMOM -1.03631 2.57129 -18.06604 5.27354 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 1. NORMAL Test Statistic: -4.785744, Two-tailed area: .00000 Univariate statistics ===================== Number of Observations: 94 Mean Std Dev Minimum Maximum ARMOM 0.062372 1.84558 -7.28165 5.49718 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 2. NORMAL Test Statistic: 0.3276574, Two-tailed area: .74317 ===================== ALP BET Value -0.48673 -0.019932 Standard Parameter Estimate Error t-statistic P-value ALP -.486730 .036903 -13.1893 [.000] BET -.019932 .023769 -.838564 [.402] Sargan Test for 2 step estimation ================================= SARGAN = 25.62619 CHISQ(26) Test Statistic: 25.62619, Upper tail area: .48379 Serial Correlation Tests, AR(1) and AR(2) ========================================= Univariate statistics ===================== Number of Observations: 141 Mean Std Dev Minimum Maximum ARMOM -1.04649 2.59061 -18.19918 5.32813 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 1. NORMAL Test Statistic: -4.796691, Two-tailed area: .00000 Univariate statistics ===================== Number of Observations: 94 Mean Std Dev Minimum Maximum ARMOM 0.068896 1.85976 -7.31033 5.60185 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 2. NORMAL Test Statistic: 0.3591700, Two-tailed area: .71947 ******************************************************************************* END OF OUTPUT. MEMORY USAGE: ITEM: DATA ARRAY TOTAL MEMORY UNITS: (4-BYTE WORDS) (MEGABYTES) MEMORY ALLOCATED : 4500000 20.0 MEMORY ACTUALLY REQUIRED : 241071 3.1 CURRENT VARIABLE STORAGE : 89242