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 (DIF)] 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 ? 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 ? 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 ) ; 70 frml du4 dy4 - ( alp * dy3 + bet * dx4 ) ; 71 frml du5 dy5 - ( alp * dy4 + bet * dx5 ) ; 72 frml du6 dy6 - ( alp * dy5 + bet * dx6 ) ; 73 73 list eq_dif du3-du6 ; 74 74 list zc_dif y1-y4 x1-x4 ; 75 75 load(nrow=8, 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 ; 76 76 mat neqx = ncol(zm_dif) ; 77 77 freq n ; 78 smpl 1 47 ; 79 read(file="ydata.txt") code y1-y6 ; 80 read(file="xdata.txt") code x1-x6 ; 81 81 ? print y1-y6 ; 81 ? print x1-x6 ; 81 81 genr dy2 = y2 - y1 ; 82 genr dy3 = y3 - y2 ; 83 genr dy4 = y4 - y3 ; 84 genr dy5 = y5 - y4 ; 85 genr dy6 = y6 - y5 ; 86 86 genr dx2 = x2 - x1 ; 87 genr dx3 = x3 - x2 ; 88 genr dx4 = x4 - x3 ; 89 genr dx5 = x5 - x4 ; 90 genr dx6 = x6 - x5 ; 91 91 91 param alp bet ; 92 title "" ; 93 cov1spdm neqx zc_dif zm_dif ani1 ; 94 mat ani1 = ani1 / 2 ; 95 gmm(covoc=ani1, noiteroc, nooptcov, hetero, nma=0, 95 maxit=100, silent, inst=zc_dif, mask=zm_dif) eq_dif ; 96 print alp bet ; 97 tstats(name=@rnms) @coef @vcov ; 98 title "Sargan Test for 1 step estimation" ; 99 evdgen sr1 ; 100 set sargan = @gmmovid / sr1 ; 101 print sargan ; cdf(chi, df=@novid) sargan ; 103 title "Serial Correlation Tests, AR(1) and AR(2)" ; 104 regopt(noprint) all ; lm2test2 ; regopt ; 107 107 107 title "" ; 108 regopt(noprint) all ; 109 cov2stpm eq_dif zc_dif zm_dif ani2 ; 110 regopt ; 111 gmm(covoc=ani2, noiteroc, optcov, hetero, nma=0, 111 maxit=100, silent, inst=zc_dif, mask=zm_dif) eq_dif ; 112 print alp bet ; 113 tstats(name=@rnms) @coef @vcov ; 114 title "Sargan Test for 2 step estimation" ; 115 set sargan = @gmmovid ; 116 print sargan ; cdf(chi, df=@novid) sargan ; 118 title "Serial Correlation Tests, AR(1) and AR(2)" ; 119 regopt(noprint) all ; lm2test2 ; regopt ; 122 122 stop ; 123 end ; EXECUTION ******************************************************************************* Current sample: 1 to 47 ===================== ALP BET Value -0.49518 0.0063032 Standard Parameter Estimate Error t-statistic P-value ALP -.495178 .072584 -6.82213 [.000] BET .630319E-02 .046599 .135264 [.892] Sargan Test for 1 step estimation ================================= SARGAN = 19.33036 CHISQ(18) Test Statistic: 19.33036, Upper tail area: .37175 Serial Correlation Tests, AR(1) and AR(2) ========================================= Univariate statistics ===================== Number of Observations: 141 Mean Std Dev Minimum Maximum ARMOM -0.93329 2.39420 -16.84419 4.89660 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 1. NORMAL Test Statistic: -4.628800, Two-tailed area: .00000 Univariate statistics ===================== Number of Observations: 94 Mean Std Dev Minimum Maximum ARMOM -0.018216 1.73104 -7.08346 4.71746 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 2. NORMAL Test Statistic: -0.1020284, Two-tailed area: .91873 ===================== ALP BET Value -0.50735 -0.0044743 Standard Parameter Estimate Error t-statistic P-value ALP -.507353 .045847 -11.0663 [.000] BET -.447434E-02 .030407 -.147148 [.883] Sargan Test for 2 step estimation ================================= SARGAN = 23.42081 CHISQ(18) Test Statistic: 23.42081, Upper tail area: .17493 Serial Correlation Tests, AR(1) and AR(2) ========================================= Univariate statistics ===================== Number of Observations: 141 Mean Std Dev Minimum Maximum ARMOM -0.94587 2.43895 -17.29028 5.18488 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 1. NORMAL Test Statistic: -4.605090, Two-tailed area: .00000 Univariate statistics ===================== Number of Observations: 94 Mean Std Dev Minimum Maximum ARMOM -0.012526 1.75840 -7.25628 5.16037 Standard LM Test for Serial Correlation with HS =============================================== Order of Serial Correlation: 2. NORMAL Test Statistic: -0.6906508E-01, Two-tailed area: .94494 ******************************************************************************* END OF OUTPUT. MEMORY USAGE: ITEM: DATA ARRAY TOTAL MEMORY UNITS: (4-BYTE WORDS) (MEGABYTES) MEMORY ALLOCATED : 4500000 20.0 MEMORY ACTUALLY REQUIRED : 21590 2.2 CURRENT VARIABLE STORAGE : 9960