------------------------------------- | this copy licensed | | for use by: | | TSP/GiveWin 4.5 User #45AGT0007 | ------------------------------------- TSP Version 4.5 (03/30/00) TSP/GiveWin 20MB Copyright (C) 2000 TSP International ALL RIGHTS RESERVED 12/01/03 2:56 PM 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] 2 ? [Using GMM(DIF) or GMM (SYS)] 2 ? [without Time Dummies or with Time Dummies] 2 ? ================================================== 2 ? We can select the options to estimate 2 ? dynamic panel data model in different modes. 2 ? ================================================== 2 ? Designed by Yoshitsugu Kitazawa 2 ? First Design: 2003.12.1 Last Update: 2003.12.1 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 and with 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 ? Further, it is supposed that y_{it} and x_{it} are 2 ? mean-stationary. In addition, (TD_t)s are the 2 ? time dummies to be estimated, when (TD_t)s are 2 ? specified in the model. 2 ? 2 ? * Specify the options at Specification of Options below. 2 ? lt = 6 : nnumber of all time periods used in the 2 ? estimation in this case. 2 ? 2 ? * Specify the options at Specification of Options below. 2 ? [1] tm=0 and om=1 : without Time Dummies and using GMM(DIF) 2 ? [2] tm=0 and om=2 : without Time Dummies and using GMM(SYS) 2 ? [3] tm=1 and om=1 : with Time Dummies and using GMM(DIF) 2 ? [4] tm=1 and om=2 : with Time Dummies and using GMM(SYS) 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 "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 "cov1ssys.tsp" ; 18 ? ============================ cov1ssys ========================= 18 proc cov1ssys neq ivs imask an1 ; 19 19 ? This procedure makes a covariance matrix for the system GMM 19 ? estimator. The structure of the covariance matrix is the same 19 ? as one in p9 in "Panel Data estimation using DPD for Ox", 19 ? edited by Doornik, Arellano, and Bond (June 20, 2001), except 19 ? for the scaling. 19 ? The system GMM estimator is introduced in Blundell and Bond 19 ? (Journal of Econometrics, 1998) in detail. 19 ? 19 ? That is, for example, when T= 5, 19 ? 19 ? | 2 -1 0 0 0 | 19 ? | -1 2 -1 0 0 | 19 ? HD = | 0 -1 2 -1 0 | 19 ? | 0 0 -1 2 -1 | 19 ? | 0 0 0 -1 2 | 19 ? 19 ? | 1 0 0 0 0 | 19 ? | 0 1 0 0 0 | 19 ? I = | 0 0 1 0 0 | 19 ? | 0 0 0 1 0 | 19 ? | 0 0 0 0 1 | 19 ? 19 ? | 0 0 0 0 0 | 19 ? | 0 0 0 0 0 | 19 ? O = | 0 0 0 0 0 | 19 ? | 0 0 0 0 0 | 19 ? | 0 0 0 0 0 | 19 ? 19 ? H = | HD O | 19 ? | O I | 19 ? 19 ? Remark: Write the ivs list in the following order: 19 ? [Instruments List for Difference Equation] 19 ? [Instruments List for Level Equation] 19 ? and 19 ? in gmm command, write the equation list 19 ? in the following order: 19 ? gmm(...) difference_eq_list level_eq_list ; 19 ? 19 ? This procedure is made by Yoshitsgu Kitazawa 19 ? (probably August/03), refering to the cov1step.tsp 19 ? procedure designed by Clint Cummins (12/17/97). 19 19 ? neq - number of equations (time periods (T-2)*2), 19 ? where first T-2 is number of 1st dif eq while 19 ? last T-2 is number of level eq. 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 ? an1 - the covariance matrix estimate (returned). 19 19 local h i i1 diagm ; 20 local neqh neqhp1 ; 21 21 ? Make the theoretical covariance matrix of the equation residuals 21 ? (MA(1)). 21 21 ? In TSP 4.4 (rev. 8/97), this can be done with the BAND option to 21 ? MFORM: 21 ?mmake i 2 -1; ? vector of band values, starting with main diagonal 21 ?mform(band,nrow=neq) h = i; 21 21 set neqh = neq / 2 ; 22 set neqhp1 = neqh + 1 ; 23 23 mat h = 2*ident(neq) ; 24 if neq .gt. 2 ; then ; do ; 27 do i = 2 neqh ; 28 set i1 = i-1 ; 29 set h(i,i1) = -1 ; 30 enddo ; 31 do i = neqhp1 neq ; 32 set h(i,i) = h(i,i) / 2 ; 33 enddo ; 34 enddo ; 35 35 moment(noprint) ivs ; ? @mom = (z'z)/@nob 36 mat an1 = sym(h) # @mom ; 37 ? 37 ? Apply the mask to an1, to work around a bug in GMM 37 ? that was fixed on 12/17/97 37 ? 37 mat diagm = diag(vec(imask)); 38 mat an1 = diagm'an1*diagm; 39 39 endproc cov1ssys ; 40 ? ================================================================== 40 input "cov2stpm.tsp" ; 40 ? ============================ cov2stpm ========================= 40 proc cov2stpm eqs ivs imask an2 ; 41 41 ? This is as same as cov2step procedure by Dr. Clint Cummins, only 41 ? changing name of procedure, etc. see 41 ? http://www.stanford.edu/~clint/tspex/group.htm#G 41 ? The description below is the description in cov2step procedure 41 ? made by Dr. Clint Cummins. 41 41 ? Procedure to compute the estimated two-step covariance matrix for 41 ? GMM estimation (after first step estimation). 41 ? see Arellano and Bond (REStud 91 for details). 41 ? Benchmarked with Steve Bond using DPD and these give estimates that 41 ? match his. TSP's default GMM estimator does not match the cov2step 41 ? results - the default GMM is more like a 3-step estimator since it 41 ? does 2SLS, 3SLS, and then GMM. 41 ? simple version, by Clint Cummins 9/97 41 41 ? This procedure is preferable in terms of controlling for 41 ? missing values. 41 41 ? eqs - equations (number of column of mask matrix, imask) 41 ? ivs - a list of instrumental variables 41 ? imask - a ninst by neq matrix of zeros and ones that specifies 41 ? which instruments are used for which equation. 41 ? an2 - the covariance matrix estimate (returned). 41 41 ? supres nob phi gmmovid coef; 41 gmm(covoc=own,hetero,maxit=0,nolsqstart,silent,inst=ivs,mask=imask) eqs; 42 ? nosupres nob phi gmmovid coef; 42 mat an2 = @covoc; 43 endproc cov2stpm ; 44 ? ================================================================== 44 44 44 44 input "evdgen.tsp" ; 44 ? ================== evdgen =================== 44 proc evdgen sigres ; 45 ? procedure to generate sigma_v in Arellano and Bond (1991) for 45 ? 1-step estimator for the dynamic panel data model. 45 ? This is used for estimating the variance of the parameter estimate 45 ? and for generating the Sargan test for 1-step estimation. 45 ? It is assumed that the disturbances in the model is homoscedastic 45 ? cross-sectionally and over time. 45 ? The sigma_v is the estimate of the variance of the disturbance 45 ? for the first-differenced equations. 45 ? sig_v = residual' residual / (#eq * #obs - #param) 45 ? where residual is ((#eq * #obs) by 1) vector. 45 ? When GMM 1-step estimation, implement 45 ? cov1stpd ... ani1 ; 45 ? mat ani1 = ani1 / 2 ; 45 ? gmm(..optcov ..) eqn ; 45 ? evdgen sr1 ; 45 ? set @gmmovid = @gmmovid / sr1 ; 45 ? mat @vcov = @vcov * sr1 ; 45 ? by Yoshitsugu Kitazawa, (2001, 11, 2) 45 ? --------------------------------------------- 45 local resv sigresp np tn ; 46 mat resv = vec(@res) ; 47 mat sigresp = resv' resv ; 48 mat tn = nrow(resv) ; 49 length @rnms np ; 50 set sigres = sigresp / (tn - np) ; 51 endproc evdgen ; 52 ? ================== evdgen =================== 52 input "mattrim1.tsp" ; 52 ? ================== mattrim1 =================== 52 proc mattrim1 mrx fx lx mrxs ; 53 ? 53 ? This procedure extracts the successive columns 53 ? from matrix. Edited by Yoshitsugu Kitazawa 53 ? (2003.11.26). 53 ? 53 ? mrx - original matrix 53 ? fx - the starting column number in mrx 53 ? lx - the ending column number in mrx 53 ? mrxs - stemmed matrix, starting from fx-th column 53 ? in mrx and ending at lx-th column 53 ? 53 ? For example, using this procedure, 53 ? from the following 3 by 4 matrix, we can extract 53 ? the matrix composed of the successive columns 53 ? which start from 2nd column of the 3 by 4 matrix 53 ? and end at 4th column. 53 ? 53 ? load(nrow=3, ncol=5) m35 ; 53 ? 1 2 3 4 5 53 ? 6 7 8 9 10 53 ? 11 12 13 14 15 53 ? ; 53 ? 53 ? The used command is 53 ? 53 ? mattrim1 m35 2 4 m33 ; 53 ? 53 ? print m33 ; 53 ? 53 ? 2 3 4 53 ? 7 8 9 53 ? 12 13 14 53 ? 53 ? --------------------------------------------- 53 local nm tls i nmrx ; 54 54 mat nm = ncol(mrx) ; 55 55 if((fx<1) .or. (fx>nm) 55 .or. (lx<1) .or. (lx>nm) 55 .or. (fx>lx)); then ; do ; 58 title "ERROR: procedure mattrim1" ; 59 stop ; 60 enddo ; 61 61 list(first=nm, last=nm) tls ; 62 dot tls ; 63 local mf1-mf. ; 64 unmake mrx mf1-mf. ; 65 enddot ; 66 66 do i=fx to lx ; 67 if(i=fx) ; then ; do ; 70 list(first=i, last=i) tls ; 71 dot tls ; 72 mmake nmrx mf. ; 73 enddot ; 74 enddo ; 75 else ; do ; 77 list(first=i, last=i) tls ; 78 dot tls ; 79 mmake nmrx nmrx mf. ; 80 enddot ; 81 enddo ; 82 enddo ; 83 83 mmake mrxs nmrx ; 84 endproc mattrim1 ; 85 ? ================== mattrim1 =================== 85 85 85 ? ===== Specification of Options =================== 85 ? -------------------------------------------------- 85 ? *** Specify here [the number of time periods], 85 ? *** [the usage of time dummies], and 85 ? *** [the selection of estimation method]. 85 ? -------------------------------------------------- 85 ? Number of all time periods used in the estimation 85 set lt = 6 ; 86 ? Time Dummy (TD) Specification 86 set tm = 0 ; ? 0: Without TD, 1: With TD 87 ? Selection of estimation method 87 set om = 2 ; ? 1: GMM(DIF), 2: GMM(SYS) 88 ? ================================================== 88 88 print lt tm om ; 89 89 if(.not. (tm=0 .or. tm=1)) ; then ; do ; 92 title "Error: tm must be 0 or 1" ; 93 stop ; 94 enddo ; 95 95 if(.not. (om=1 .or. om=2)) ; then ; do ; 98 title "Error: om must be 1 or 2" ; 99 stop ; 100 enddo ; 101 101 set ltm1 = lt - 1 ; 102 set ltm2 = lt - 2 ; 103 103 103 ? Level Eq. 103 list(first=2, last=lt) tmplis ; 104 dot(index=i) tmplis ; 105 set i=i+1 ; 106 frml ux. y. - ( alp * y_m1 + bet * x. + tdx. ) ; 107 set j=i-1 ; list(first=j, last=j) jlis ; dot jlis ; 110 frml y_m1 y. ; enddot ; 112 frml tdx. td. ; 113 eqsub(name=ut., print) ux. y_m1 tdx. ; 114 frml tdx. 0 ; 115 eqsub(name=un., print) ux. y_m1 tdx. ; 116 enddot ; 117 117 117 ? Differenced Eq. 117 list(first=3, last=lt) tmplis ; 118 dot(index=i) tmplis ; 119 set i=i+2 ; 120 ? 120 frml dux. ut. - un_m1 ; 121 set j=i-1 ; list(first=j, last=j) jlis ; dot jlis ; 124 frml un_m1 un. ; eqsub un_m1 un. ; enddot ; 127 eqsub(name=dutn., print) dux. ut. un_m1 ; 128 ? 128 frml dux. ut. - ut_m1 ; 129 set j=i-1 ; list(first=j, last=j) jlis ; dot jlis ; 132 frml ut_m1 ut. ; eqsub ut_m1 ut. ; enddot ; 135 eqsub(name=dut., print) dux. ut. ut_m1 ; 136 ? 136 frml dux. un. - un_m1 ; 137 set j=i-1 ; list(first=j, last=j) jlis ; dot jlis ; 140 frml un_m1 un. ; eqsub un_m1 un. ; enddot ; 143 eqsub(name=dun., print) dux. un. un_m1 ; 144 enddot ; 145 145 title "Equations used for the estimation" ; 146 146 if(om=1 .and. tm=0) ; then ; do ; 149 frml du2 0 ; 150 list(first=3, last=lt) tmplis ; 151 dot tmplis ; 152 frml du. dun. ; 153 eqsub(print) du. dun. ; 154 enddot ; 155 enddo ; 156 156 if(om=1 .and. tm=1) ; then ; do ; 159 frml du2 0 ; 160 list(first=3, last=lt) tmplis ; 161 dot tmplis ; 162 frml du. dutn. ; 163 eqsub(print) du. dutn. ; 164 enddot ; 165 enddo ; 166 166 if(om=2 .and. tm=0) ; then ; do ; 169 frml du2 0 ; 170 list(first=3, last=lt) tmplis ; 171 dot tmplis ; 172 frml du. dun. ; 173 eqsub(print) du. dun. ; 174 enddot ; 175 list(first=2, last=lt) tmplis ; 176 dot tmplis ; 177 frml u. un. ; 178 eqsub(print) u. un. ; 179 enddot ; 180 enddo ; 181 181 if(om=2 .and. tm=1) ; then ; do ; 184 frml du2 0 ; 185 list(first=3, last=lt) tmplis ; 186 dot tmplis ; 187 frml du. dut. ; 188 eqsub(print) du. dut. ; 189 enddot ; 190 list(first=2, last=lt) tmplis ; 191 dot tmplis ; 192 frml u. ut. ; 193 eqsub(print) u. ut. ; 194 enddot ; 195 enddo ; 196 196 196 list(first=lt, last=lt) tmplis ; 197 dot tmplis ; 198 list eqlisa du2-du. ; 199 list eqlisb u2-u. ; 200 enddot ; 201 201 if(om=1) ; then ; 203 do ; list eqlis eqlisa ; enddo ; 206 if(om=2) ; then ; 208 do ; list eqlis eqlisa eqlisb ; enddo ; 211 211 211 list(first=ltm2, last=ltm2) tmplis ; 212 dot tmplis ; list insta y1-y. x1-x. ; enddot ; 215 list(first=ltm1, last=ltm1) tmplis ; 216 dot tmplis ; list instb dy2-dy. dx2-dx. ; enddot ; 219 219 if(om=1) ; then ; 221 do ; list zlis insta c ; enddo ; 224 if(om=2) ; then ; 226 do ; list zlis insta instb c ; enddo ; 229 229 229 mform(type=triang, ncol=ltm2) one22ut = 1 ; 230 mat one22id = ident(ltm2) ; 231 mform(type=sym, ncol=ltm2) zer22 = 0 ; 232 mform(nrow=1, ncol=ltm2) zer12 = 0 ; 233 mform(nrow=1, ncol=ltm2) one12 = 1 ; 234 mat zer12t = zer12' ; 235 mform(nrow=1, ncol=1) zer11 = 0 ; 236 mform(nrow=1, ncol=1) one11 = 1 ; 237 237 if(om=1 .and. tm=0) ; then ; do ; 240 mmake(vert) zmaf zer12t zer12t zer11 ; 241 mmake(vert) zma one22ut one22ut zer12 ; 242 mmake zmask zmaf zma ; 243 enddo ; 244 if(om=1 .and. tm=1) ; then ; do ; 247 mmake(vert) zmaf zer12t zer12t zer11 ; 248 mmake(vert) zma one22ut one22ut one12 ; 249 mmake zmask zmaf zma ; 250 enddo ; 251 if(om=2 .and. tm=0) ; then ; do ; 254 mmake(vert) zmaf zer12t zer12t zer12t zer12t zer11 ; 255 mmake(vert) zma one22ut one22ut zer22 zer22 zer12 ; 256 mmake(vert) zmbf zer12t zer12t zer12t zer12t zer11 ; 257 mmake(vert) zmb zer22 zer22 one22id one22id zer12 ; 258 mmake zmask zmaf zma zmbf zmb ; 259 enddo ; 260 if(om=2 .and. tm=1) ; then ; do ; 263 mmake(vert) zmaf zer12t zer12t zer12t zer12t zer11 ; 264 mmake(vert) zma one22ut one22ut zer22 zer22 zer12 ; 265 mmake(vert) zmbf zer12t zer12t zer12t zer12t one11 ; 266 mmake(vert) zmb zer22 zer22 one22id one22id one12 ; 267 mmake zmask zmaf zma zmbf zmb ; 268 enddo ; 269 269 print zmask ; 270 270 mat neqx = ncol(zmask) ; 271 271 271 if(om=1 .and. tm=1) ; then ; do ; 274 list(first=3, last=lt) tmplis ; 275 dot tmplis ; frml zr_td. td. - 0 ; enddot ; 278 list(first=lt, last=lt) tmplis ; 279 dot tmplis ; list zr_tds zr_td3-zr_td. ; enddot ; 282 enddo ; 283 if(om=2 .and. tm=1) ; then ; do ; 286 list(first=2, last=lt) tmplis ; 287 dot tmplis ; frml zr_td. td. - 0 ; enddot ; 290 list(first=lt, last=lt) tmplis ; 291 dot tmplis ; list zr_tds zr_td2-zr_td. ; enddot ; 294 enddo ; 295 295 295 freq n ; 296 smpl 1 47 ; 297 read(file="ydata.txt") code y1-y6 ; 298 read(file="xdata.txt") code x1-x6 ; 299 299 ? print y1-y6 ; 299 ? print x1-x6 ; 299 299 genr y_lag1 = y1 ; 300 list(first=2, last=lt) tmplis ; 301 dot tmplis ; 302 genr dy. = y. - y_lag1 ; 303 genr y_lag1 = y. ; 304 enddot ; 305 305 genr x_lag1 = x1 ; 306 list(first=2, last=lt) tmplis ; 307 dot tmplis ; 308 genr dx. = x. - x_lag1 ; 309 genr x_lag1 = x. ; 310 enddot ; 311 311 311 param alp bet ; 312 if(om=1 .and. tm=1) ; then ; do ; 315 list(first=lt, last=lt) tmplis ; 316 dot tmplis ; param td3-td. ; enddot ; 319 enddo ; 320 if(om=2 .and. tm=1) ; then ; do ; 323 list(first=lt, last=lt) tmplis ; 324 dot tmplis ; param td2-td. ; enddot ; 327 enddo ; 328 328 title "" ; 329 if(om=1) ; then ; do ; 332 cov1spdm neqx zlis zmask ani1 ; 333 enddo ; 334 if(om=2) ; then ; do ; 337 cov1ssys neqx zlis zmask ani1 ; 338 enddo ; 339 mat ani1 = ani1 / 2 ; 340 gmm(covoc=ani1, noiteroc, nooptcov, hetero, nma=0, 340 maxit=100, silent, inst=zlis, mask=zmask) eqlis ; 341 print alp bet ; 342 if(tm=1) ; then ; do ; 345 if(om=1) ; then ; do ; 348 list(first=lt, last=lt) tmplis ; 349 dot tmplis ; print td3-td. ; enddot ; 352 enddo ; 353 if(om=2) ; then ; do ; 356 list(first=lt, last=lt) tmplis ; 357 dot tmplis ; print td2-td. ; enddot ; 360 enddo ; 361 enddo ; 362 tstats(name=@rnms) @coef @vcov ; 363 if(tm=1) ; then ; do ; 366 title "Wald Test: H_0: Time Dummies are all zero" ; 367 analyz zr_tds ; 368 enddo ; 369 title "Sargan Test for 1 step estimation" ; 370 copy @res restmp ; 371 mat lc = ncol(@res) ; 372 if(om=1) ; then ; do ; 375 set fc = 2 ; 376 enddo ; 377 if(om=2) ; then ; do ; 380 set fc = lc / 2 + 1 ; 381 enddo ; 382 mattrim1 @res fc lc @res ; 383 evdgen sr1 ; 384 copy restmp @res ; 385 set sargan = @gmmovid / sr1 ; 386 print sargan ; cdf(chi, df=@novid) sargan ; 388 title "Serial Correlation Tests, AR(1) and AR(2)" ; 389 copy @res restmp ; 390 set fc = 2 ; 391 mat nc = ncol(@res) ; 392 if(om=1) ; then ; do ; 395 set lc = nc ; 396 enddo ; 397 if(om=2) ; then ; do ; 400 set lc = nc / 2 ; 401 enddo ; 402 mattrim1 @res fc lc @res ; 403 regopt(noprint) all ; lm2test2 ; regopt ; 406 ? lm2test2 ; 406 copy restmp @res ; 407 407 title "" ; 408 regopt(noprint) all ; 409 cov2stpm eqlis zlis zmask ani2 ; 410 regopt ; 411 gmm(covoc=ani2, noiteroc, optcov, hetero, nma=0, 411 maxit=100, silent, inst=zlis, mask=zmask) eqlis ; 412 print alp bet ; 413 if(tm=1) ; then ; do ; 416 if(om=1) ; then ; do ; 419 list(first=lt, last=lt) tmplis ; 420 dot tmplis ; print td3-td. ; enddot ; 423 enddo ; 424 if(om=2) ; then ; do ; 427 list(first=lt, last=lt) tmplis ; 428 dot tmplis ; print td2-td. ; enddot ; 431 enddo ; 432 enddo ; 433 tstats(name=@rnms) @coef @vcov ; 434 if(tm=1) ; then ; do ; 437 title "Wald Test: H_0: Time Dummies are all zero" ; 438 analyz zr_tds ; 439 enddo ; 440 title "Sargan Test for 2 step estimation" ; 441 set sargan = @gmmovid ; 442 print sargan ; cdf(chi, df=@novid) sargan ; 444 title "Serial Correlation Tests, AR(1) and AR(2)" ; 445 copy @res restmp ; 446 set fc = 2 ; 447 mat nc = ncol(@res) ; 448 if(om=1) ; then ; do ; 451 set lc = nc ; 452 enddo ; 453 if(om=2) ; then ; do ; 456 set lc = nc / 2 ; 457 enddo ; 458 mattrim1 @res fc lc @res ; 459 regopt(noprint) all ; lm2test2 ; regopt ; 462 ? lm2test2 ; 462 copy restmp @res ; 463 463 stop ; 464 end ; 465 INPUT 'LM2TEST2.TSP' *; 465 ? ============================= lm2test2 ========================== 465 proc lm2test2 ; 466 ? 466 ? Procedure to perform tests for 1st and 2nd order serial 466 ? correlation after GMM estimation with panel data. 466 ? It is the same asymptotically as the Arellano-Bond test (REStud 1991) 466 ? and easier to compute; also it is defined when the model is 466 ? nonlinear. In the cases checked, it was the same as A-B to 466 ? at least 5%, which is good enough. It does not seem to be biased. 466 466 ? by Bronwyn H. Hall, Jan. 97; revised by Clint Cummins 10/97 466 ? requires TSP 4.3 or later (list(first=,last=) options) 466 ? 466 local savsmp nob neq maxlag tlag ntlag test armom ilag ilag1 466 nu us umat u ulag; 467 467 mat neq = ncol(@res) ; 468 if neq = 1; then; goto 900; ? give up if no possible lags 471 set maxlag = (neq-1); 472 if maxlag .gt. 2; then; set maxlag = 2; ? max lag of 2 here, but 475 ? it could be set higher if desired (could be an argument of the proc) 475 list(last=neq,prefix=nu) nulist ; 476 local nulist ; 477 copy @smpl savsmp ; ? Save sample. 478 478 set nob = @nob ; 479 smpl 1 nob ; ? This procedure expects contiguous data. 480 unmake @res nulist ; ? Put the residuals in the variables in nulist. 481 do ilag=1,maxlag; 482 set tlag = neq-ilag ; 483 set ntlag = nob*tlag ; ? Number of obs with lag ilag. 484 set ilag1 = ilag+1; 485 list(first=ilag1,last=neq, prefix=nu) us; ? unlagged residuals 486 smpl 1,nob; mmake umat us; 488 smpl 1,ntlag; unmake umat u; 490 list(first=1, last=tlag,prefix=nu) us; ? lagged residuals 491 smpl 1,nob; mmake umat us; 493 smpl 1,ntlag; unmake umat ulag; 495 495 ? Test for Lag ilag Serial Correlation. 495 495 armom = u*ulag ; ? serial correlation estimate 496 msd(silent,terse) armom ; 497 set test = @mean / (@stddev/sqrt(ntlag)) ; 498 title "Standard LM Test for Serial Correlation with HS" ; 499 write(format="(' Order of Serial Correlation:',F3.0)") ilag; 500 cdf(normal) test ; ? Standard LM test. 501 501 enddo ; 502 502 smpl savsmp ; ? Restore the sample. 503 900 endproc lm2test2 ; 504 ? ============================================================= EXECUTION ******************************************************************************* LT TM OM Value 6.00000 0.00000 2.00000 FRML UT2 Y2 - (ALP*Y1 + BET*X2 + TD2) FRML UN2 Y2 - (ALP*Y1 + BET*X2 + 0) FRML UT3 Y3 - (ALP*Y2 + BET*X3 + TD3) FRML UN3 Y3 - (ALP*Y2 + BET*X3 + 0) FRML UT4 Y4 - (ALP*Y3 + BET*X4 + TD4) FRML UN4 Y4 - (ALP*Y3 + BET*X4 + 0) FRML UT5 Y5 - (ALP*Y4 + BET*X5 + TD5) FRML UN5 Y5 - (ALP*Y4 + BET*X5 + 0) FRML UT6 Y6 - (ALP*Y5 + BET*X6 + TD6) FRML UN6 Y6 - (ALP*Y5 + BET*X6 + 0) FRML DUTN3 Y3 - (ALP*Y2 + BET*X3 + TD3) - (Y2 - (ALP*Y1 + BET*X2 + 0)) FRML DUT3 Y3 - (ALP*Y2 + BET*X3 + TD3) - (Y2 - (ALP*Y1 + BET*X2 + TD2)) FRML DUN3 Y3 - (ALP*Y2 + BET*X3 + 0) - (Y2 - (ALP*Y1 + BET*X2 + 0)) FRML DUTN4 Y4 - (ALP*Y3 + BET*X4 + TD4) - (Y3 - (ALP*Y2 + BET*X3 + 0)) FRML DUT4 Y4 - (ALP*Y3 + BET*X4 + TD4) - (Y3 - (ALP*Y2 + BET*X3 + TD3)) FRML DUN4 Y4 - (ALP*Y3 + BET*X4 + 0) - (Y3 - (ALP*Y2 + BET*X3 + 0)) FRML DUTN5 Y5 - (ALP*Y4 + BET*X5 + TD5) - (Y4 - (ALP*Y3 + BET*X4 + 0)) FRML DUT5 Y5 - (ALP*Y4 + BET*X5 + TD5) - (Y4 - (ALP*Y3 + BET*X4 + TD4)) FRML DUN5 Y5 - (ALP*Y4 + BET*X5 + 0) - (Y4 - (ALP*Y3 + BET*X4 + 0)) FRML DUTN6 Y6 - (ALP*Y5 + BET*X6 + TD6) - (Y5 - (ALP*Y4 + BET*X5 + 0)) FRML DUT6 Y6 - (ALP*Y5 + BET*X6 + TD6) - (Y5 - (ALP*Y4 + BET*X5 + TD5)) FRML DUN6 Y6 - (ALP*Y5 + BET*X6 + 0) - (Y5 - (ALP*Y4 + BET*X5 + 0)) Equations used for the estimation ================================= FRML DU3 Y3 - (ALP*Y2 + BET*X3 + 0) - (Y2 - (ALP*Y1 + BET*X2 + 0)) FRML DU4 Y4 - (ALP*Y3 + BET*X4 + 0) - (Y3 - (ALP*Y2 + BET*X3 + 0)) FRML DU5 Y5 - (ALP*Y4 + BET*X5 + 0) - (Y4 - (ALP*Y3 + BET*X4 + 0)) FRML DU6 Y6 - (ALP*Y5 + BET*X6 + 0) - (Y5 - (ALP*Y4 + BET*X5 + 0)) FRML U2 Y2 - (ALP*Y1 + BET*X2 + 0) FRML U3 Y3 - (ALP*Y2 + BET*X3 + 0) FRML U4 Y4 - (ALP*Y3 + BET*X4 + 0) FRML U5 Y5 - (ALP*Y4 + BET*X5 + 0) FRML U6 Y6 - (ALP*Y5 + BET*X6 + 0) ZMASK 1 2 3 4 5 1 0.00000 1.00000 1.00000 1.00000 1.00000 2 0.00000 0.00000 1.00000 1.00000 1.00000 3 0.00000 0.00000 0.00000 1.00000 1.00000 4 0.00000 0.00000 0.00000 0.00000 1.00000 5 0.00000 1.00000 1.00000 1.00000 1.00000 6 0.00000 0.00000 1.00000 1.00000 1.00000 7 0.00000 0.00000 0.00000 1.00000 1.00000 8 0.00000 0.00000 0.00000 0.00000 1.00000 9 0.00000 0.00000 0.00000 0.00000 0.00000 10 0.00000 0.00000 0.00000 0.00000 0.00000 11 0.00000 0.00000 0.00000 0.00000 0.00000 12 0.00000 0.00000 0.00000 0.00000 0.00000 13 0.00000 0.00000 0.00000 0.00000 0.00000 14 0.00000 0.00000 0.00000 0.00000 0.00000 15 0.00000 0.00000 0.00000 0.00000 0.00000 16 0.00000 0.00000 0.00000 0.00000 0.00000 17 0.00000 0.00000 0.00000 0.00000 0.00000 6 7 8 9 10 1 0.00000 0.00000 0.00000 0.00000 0.00000 2 0.00000 0.00000 0.00000 0.00000 0.00000 3 0.00000 0.00000 0.00000 0.00000 0.00000 4 0.00000 0.00000 0.00000 0.00000 0.00000 5 0.00000 0.00000 0.00000 0.00000 0.00000 6 0.00000 0.00000 0.00000 0.00000 0.00000 7 0.00000 0.00000 0.00000 0.00000 0.00000 8 0.00000 0.00000 0.00000 0.00000 0.00000 9 0.00000 1.00000 0.00000 0.00000 0.00000 10 0.00000 0.00000 1.00000 0.00000 0.00000 11 0.00000 0.00000 0.00000 1.00000 0.00000 12 0.00000 0.00000 0.00000 0.00000 1.00000 13 0.00000 1.00000 0.00000 0.00000 0.00000 14 0.00000 0.00000 1.00000 0.00000 0.00000 15 0.00000 0.00000 0.00000 1.00000 0.00000 16 0.00000 0.00000 0.00000 0.00000 1.00000 17 0.00000 0.00000 0.00000 0.00000 0.00000 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 : 278401 3.2 CURRENT VARIABLE STORAGE : 109596