TSP Version 4.5 (03/30/00) DOS/Win 20MB Copyright (C) 2000 TSP International ALL RIGHTS RESERVED 12/01/03 0:51 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 (DIF)] 2 ? [with Time Dummies] 2 ? ================================================== 2 ? Designed by Yoshitsugu Kitazawa 2 ? First Design: 2003.11.29 Last Update: 2003.11.30 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} + TD_t + 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 ? In addition, (TD_t)s are the time dummies to be 2 ? estimated. (When using GMM (DIF), (dTD_t)s are 2 ? the time dummies to be estimated.) 2 ? 2 ? * Moment Restrictions to be used for GMM (DIF) 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[ du_{it} ] = 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 ? 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 "cov1spdm.tsp" ; 2 ? ============================ cov1spdm ========================= 2 proc cov1spdm neq ivs imask an1 ; 3 3 ? This procedure is as same as cov1step.tsp procedure 3 ? made by Prof. Hall and Dr. Cummins. Explanations are same, too. 3 ? | 2 -1 0 0 0 | 3 ? | -1 2 -1 0 0 | 3 ? H = | 0 -1 2 -1 0 | when T = 5 3 ? | 0 0 -1 2 -1 | 3 ? | 0 0 0 -1 2 | 3 ? 3 3 ? Procedure to compute the estimated one-step covariance matrix for 3 ? GMM estimation; see Arellano and Bond (REStud 91 for details). 3 ? Benchmarked with Steve Bond using DPD and these give estimates that 3 ? match his. 3 3 ? This version is by Clint Cummins 7/97, and revised 12/97. 3 ? The 7/97 assumed that GMM would apply the mask to this COVOC, 3 ? but there was a bug in GMM that prevented this from operating 3 ? correctly. That bug was fixed on 12/17/97, but we will apply 3 ? the mask to an1 here, so that earlier versions of TSP with this 3 ? bug will operate correctly. 3 ? The form before using the mask is: an1 = ( h # (z'z) ) / @nob . 3 ? requires TSP 4.3 or later (nooptcov option in GMM, when an1 is used) 3 3 ? neq - number of equations (time periods T-2). 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 4 ? Make the theoretical covariance matrix of the equation residuals 4 ? (MA(1)). 4 4 ? In TSP 4.4 (rev. 8/97), this can be done with the BAND option to 4 ? MFORM: 4 ?mmake i 2 -1; ? vector of band values, starting with main diagonal 4 ?mform(band,nrow=neq) h = i; 4 4 mat h = 2*ident(neq) ; 5 if neq .gt. 1 ; then ; do ; 8 do i = 2 neq ; 9 set i1 = i-1 ; 10 set h(i,i1) = -1 ; 11 enddo ; 12 enddo ; 13 13 moment(noprint) ivs ; ? @mom = (z'z)/@nob 14 mat an1 = sym(h) # @mom ; 15 ? 15 ? Apply the mask to an1, to work around a bug in GMM 15 ? that was fixed on 12/17/97 15 ? 15 mat diagm = diag(vec(imask)); 16 mat an1 = diagm'an1*diagm; 17 17 endproc cov1spdm ; 18 ? ================================================================== 18 input "cov2stpm.tsp" ; 18 ? ============================ cov2stpm ========================= 18 proc cov2stpm eqs ivs imask an2 ; 19 19 ? This is as same as cov2step procedure by Dr. Clint Cummins, only 19 ? changing name of procedure, etc. see 19 ? http://www.stanford.edu/~clint/tspex/group.htm#G 19 ? The description below is the description in cov2step procedure 19 ? made by Dr. Clint Cummins. 19 19 ? Procedure to compute the estimated two-step covariance matrix for 19 ? GMM estimation (after first step estimation). 19 ? see Arellano and Bond (REStud 91 for details). 19 ? Benchmarked with Steve Bond using DPD and these give estimates that 19 ? match his. TSP's default GMM estimator does not match the cov2step 19 ? results - the default GMM is more like a 3-step estimator since it 19 ? does 2SLS, 3SLS, and then GMM. 19 ? simple version, by Clint Cummins 9/97 19 19 ? This procedure is preferable in terms of controlling for 19 ? missing values. 19 19 ? eqs - equations (number of column of mask matrix, imask) 19 ? ivs - a list of instrumental variables 19 ? imask - a ninst by neq matrix of zeros and ones that specifies 19 ? which instruments are used for which equation. 19 ? an2 - the covariance matrix estimate (returned). 19 19 ? supres nob phi gmmovid coef; 19 gmm(covoc=own,hetero,maxit=0,nolsqstart,silent,inst=ivs,mask=imask) eqs; 20 ? nosupres nob phi gmmovid coef; 20 mat an2 = @covoc; 21 endproc cov2stpm ; 22 ? ================================================================== 22 22 22 22 input "evdgen.tsp" ; 22 ? ================== evdgen =================== 22 proc evdgen sigres ; 23 ? procedure to generate sigma_v in Arellano and Bond (1991) for 23 ? 1-step estimator for the dynamic panel data model. 23 ? This is used for estimating the variance of the parameter estimate 23 ? and for generating the Sargan test for 1-step estimation. 23 ? It is assumed that the disturbances in the model is homoscedastic 23 ? cross-sectionally and over time. 23 ? The sigma_v is the estimate of the variance of the disturbance 23 ? for the first-differenced equations. 23 ? sig_v = residual' residual / (#eq * #obs - #param) 23 ? where residual is ((#eq * #obs) by 1) vector. 23 ? When GMM 1-step estimation, implement 23 ? cov1stpd ... ani1 ; 23 ? mat ani1 = ani1 / 2 ; 23 ? gmm(..optcov ..) eqn ; 23 ? evdgen sr1 ; 23 ? set @gmmovid = @gmmovid / sr1 ; 23 ? mat @vcov = @vcov * sr1 ; 23 ? by Yoshitsugu Kitazawa, (2001, 11, 2) 23 ? --------------------------------------------- 23 local resv sigresp np tn ; 24 mat resv = vec(@res) ; 25 mat sigresp = resv' resv ; 26 mat tn = nrow(resv) ; 27 length @rnms np ; 28 set sigres = sigresp / (tn - np) ; 29 endproc evdgen ; 30 ? ================== evdgen =================== 30 input "lm2test2.tsp" ; 30 ? ============================= lm2test2 ========================== 30 proc lm2test2 ; 31 ? 31 ? Procedure to perform tests for 1st and 2nd order serial 31 ? correlation after GMM estimation with panel data. 31 ? It is the same asymptotically as the Arellano-Bond test (REStud 1991) 31 ? and easier to compute; also it is defined when the model is 31 ? nonlinear. In the cases checked, it was the same as A-B to 31 ? at least 5%, which is good enough. It does not seem to be biased. 31 31 ? by Bronwyn H. Hall, Jan. 97; revised by Clint Cummins 10/97 31 ? requires TSP 4.3 or later (list(first=,last=) options) 31 ? 31 local savsmp nob neq maxlag tlag ntlag test armom ilag ilag1 31 nu us umat u ulag; 32 32 mat neq = ncol(@res) ; 33 if neq = 1; then; goto 900; ? give up if no possible lags 36 set maxlag = (neq-1); 37 if maxlag .gt. 2; then; set maxlag = 2; ? max lag of 2 here, but 40 ? it could be set higher if desired (could be an argument of the proc) 40 list(last=neq,prefix=nu) nulist ; 41 local nulist ; 42 copy @smpl savsmp ; ? Save sample. 43 43 set nob = @nob ; 44 smpl 1 nob ; ? This procedure expects contiguous data. 45 unmake @res nulist ; ? Put the residuals in the variables in nulist. 46 do ilag=1,maxlag; 47 set tlag = neq-ilag ; 48 set ntlag = nob*tlag ; ? Number of obs with lag ilag. 49 set ilag1 = ilag+1; 50 list(first=ilag1,last=neq, prefix=nu) us; ? unlagged residuals 51 smpl 1,nob; mmake umat us; 53 smpl 1,ntlag; unmake umat u; 55 list(first=1, last=tlag,prefix=nu) us; ? lagged residuals 56 smpl 1,nob; mmake umat us; 58 smpl 1,ntlag; unmake umat ulag; 60 60 ? Test for Lag ilag Serial Correlation. 60 60 armom = u*ulag ; ? serial correlation estimate 61 msd(silent,terse) armom ; 62 set test = @mean / (@stddev/sqrt(ntlag)) ; 63 title "Standard LM Test for Serial Correlation with HS" ; 64 write(format="(' Order of Serial Correlation:',F3.0)") ilag; 65 cdf(normal) test ; ? Standard LM test. 66 66 enddo ; 67 67 smpl savsmp ; ? Restore the sample. 68 900 endproc lm2test2 ; 69 ? ============================================================= 69 69 frml du3 dy3 - ( alp * dy2 + bet * dx3 + td3 ) ; 70 frml du4 dy4 - ( alp * dy3 + bet * dx4 + td4 ) ; 71 frml du5 dy5 - ( alp * dy4 + bet * dx5 + td5 ) ; 72 frml du6 dy6 - ( alp * dy5 + bet * dx6 + td6 ) ; 73 73 list eq_dif du3-du6 ; 74 74 list zc_dif y1-y4 x1-x4 c ; 75 75 load(nrow=9, ncol=4) zm_dif ; 75 1 1 1 1 75 0 1 1 1 75 0 0 1 1 75 0 0 0 1 75 ? --- 75 1 1 1 1 75 0 1 1 1 75 0 0 1 1 75 0 0 0 1 75 ? --- 75 1 1 1 1 75 ; 76 76 mat neqx = ncol(zm_dif) ; 77 77 frml zr_td3 td3 - 0 ; 78 frml zr_td4 td4 - 0 ; 79 frml zr_td5 td5 - 0 ; 80 frml zr_td6 td6 - 0 ; 81 list zr_tds zr_td3-zr_td6 ; 82 82 82 freq n ; 83 smpl 1 47 ; 84 read(file="ydata.txt") code y1-y6 ; 85 read(file="xdata.txt") code x1-x6 ; 86 86 ? print y1-y6 ; 86 ? print x1-x6 ; 86 86 genr dy2 = y2 - y1 ; 87 genr dy3 = y3 - y2 ; 88 genr dy4 = y4 - y3 ; 89 genr dy5 = y5 - y4 ; 90 genr dy6 = y6 - y5 ; 91 91 genr dx2 = x2 - x1 ; 92 genr dx3 = x3 - x2 ; 93 genr dx4 = x4 - x3 ; 94 genr dx5 = x5 - x4 ; 95 genr dx6 = x6 - x5 ; 96 96 96 param alp bet td3-td6 ; 97 title "" ; 98 cov1spdm neqx zc_dif zm_dif ani1 ; 99 mat ani1 = ani1 / 2 ; 100 gmm(covoc=ani1, noiteroc, nooptcov, hetero, nma=0, 100 maxit=100, silent, inst=zc_dif, mask=zm_dif) eq_dif ; 101 print alp bet ; 102 print td3-td6 ; 103 tstats(name=@rnms) @coef @vcov ; 104 title "Wald Test: H_0: Time Dummies are all zero" ; 105 analyz zr_tds ; 106 title "Sargan Test for 1 step estimation" ; 107 evdgen sr1 ; 108 set sargan = @gmmovid / sr1 ; 109 print sargan ; cdf(chi, df=@novid) sargan ; 111 title "Serial Correlation Tests, AR(1) and AR(2)" ; 112 regopt(noprint) all ; lm2test2 ; regopt ; 115 115 115 title "" ; 116 regopt(noprint) all ; 117 cov2stpm eq_dif zc_dif zm_dif ani2 ; 118 regopt ; 119 gmm(covoc=ani2, noiteroc, optcov, hetero, nma=0, 119 maxit=100, silent, inst=zc_dif, mask=zm_dif) eq_dif ; 120 print alp bet ; 121 print td3-td6 ; 122 tstats(name=@rnms) @coef @vcov ; 123 title "Wald Test: H_0: Time Dummies are all zero" ; 124 analyz zr_tds ; 125 title "Sargan Test for 2 step estimation" ; 126 set sargan = @gmmovid ; 127 print sargan ; cdf(chi, df=@novid) sargan ; 129 title "Serial Correlation Tests, AR(1) and AR(2)" ; 130 regopt(noprint) all ; lm2test2 ; regopt ; 133 133 stop ; 134 end ; EXECUTION ******************************************************************************* Current sample: 1 to 47 ===================== ALP BET Value -0.51303 0.017139 TD3 TD4 TD5 TD6 Value -0.33228 0.025868 0.093809 0.30856 Standard Parameter Estimate Error t-statistic P-value ALP -.513033 .067424 -7.60904 [.000] BET .017139 .047539 .360521 [.718] TD3 -.332282 .209942 -1.58273 [.113] TD4 .025868 .208596 .124009 [.901] TD5 .093809 .158338 .592458 [.554] TD6 .308562 .179227 1.72163 [.085] Wald Test: H_0: Time Dummies are all zero ========================================= Results of Parameter Analysis ============================= Standard Parameter Estimate Error t-statistic P-value ZR_TD3 -.332282 .209942 -1.58273 [.113] ZR_TD4 .025868 .208596 .124009 [.901] ZR_TD5 .093809 .158338 .592458 [.554] ZR_TD6 .308562 .179227 1.72163 [.085] Wald Test for the Hypothesis that the given set of Parameters are jointly zero: CHISQ(4) = 7.5313055 ; P-value = 0.11034 Sargan Test for 1 step estimation ================================= SARGAN = 21.00249 CHISQ(18) Test Statistic: 21.00249, Upper tail area: .27929 Serial Correlation Tests, AR(1) and AR(2) ========================================= Univariate statistics ===================== Number of Observations: 141 Mean Std Dev Minimum Maximum ARMOM -0.88093 2.23388 -14.99340 4.17810 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 1. NORMAL Test Statistic: -4.682665, Two-tailed area: .00000 Univariate statistics ===================== Number of Observations: 94 Mean Std Dev Minimum Maximum ARMOM -0.063359 1.65102 -5.94688 5.30442 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 2. NORMAL Test Statistic: -0.3720674, Two-tailed area: .70984 ===================== ALP BET Value -0.53823 0.00033095 TD3 TD4 TD5 TD6 Value -0.36189 -0.033711 0.099149 0.35496 Standard Parameter Estimate Error t-statistic P-value ALP -.538228 .045573 -11.8103 [.000] BET .330946E-03 .030286 .010927 [.991] TD3 -.361890 .140194 -2.58134 [.010] TD4 -.033711 .160230 -.210390 [.833] TD5 .099149 .111163 .891921 [.372] TD6 .354957 .111271 3.19003 [.001] Wald Test: H_0: Time Dummies are all zero ========================================= Results of Parameter Analysis ============================= Standard Parameter Estimate Error t-statistic P-value ZR_TD3 -.361890 .140194 -2.58134 [.010] ZR_TD4 -.033711 .160230 -.210390 [.833] ZR_TD5 .099149 .111163 .891921 [.372] ZR_TD6 .354957 .111271 3.19003 [.001] Wald Test for the Hypothesis that the given set of Parameters are jointly zero: CHISQ(4) = 33.094082 ; P-value = 0.00000 Sargan Test for 2 step estimation ================================= SARGAN = 23.92152 CHISQ(18) Test Statistic: 23.92152, Upper tail area: .15762 Serial Correlation Tests, AR(1) and AR(2) ========================================= Univariate statistics ===================== Number of Observations: 141 Mean Std Dev Minimum Maximum ARMOM -0.88526 2.28837 -15.32806 4.46621 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 1. NORMAL Test Statistic: -4.593621, Two-tailed area: .00000 Univariate statistics ===================== Number of Observations: 94 Mean Std Dev Minimum Maximum ARMOM -0.065332 1.69511 -6.17101 6.08999 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 2. NORMAL Test Statistic: -0.3736731, Two-tailed area: .70865 ******************************************************************************* END OF OUTPUT. MEMORY USAGE: ITEM: DATA ARRAY TOTAL MEMORY UNITS: (4-BYTE WORDS) (MEGABYTES) MEMORY ALLOCATED : 4500000 20.0 MEMORY ACTUALLY REQUIRED : 27063 2.2 CURRENT VARIABLE STORAGE : 11564