Stata Code Companion to Baltagi’s Econometric Analysis of Panel Data, 6Ed

Solomon Negash

---------------------------------------------------------------------------------------
      name:  <baltagipd>
       log:  ~\baltagi_panel_data_econometrics.smcl
  log type:  smcl
 opened on:   3 Jun 2025, 01:41:53
---------------------------------------------------------------------------------------

Chapter 02. The One-Way Error Component Regression Model

. clear all

Table 2.1 Grunfeld's data. One-way error component results

. import excel "grunfeld.xls", sheet("Sheet1") firstrow clear (5 vars, 200 obs) . xtset firm year Panel variable: firm (strongly balanced) Time variable: year, 1935 to 1954 Delta: 1 unit . local y invest . local xlist value cap . eststo OLS: reg `y' `xlist' Source | SS df MS Number of obs = 200 -------------+---------------------------------- F(2, 197) = 426.58 Model | 7604093.44 2 3802046.72 Prob > F = 0.0000 Residual | 1755850.48 197 8912.94662 R-squared = 0.8124 -------------+---------------------------------- Adj R-squared = 0.8105 Total | 9359943.93 199 47034.8941 Root MSE = 94.408 ------------------------------------------------------------------------------ invest | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1155622 .0058357 19.80 0.000 .1040537 .1270706 cap | .2306785 .0254758 9.05 0.000 .1804382 .2809188 _cons | -42.71437 9.511676 -4.49 0.000 -61.47215 -23.95659 ------------------------------------------------------------------------------ . eststo Between: xtreg `y' `xlist', be Between regression (regression on group means) Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.4778 min = 20 Between = 0.8578 avg = 20.0 Overall = 0.7551 max = 20 F(2,7) = 21.11 sd(u_i + avg(e_i.)) = 85.02366 Prob > F = 0.0011 ------------------------------------------------------------------------------ invest | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1346461 .0287455 4.68 0.002 .0666739 .2026183 cap | .0320315 .1909378 0.17 0.872 -.4194647 .4835276 _cons | -8.527114 47.51531 -0.18 0.863 -120.883 103.8287 ------------------------------------------------------------------------------ . eststo Fixed: xtreg `y' `xlist', fe Fixed-effects (within) regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7668 min = 20 Between = 0.8194 avg = 20.0 Overall = 0.8060 max = 20 F(2, 188) = 309.01 corr(u_i, Xb) = -0.1517 Prob > F = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1101238 .0118567 9.29 0.000 .0867345 .1335131 cap | .3100653 .0173545 17.87 0.000 .2758308 .3442999 _cons | -58.74394 12.45369 -4.72 0.000 -83.31087 -34.17701 -------------+---------------------------------------------------------------- sigma_u | 85.732502 sigma_e | 52.767966 rho | .72525011 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(9, 188) = 49.18 Prob > F = 0.0000 . eststo Random: xtreg `y' `xlist', re theta Random-effects GLS regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7668 min = 20 Between = 0.8196 avg = 20.0 Overall = 0.8061 max = 20 Wald chi2(2) = 657.67 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 theta = .86122362 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097812 .0104927 10.46 0.000 .0892159 .1303464 cap | .308113 .0171805 17.93 0.000 .2744399 .3417861 _cons | -57.83441 28.89894 -2.00 0.045 -114.4753 -1.193543 -------------+---------------------------------------------------------------- sigma_u | 84.200951 sigma_e | 52.767966 rho | .71800837 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo SWAR: xtreg `y' `xlist', sa Random-effects GLS regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7668 min = 20 Between = 0.8196 avg = 20.0 Overall = 0.8061 max = 20 Wald chi2(2) = 657.67 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097812 .0104927 10.46 0.000 .0892159 .1303464 cap | .308113 .0171805 17.93 0.000 .2744399 .3417861 _cons | -57.83441 28.89894 -2.00 0.045 -114.4753 -1.193543 -------------+---------------------------------------------------------------- sigma_u | 84.200951 sigma_e | 52.767966 rho | .71800837 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo MLE: xtreg `y' `xlist', mle Fitting constant-only model: Iteration 0: Log likelihood = -1241.9899 Iteration 1: Log likelihood = -1241.9696 Iteration 2: Log likelihood = -1241.9696 Fitting full model: Iteration 0: Log likelihood = -1105.6101 Iteration 1: Log likelihood = -1098.8418 Iteration 2: Log likelihood = -1095.4188 Iteration 3: Log likelihood = -1095.2576 Iteration 4: Log likelihood = -1095.257 Random-effects ML regression Number of obs = 200 Group variable: firm Number of groups = 10 Random effects u_i ~ Gaussian Obs per group: min = 20 avg = 20.0 max = 20 LR chi2(2) = 293.43 Log likelihood = -1095.257 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097627 .0103389 10.62 0.000 .0894988 .1300265 cap | .307942 .0171006 18.01 0.000 .2744254 .3414585 _cons | -57.7672 27.70004 -2.09 0.037 -112.0583 -3.476119 -------------+---------------------------------------------------------------- /sigma_u | 80.29729 18.37811 51.27213 125.7536 /sigma_e | 52.49255 2.69306 47.47095 58.04535 rho | .7005943 .0985226 .4881266 .8603709 ------------------------------------------------------------------------------ LR test of sigma_u=0: chibar2(01) = 193.09 Prob >= chibar2 = 0.000 . eststo PA: xtreg `y' `xlist', pa Iteration 1: Tolerance = .3394649 Iteration 2: Tolerance = .00362672 Iteration 3: Tolerance = .00001665 Iteration 4: Tolerance = 7.455e-08 GEE population-averaged model Number of obs = 200 Group variable: firm Number of groups = 10 Family: Gaussian Obs per group: Link: Identity min = 20 Correlation: exchangeable avg = 20.0 max = 20 Wald chi2(2) = 668.53 Scale parameter = 9203.122 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097627 .0103384 10.62 0.000 .0894997 .1300256 cap | .307942 .017072 18.04 0.000 .2744815 .3414025 _cons | -57.7672 27.69738 -2.09 0.037 -112.0531 -3.481346 ------------------------------------------------------------------------------ . esttab OLS Between Fixed Random SWAR MLE, se ------------------------------------------------------------------------------------------------------------ (1) (2) (3) (4) (5) (6) invest invest invest invest invest invest ------------------------------------------------------------------------------------------------------------ main value 0.116*** 0.135** 0.110*** 0.110*** 0.110*** 0.110*** (0.00584) (0.0287) (0.0119) (0.0105) (0.0105) (0.0103) cap 0.231*** 0.0320 0.310*** 0.308*** 0.308*** 0.308*** (0.0255) (0.191) (0.0174) (0.0172) (0.0172) (0.0171) _cons -42.71*** -8.527 -58.74*** -57.83* -57.83* -57.77* (9.512) (47.52) (12.45) (28.90) (28.90) (27.70) ------------------------------------------------------------------------------------------------------------ sigma_u _cons 80.30*** (18.38) ------------------------------------------------------------------------------------------------------------ sigma_e _cons 52.49*** (2.693) ------------------------------------------------------------------------------------------------------------ N 200 200 200 200 200 200 ------------------------------------------------------------------------------------------------------------ Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 . est clear

Table 2.5: Gasoline Demand Data. One-way Error Component Results

. import excel "gasoline.xls", sheet("Sheet1") firstrow clear (6 vars, 342 obs) . encode country, g(country2) . xtset country2 year Panel variable: country2 (strongly balanced) Time variable: year, 1960 to 1978 Delta: 1 unit . local y lgaspcar . local xlist lincomep lrpmg lcarpcap . eststo OLS: reg `y' `xlist' Source | SS df MS Number of obs = 342 -------------+---------------------------------- F(3, 338) = 664.00 Model | 87.8386069 3 29.2795356 Prob > F = 0.0000 Residual | 14.9043574 338 .044095732 R-squared = 0.8549 -------------+---------------------------------- Adj R-squared = 0.8536 Total | 102.742964 341 .301299016 Root MSE = .20999 ------------------------------------------------------------------------------ lgaspcar | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- lincomep | .8899617 .0358058 24.86 0.000 .8195314 .960392 lrpmg | -.8917979 .0303147 -29.42 0.000 -.9514272 -.8321686 lcarpcap | -.7633727 .0186083 -41.02 0.000 -.7999754 -.7267701 _cons | 2.391326 .1169343 20.45 0.000 2.161315 2.621336 ------------------------------------------------------------------------------ . eststo Between: xtreg `y' `xlist', be Between regression (regression on group means) Number of obs = 342 Group variable: country2 Number of groups = 18 R-squared: Obs per group: Within = 0.7337 min = 19 Between = 0.8799 avg = 19.0 Overall = 0.8529 max = 19 F(3,14) = 34.19 sd(u_i + avg(e_i.)) = .1966886 Prob > F = 0.0000 ------------------------------------------------------------------------------ lgaspcar | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- lincomep | .9675764 .1556662 6.22 0.000 .6337056 1.301447 lrpmg | -.9635504 .1329214 -7.25 0.000 -1.248639 -.6784623 lcarpcap | -.7952991 .0824742 -9.64 0.000 -.9721887 -.6184095 _cons | 2.54163 .5267844 4.82 0.000 1.41179 3.67147 ------------------------------------------------------------------------------ . eststo Fixed: xtreg `y' `xlist', fe Fixed-effects (within) regression Number of obs = 342 Group variable: country2 Number of groups = 18 R-squared: Obs per group: Within = 0.8396 min = 19 Between = 0.5755 avg = 19.0 Overall = 0.6150 max = 19 F(3, 321) = 560.09 corr(u_i, Xb) = -0.2468 Prob > F = 0.0000 ------------------------------------------------------------------------------ lgaspcar | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- lincomep | .6622497 .073386 9.02 0.000 .5178713 .806628 lrpmg | -.3217025 .0440993 -7.29 0.000 -.4084625 -.2349424 lcarpcap | -.6404829 .0296789 -21.58 0.000 -.6988725 -.5820933 _cons | 2.40267 .2253094 10.66 0.000 1.9594 2.845939 -------------+---------------------------------------------------------------- sigma_u | .34841288 sigma_e | .09233035 rho | .93438171 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(17, 321) = 83.96 Prob > F = 0.0000 . eststo Random: xtreg `y' `xlist', re theta Random-effects GLS regression Number of obs = 342 Group variable: country2 Number of groups = 18 R-squared: Obs per group: Within = 0.8363 min = 19 Between = 0.7099 avg = 19.0 Overall = 0.7309 max = 19 Wald chi2(3) = 1642.20 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 theta = .89230673 ------------------------------------------------------------------------------ lgaspcar | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lincomep | .5549857 .0591282 9.39 0.000 .4390966 .6708748 lrpmg | -.4203892 .0399781 -10.52 0.000 -.498745 -.3420335 lcarpcap | -.6068401 .025515 -23.78 0.000 -.6568487 -.5568316 _cons | 1.996698 .184326 10.83 0.000 1.635426 2.357971 -------------+---------------------------------------------------------------- sigma_u | .19554465 sigma_e | .09233035 rho | .81769849 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo SWAR: xtreg `y' `xlist', sa Random-effects GLS regression Number of obs = 342 Group variable: country2 Number of groups = 18 R-squared: Obs per group: Within = 0.8363 min = 19 Between = 0.7099 avg = 19.0 Overall = 0.7309 max = 19 Wald chi2(3) = 1642.20 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lgaspcar | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lincomep | .5549857 .0591282 9.39 0.000 .4390966 .6708748 lrpmg | -.4203892 .0399781 -10.52 0.000 -.498745 -.3420335 lcarpcap | -.6068401 .025515 -23.78 0.000 -.6568487 -.5568316 _cons | 1.996698 .184326 10.83 0.000 1.635426 2.357971 -------------+---------------------------------------------------------------- sigma_u | .19554465 sigma_e | .09233035 rho | .81769849 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo MLE: xtreg `y' `xlist', mle Fitting constant-only model: Iteration 0: Log likelihood = -22.421495 Iteration 1: Log likelihood = -22.396827 Iteration 2: Log likelihood = -22.396815 Fitting full model: Iteration 0: Log likelihood = 216.74303 Iteration 1: Log likelihood = 230.51818 Iteration 2: Log likelihood = 273.05803 Iteration 3: Log likelihood = 281.79283 Iteration 4: Log likelihood = 282.47029 Iteration 5: Log likelihood = 282.47693 Iteration 6: Log likelihood = 282.47694 Random-effects ML regression Number of obs = 342 Group variable: country2 Number of groups = 18 Random effects u_i ~ Gaussian Obs per group: min = 19 avg = 19.0 max = 19 LR chi2(3) = 609.75 Log likelihood = 282.47694 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lgaspcar | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lincomep | .5881332 .0659581 8.92 0.000 .4588576 .7174088 lrpmg | -.3780466 .0440663 -8.58 0.000 -.464415 -.2916782 lcarpcap | -.6163722 .0272054 -22.66 0.000 -.6696938 -.5630506 _cons | 2.136168 .2156039 9.91 0.000 1.713592 2.558744 -------------+---------------------------------------------------------------- /sigma_u | .2922939 .0545496 .2027512 .4213821 /sigma_e | .0922537 .0036482 .0853734 .0996885 rho | .9094086 .0317608 .8303746 .9571561 ------------------------------------------------------------------------------ LR test of sigma_u=0: chibar2(01) = 463.97 Prob >= chibar2 = 0.000 . eststo PA: xtreg `y' `xlist', pa Iteration 1: Tolerance = .22237565 Iteration 2: Tolerance = .05813824 Iteration 3: Tolerance = .01578595 Iteration 4: Tolerance = .00328533 Iteration 5: Tolerance = .00066877 Iteration 6: Tolerance = .00013561 Iteration 7: Tolerance = .00002748 Iteration 8: Tolerance = 5.566e-06 Iteration 9: Tolerance = 1.128e-06 Iteration 10: Tolerance = 2.284e-07 GEE population-averaged model Number of obs = 342 Group variable: country2 Number of groups = 18 Family: Gaussian Obs per group: Link: Identity min = 19 Correlation: exchangeable avg = 19.0 max = 19 Wald chi2(3) = 1715.11 Scale parameter = .0939464 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lgaspcar | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lincomep | .5881332 .0637347 9.23 0.000 .4632155 .7130509 lrpmg | -.3780466 .0408901 -9.25 0.000 -.4581897 -.2979036 lcarpcap | -.6163722 .0266907 -23.09 0.000 -.668685 -.5640593 _cons | 2.136168 .2055003 10.39 0.000 1.733394 2.538941 ------------------------------------------------------------------------------ . esttab OLS Between Fixed Random SWAR MLE, se ------------------------------------------------------------------------------------------------------------ (1) (2) (3) (4) (5) (6) lgaspcar lgaspcar lgaspcar lgaspcar lgaspcar lgaspcar ------------------------------------------------------------------------------------------------------------ main lincomep 0.890*** 0.968*** 0.662*** 0.555*** 0.555*** 0.588*** (0.0358) (0.156) (0.0734) (0.0591) (0.0591) (0.0660) lrpmg -0.892*** -0.964*** -0.322*** -0.420*** -0.420*** -0.378*** (0.0303) (0.133) (0.0441) (0.0400) (0.0400) (0.0441) lcarpcap -0.763*** -0.795*** -0.640*** -0.607*** -0.607*** -0.616*** (0.0186) (0.0825) (0.0297) (0.0255) (0.0255) (0.0272) _cons 2.391*** 2.542*** 2.403*** 1.997*** 1.997*** 2.136*** (0.117) (0.527) (0.225) (0.184) (0.184) (0.216) ------------------------------------------------------------------------------------------------------------ sigma_u _cons 0.292*** (0.0545) ------------------------------------------------------------------------------------------------------------ sigma_e _cons 0.0923*** (0.00365) ------------------------------------------------------------------------------------------------------------ N 342 342 342 342 342 342 ------------------------------------------------------------------------------------------------------------ Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 . est clear

Tables 2.6 - 2.10

. import excel "produc.xls", sheet("Sheet1") firstrow clear (11 vars, 816 obs) . g lny = ln(gsp) . g lnk1 = ln(p_cap) . g lnk2 = ln(pc) . g lnl = ln(emp) . g u = unemp . encode(state), g(statenum) . xtset statenum year Panel variable: statenum (strongly balanced) Time variable: year, 1970 to 1986 Delta: 1 unit

Table 2.7 Public capital productivity data: the Between estimator

. eststo be: xtreg lny lnk1 lnk2 lnl u, be Between regression (regression on group means) Number of obs = 816 Group variable: statenum Number of groups = 48 R-squared: Obs per group: Within = 0.9330 min = 17 Between = 0.9939 avg = 17.0 Overall = 0.9925 max = 17 F(4,43) = 1754.11 sd(u_i + avg(e_i.)) = .0832062 Prob > F = 0.0000 ------------------------------------------------------------------------------ lny | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- lnk1 | .1793651 .0719719 2.49 0.017 .0342199 .3245104 lnk2 | .3019542 .0418215 7.22 0.000 .2176132 .3862953 lnl | .5761274 .0563746 10.22 0.000 .4624372 .6898176 u | -.0038903 .0099084 -0.39 0.697 -.0238724 .0160918 _cons | 1.589444 .2329795 6.82 0.000 1.119596 2.059292 ------------------------------------------------------------------------------

Table 2.8 Public capital productivity data: the Within estimator

. eststo fe: xtreg lny lnk1 lnk2 lnl u, fe Fixed-effects (within) regression Number of obs = 816 Group variable: statenum Number of groups = 48 R-squared: Obs per group: Within = 0.9413 min = 17 Between = 0.9921 avg = 17.0 Overall = 0.9910 max = 17 F(4, 764) = 3064.81 corr(u_i, Xb) = 0.0608 Prob > F = 0.0000 ------------------------------------------------------------------------------ lny | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- lnk1 | -.0261496 .0290016 -0.90 0.368 -.0830818 .0307826 lnk2 | .2920069 .0251197 11.62 0.000 .2426952 .3413187 lnl | .7681594 .0300917 25.53 0.000 .7090871 .8272317 u | -.0052977 .0009887 -5.36 0.000 -.0072387 -.0033568 _cons | 2.352899 .1748131 13.46 0.000 2.009728 2.69607 -------------+---------------------------------------------------------------- sigma_u | .09057293 sigma_e | .03813705 rho | .84940449 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(47, 764) = 75.82 Prob > F = 0.0000

Table 2.9 Public capital productivity data: the Swamy and Arora estimator

. eststo re: xtreg lny lnk1 lnk2 lnl u, re theta Random-effects GLS regression Number of obs = 816 Group variable: statenum Number of groups = 48 R-squared: Obs per group: Within = 0.9412 min = 17 Between = 0.9928 avg = 17.0 Overall = 0.9917 max = 17 Wald chi2(4) = 19131.09 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 theta = .88883529 ------------------------------------------------------------------------------ lny | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lnk1 | .0044387 .0234173 0.19 0.850 -.0414584 .0503357 lnk2 | .3105484 .0198047 15.68 0.000 .2717318 .349365 lnl | .7296705 .0249202 29.28 0.000 .6808278 .7785132 u | -.0061725 .0009073 -6.80 0.000 -.0079507 -.0043942 _cons | 2.135411 .1334615 16.00 0.000 1.873831 2.39699 -------------+---------------------------------------------------------------- sigma_u | .08269049 sigma_e | .03813705 rho | .82460105 (fraction of variance due to u_i) ------------------------------------------------------------------------------

Table 2.10 Public capital productivity data: the maximum likelihood estimator

. eststo mle: xtreg lny lnk1 lnk2 lnl u, mle Fitting constant-only model: Iteration 0: Log likelihood = 194.90992 Iteration 1: Log likelihood = 195.44872 Iteration 2: Log likelihood = 195.45155 Fitting full model: Iteration 0: Log likelihood = 1374.1026 Iteration 1: Log likelihood = 1398.8952 Iteration 2: Log likelihood = 1401.8628 Iteration 3: Log likelihood = 1401.9041 Iteration 4: Log likelihood = 1401.9041 Random-effects ML regression Number of obs = 816 Group variable: statenum Number of groups = 48 Random effects u_i ~ Gaussian Obs per group: min = 17 avg = 17.0 max = 17 LR chi2(4) = 2412.91 Log likelihood = 1401.9041 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lny | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lnk1 | .0031445 .0239185 0.13 0.895 -.043735 .0500239 lnk2 | .3098112 .020081 15.43 0.000 .2704531 .3491692 lnl | .7313372 .0256936 28.46 0.000 .6809787 .7816956 u | -.0061382 .0009143 -6.71 0.000 -.0079302 -.0043462 _cons | 2.143866 .1376582 15.57 0.000 1.87406 2.413671 -------------+---------------------------------------------------------------- /sigma_u | .085162 .0090452 .0691573 .1048706 /sigma_e | .0380836 .0009735 .0362226 .0400402 rho | .833348 .0304597 .7668537 .8861754 ------------------------------------------------------------------------------ LR test of sigma_u=0: chibar2(01) = 1149.84 Prob >= chibar2 = 0.000

Table 2.6. Public capital productivity data. One-way error component results

. esttab be fe re mle, se ---------------------------------------------------------------------------- (1) (2) (3) (4) lny lny lny lny ---------------------------------------------------------------------------- main lnk1 0.179* -0.0261 0.00444 0.00314 (0.0720) (0.0290) (0.0234) (0.0239) lnk2 0.302*** 0.292*** 0.311*** 0.310*** (0.0418) (0.0251) (0.0198) (0.0201) lnl 0.576*** 0.768*** 0.730*** 0.731*** (0.0564) (0.0301) (0.0249) (0.0257) u -0.00389 -0.00530*** -0.00617*** -0.00614*** (0.00991) (0.000989) (0.000907) (0.000914) _cons 1.589*** 2.353*** 2.135*** 2.144*** (0.233) (0.175) (0.133) (0.138) ---------------------------------------------------------------------------- sigma_u _cons 0.0852*** (0.00905) ---------------------------------------------------------------------------- sigma_e _cons 0.0381*** (0.000973) ---------------------------------------------------------------------------- N 816 816 816 816 ---------------------------------------------------------------------------- Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 . est clear

Chapter 03. The Two-Way Error Component Regression Model

. import excel "grunfeld.xls", sheet("Sheet1") firstrow clear (5 vars, 200 obs) . xtset firm year Panel variable: firm (strongly balanced) Time variable: year, 1935 to 1954 Delta: 1 unit . local y invest . local xlist value cap . eststo OLS: reg `y' `xlist' Source | SS df MS Number of obs = 200 -------------+---------------------------------- F(2, 197) = 426.58 Model | 7604093.44 2 3802046.72 Prob > F = 0.0000 Residual | 1755850.48 197 8912.94662 R-squared = 0.8124 -------------+---------------------------------- Adj R-squared = 0.8105 Total | 9359943.93 199 47034.8941 Root MSE = 94.408 ------------------------------------------------------------------------------ invest | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1155622 .0058357 19.80 0.000 .1040537 .1270706 cap | .2306785 .0254758 9.05 0.000 .1804382 .2809188 _cons | -42.71437 9.511676 -4.49 0.000 -61.47215 -23.95659 ------------------------------------------------------------------------------ . eststo Fixed: xtreg `y' `xlist' i.year, fe Fixed-effects (within) regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7985 min = 20 Between = 0.8143 avg = 20.0 Overall = 0.8068 max = 20 F(21, 169) = 31.90 corr(u_i, Xb) = -0.3250 Prob > F = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1177159 .0137513 8.56 0.000 .0905694 .1448623 cap | .3579163 .022719 15.75 0.000 .3130667 .4027659 | year | 1936 | -19.19741 23.67586 -0.81 0.419 -65.93593 27.54112 1937 | -40.69001 24.69541 -1.65 0.101 -89.44123 8.061211 1938 | -39.2264 23.23594 -1.69 0.093 -85.09648 6.643668 1939 | -69.47029 23.65607 -2.94 0.004 -116.1698 -22.77082 1940 | -44.23508 23.80979 -1.86 0.065 -91.23801 2.767842 1941 | -18.80446 23.694 -0.79 0.429 -65.5788 27.96987 1942 | -21.13979 23.38163 -0.90 0.367 -67.29748 25.01789 1943 | -42.97762 23.55287 -1.82 0.070 -89.47335 3.5181 1944 | -43.09877 23.6102 -1.83 0.070 -89.70767 3.510128 1945 | -55.68304 23.89562 -2.33 0.021 -102.8554 -8.510695 1946 | -31.16928 24.11598 -1.29 0.198 -78.77666 16.43809 1947 | -39.39224 23.78368 -1.66 0.100 -86.34362 7.559135 1948 | -43.71651 23.96965 -1.82 0.070 -91.03502 3.601989 1949 | -73.4951 24.18292 -3.04 0.003 -121.2346 -25.75559 1950 | -75.89611 24.34553 -3.12 0.002 -123.9566 -27.8356 1951 | -62.48091 24.86425 -2.51 0.013 -111.5654 -13.39638 1952 | -64.63234 25.3495 -2.55 0.012 -114.6748 -14.58988 1953 | -67.71797 26.61108 -2.54 0.012 -120.2509 -15.18501 1954 | -93.52622 27.10786 -3.45 0.001 -147.0399 -40.01257 | _cons | -32.83632 18.87533 -1.74 0.084 -70.09811 4.425477 -------------+---------------------------------------------------------------- sigma_u | 91.798272 sigma_e | 51.724525 rho | .75902159 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(9, 169) = 52.36 Prob > F = 0.0000 *eststo Between: xtreg `y' `xlist', be . eststo Random: xtreg `y' `xlist', re theta Random-effects GLS regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7668 min = 20 Between = 0.8196 avg = 20.0 Overall = 0.8061 max = 20 Wald chi2(2) = 657.67 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 theta = .86122362 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097812 .0104927 10.46 0.000 .0892159 .1303464 cap | .308113 .0171805 17.93 0.000 .2744399 .3417861 _cons | -57.83441 28.89894 -2.00 0.045 -114.4753 -1.193543 -------------+---------------------------------------------------------------- sigma_u | 84.200951 sigma_e | 52.767966 rho | .71800837 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo SWAR: xtreg `y' `xlist', sa Random-effects GLS regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7668 min = 20 Between = 0.8196 avg = 20.0 Overall = 0.8061 max = 20 Wald chi2(2) = 657.67 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097812 .0104927 10.46 0.000 .0892159 .1303464 cap | .308113 .0171805 17.93 0.000 .2744399 .3417861 _cons | -57.83441 28.89894 -2.00 0.045 -114.4753 -1.193543 -------------+---------------------------------------------------------------- sigma_u | 84.200951 sigma_e | 52.767966 rho | .71800837 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo MLE: xtreg `y' `xlist', mle Fitting constant-only model: Iteration 0: Log likelihood = -1241.9899 Iteration 1: Log likelihood = -1241.9696 Iteration 2: Log likelihood = -1241.9696 Fitting full model: Iteration 0: Log likelihood = -1105.6101 Iteration 1: Log likelihood = -1098.8418 Iteration 2: Log likelihood = -1095.4188 Iteration 3: Log likelihood = -1095.2576 Iteration 4: Log likelihood = -1095.257 Random-effects ML regression Number of obs = 200 Group variable: firm Number of groups = 10 Random effects u_i ~ Gaussian Obs per group: min = 20 avg = 20.0 max = 20 LR chi2(2) = 293.43 Log likelihood = -1095.257 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097627 .0103389 10.62 0.000 .0894988 .1300265 cap | .307942 .0171006 18.01 0.000 .2744254 .3414585 _cons | -57.7672 27.70004 -2.09 0.037 -112.0583 -3.476119 -------------+---------------------------------------------------------------- /sigma_u | 80.29729 18.37811 51.27213 125.7536 /sigma_e | 52.49255 2.69306 47.47095 58.04535 rho | .7005943 .0985226 .4881266 .8603709 ------------------------------------------------------------------------------ LR test of sigma_u=0: chibar2(01) = 193.09 Prob >= chibar2 = 0.000 *eststo PA: xtreg `y' `xlist', pa . esttab OLS Fixed Random SWAR MLE, keep(`xlist' _cons) se -------------------------------------------------------------------------------------------- (1) (2) (3) (4) (5) invest invest invest invest invest -------------------------------------------------------------------------------------------- main value 0.116*** 0.118*** 0.110*** 0.110*** 0.110*** (0.00584) (0.0138) (0.0105) (0.0105) (0.0103) cap 0.231*** 0.358*** 0.308*** 0.308*** 0.308*** (0.0255) (0.0227) (0.0172) (0.0172) (0.0171) _cons -42.71*** -32.84 -57.83* -57.83* -57.77* (9.512) (18.88) (28.90) (28.90) (27.70) -------------------------------------------------------------------------------------------- sigma_u _cons 80.30*** (18.38) -------------------------------------------------------------------------------------------- sigma_e _cons 52.49*** (2.693) -------------------------------------------------------------------------------------------- N 200 200 200 200 200 -------------------------------------------------------------------------------------------- Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 . est clear

Chapter 04 Test of Hypotheses with Panel Data

. import excel "grunfeld.xls", sheet("Sheet1") firstrow clear (5 vars, 200 obs) . xtset firm year Panel variable: firm (strongly balanced) Time variable: year, 1935 to 1954 Delta: 1 unit . xtregar invest value cap , re lbi RE GLS regression with AR(1) disturbances Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7649 min = 20 Between = 0.8068 avg = 20.0 Overall = 0.7967 max = 20 Wald chi2(3) = 360.31 corr(u_i, Xb) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0949215 .0082168 11.55 0.000 .0788168 .1110262 cap | .3196589 .0258618 12.36 0.000 .2689707 .3703471 _cons | -44.38124 26.97525 -1.65 0.100 -97.25177 8.489277 -------------+---------------------------------------------------------------- rho_ar | .67210609 (estimated autocorrelation coefficient) sigma_u | 74.517098 sigma_e | 41.482496 rho_fov | .76341859 (fraction of variance due to u_i) theta | .67315697 ------------------------------------------------------------------------------ Modified Bhargava et al. Durbin–Watson = .68447968 Baltagi–Wu LBI = .95635625 . xtregar invest value cap if year!=1951 & year!= 1952 , re lbi RE GLS regression with AR(1) disturbances Number of obs = 180 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7766 min = 18 Between = 0.8112 avg = 18.0 Overall = 0.8024 max = 18 Wald chi2(3) = 341.38 corr(u_i, Xb) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0919986 .0083459 11.02 0.000 .0756409 .1083563 cap | .3243706 .0266376 12.18 0.000 .2721618 .3765793 _cons | -43.01925 27.05662 -1.59 0.112 -96.04925 10.01076 -------------+---------------------------------------------------------------- rho_ar | .68934342 (estimated autocorrelation coefficient) sigma_u | 74.002134 sigma_e | 41.535676 rho_fov | .76043802 (fraction of variance due to u_i) theta | .6551959 ------------------------------------------------------------------------------ Modified Bhargava et al. Durbin–Watson = .80652307 Baltagi–Wu LBI = 1.1394027 . xtreg invest value cap, re Random-effects GLS regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7668 min = 20 Between = 0.8196 avg = 20.0 Overall = 0.8061 max = 20 Wald chi2(2) = 657.67 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097812 .0104927 10.46 0.000 .0892159 .1303464 cap | .308113 .0171805 17.93 0.000 .2744399 .3417861 _cons | -57.83441 28.89894 -2.00 0.045 -114.4753 -1.193543 -------------+---------------------------------------------------------------- sigma_u | 84.200951 sigma_e | 52.767966 rho | .71800837 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . xttest1, unadjusted Tests for the error component model: invest[firm,t] = Xb + u[firm] + v[firm,t] v[firm,t] = lambda v[firm,(t-1)] + e[firm,t] Estimated results: | Var sd = sqrt(Var) ---------+----------------------------- invest | 47034.89 216.8753 e | 2784.458 52.767966 u | 7089.8 84.200951 Tests: Random Effects, Two Sided: LM(Var(u)=0) = 798.16 Pr>chi2(1) = 0.0000 ALM(Var(u)=0) = 664.95 Pr>chi2(1) = 0.0000 Random Effects, One Sided: LM(Var(u)=0) = 28.25 Pr>N(0,1) = 0.0000 ALM(Var(u)=0) = 25.79 Pr>N(0,1) = 0.0000 Serial Correlation: LM(lambda=0) = 143.52 Pr>chi2(1) = 0.0000 ALM(lambda=0) = 10.31 Pr>chi2(1) = 0.0013 Joint Test: LM(Var(u)=0,lambda=0) = 808.47 Pr>chi2(2) = 0.0000 . est clear . xtgls invest value cap, corr(ar1) panels(heteroskedastic) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: common AR(1) coefficient for all panels (0.9261) Estimated covariances = 10 Number of obs = 200 Estimated autocorrelations = 1 Number of groups = 10 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 107.43 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0715306 .0087269 8.20 0.000 .0544262 .088635 cap | .1405652 .0314945 4.46 0.000 .0788371 .2022933 _cons | -1.979683 6.781351 -0.29 0.770 -15.27089 11.31152 ------------------------------------------------------------------------------ . xtgls invest value cap, corr(psar1) panels(heteroskedastic) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: panel-specific AR(1) Estimated covariances = 10 Number of obs = 200 Estimated autocorrelations = 10 Number of groups = 10 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 100.13 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .071577 .00818 8.75 0.000 .0555444 .0876096 cap | .165713 .0336642 4.92 0.000 .0997324 .2316935 _cons | 5.663741 9.870045 0.57 0.566 -13.68119 25.00867 ------------------------------------------------------------------------------ . xtgls invest value cap, corr(psar1) panels(correlated) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic with cross-sectional correlation Correlation: panel-specific AR(1) Estimated covariances = 55 Number of obs = 200 Estimated autocorrelations = 10 Number of groups = 10 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 326.73 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0846195 .0056835 14.89 0.000 .07348 .095759 cap | .245775 .0214979 11.43 0.000 .20364 .2879101 _cons | -8.819493 6.304894 -1.40 0.162 -21.17686 3.537871 ------------------------------------------------------------------------------

Table 4.4 and Table 4.5

. eststo fe: qui xtreg invest value cap , fe . eststo re: qui xtreg invest value cap , re . eststo be: qui xtreg invest value cap , be . hausman fe re ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-V_B)) | fe re Difference Std. err. -------------+---------------------------------------------------------------- value | .1101238 .1097812 .0003427 .0055213 cap | .3100653 .308113 .0019524 .0024516 ------------------------------------------------------------------------------ b = Consistent under H0 and Ha; obtained from xtreg. B = Inconsistent under Ha, efficient under H0; obtained from xtreg. Test of H0: Difference in coefficients not systematic chi2(2) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 2.33 Prob > chi2 = 0.3119 . hausman be re ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-V_B)) | be re Difference Std. err. -------------+---------------------------------------------------------------- value | .1346461 .1097812 .0248649 .026762 cap | .0320315 .308113 -.2760815 .1901633 ------------------------------------------------------------------------------ b = Consistent under H0 and Ha; obtained from xtreg. B = Inconsistent under Ha, efficient under H0; obtained from xtreg. Test of H0: Difference in coefficients not systematic chi2(2) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 2.13 Prob > chi2 = 0.3445 . est clear

Chapter 05. Heteroskedasticity and Serial Correlation

Table 2.1. Table 2.1 Grunfeld's data. One-way error component results

. import excel "grunfeld.xls", sheet("Sheet1") firstrow clear (5 vars, 200 obs) . xtset firm year Panel variable: firm (strongly balanced) Time variable: year, 1935 to 1954 Delta: 1 unit

Table 5.1 Grunfeld's data. Random effects and AR(1) remainder disturbances

. xtregar invest value cap , re lbi RE GLS regression with AR(1) disturbances Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7649 min = 20 Between = 0.8068 avg = 20.0 Overall = 0.7967 max = 20 Wald chi2(3) = 360.31 corr(u_i, Xb) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0949215 .0082168 11.55 0.000 .0788168 .1110262 cap | .3196589 .0258618 12.36 0.000 .2689707 .3703471 _cons | -44.38124 26.97525 -1.65 0.100 -97.25177 8.489277 -------------+---------------------------------------------------------------- rho_ar | .67210609 (estimated autocorrelation coefficient) sigma_u | 74.517098 sigma_e | 41.482496 rho_fov | .76341859 (fraction of variance due to u_i) theta | .67315697 ------------------------------------------------------------------------------ Modified Bhargava et al. Durbin–Watson = .68447968 Baltagi–Wu LBI = .95635625

Table 5.2 Grunfeld's data. Unequally spaced panel

. xtregar invest value cap if year!=1951 & year!= 1952 , re lbi RE GLS regression with AR(1) disturbances Number of obs = 180 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7766 min = 18 Between = 0.8112 avg = 18.0 Overall = 0.8024 max = 18 Wald chi2(3) = 341.38 corr(u_i, Xb) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0919986 .0083459 11.02 0.000 .0756409 .1083563 cap | .3243706 .0266376 12.18 0.000 .2721618 .3765793 _cons | -43.01925 27.05662 -1.59 0.112 -96.04925 10.01076 -------------+---------------------------------------------------------------- rho_ar | .68934342 (estimated autocorrelation coefficient) sigma_u | 74.002134 sigma_e | 41.535676 rho_fov | .76043802 (fraction of variance due to u_i) theta | .6551959 ------------------------------------------------------------------------------ Modified Bhargava et al. Durbin–Watson = .80652307 Baltagi–Wu LBI = 1.1394027

Table 5.3 Grunfeld's data. Joint test for random effects and AR(1) remainder disturbances

. xtreg invest value cap, re Random-effects GLS regression Number of obs = 200 Group variable: firm Number of groups = 10 R-squared: Obs per group: Within = 0.7668 min = 20 Between = 0.8196 avg = 20.0 Overall = 0.8061 max = 20 Wald chi2(2) = 657.67 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .1097812 .0104927 10.46 0.000 .0892159 .1303464 cap | .308113 .0171805 17.93 0.000 .2744399 .3417861 _cons | -57.83441 28.89894 -2.00 0.045 -114.4753 -1.193543 -------------+---------------------------------------------------------------- sigma_u | 84.200951 sigma_e | 52.767966 rho | .71800837 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . xttest1, unadjusted Tests for the error component model: invest[firm,t] = Xb + u[firm] + v[firm,t] v[firm,t] = lambda v[firm,(t-1)] + e[firm,t] Estimated results: | Var sd = sqrt(Var) ---------+----------------------------- invest | 47034.89 216.8753 e | 2784.458 52.767966 u | 7089.8 84.200951 Tests: Random Effects, Two Sided: LM(Var(u)=0) = 798.16 Pr>chi2(1) = 0.0000 ALM(Var(u)=0) = 664.95 Pr>chi2(1) = 0.0000 Random Effects, One Sided: LM(Var(u)=0) = 28.25 Pr>N(0,1) = 0.0000 ALM(Var(u)=0) = 25.79 Pr>N(0,1) = 0.0000 Serial Correlation: LM(lambda=0) = 143.52 Pr>chi2(1) = 0.0000 ALM(lambda=0) = 10.31 Pr>chi2(1) = 0.0013 Joint Test: LM(Var(u)=0,lambda=0) = 808.47 Pr>chi2(2) = 0.0000

Table 5.5 Common rho and heteroskedastic AR(1) for Grunfeld data

. xtgls invest value cap, corr(ar1) panels(heteroskedastic) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: common AR(1) coefficient for all panels (0.9261) Estimated covariances = 10 Number of obs = 200 Estimated autocorrelations = 1 Number of groups = 10 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 107.43 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0715306 .0087269 8.20 0.000 .0544262 .088635 cap | .1405652 .0314945 4.46 0.000 .0788371 .2022933 _cons | -1.979683 6.781351 -0.29 0.770 -15.27089 11.31152 ------------------------------------------------------------------------------

Table 5.6 Varying rhos and heteroskedastic AR(1) for Grunfeld data

. xtgls invest value cap, corr(psar1) panels(heteroskedastic) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: panel-specific AR(1) Estimated covariances = 10 Number of obs = 200 Estimated autocorrelations = 10 Number of groups = 10 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 100.13 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .071577 .00818 8.75 0.000 .0555444 .0876096 cap | .165713 .0336642 4.92 0.000 .0997324 .2316935 _cons | 5.663741 9.870045 0.57 0.566 -13.68119 25.00867 ------------------------------------------------------------------------------

Table 5.7 Varying rhos and cross-section dependence AR(1) for Grunfeld data

. xtgls invest value cap, corr(psar1) panels(correlated) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic with cross-sectional correlation Correlation: panel-specific AR(1) Estimated covariances = 55 Number of obs = 200 Estimated autocorrelations = 10 Number of groups = 10 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 326.73 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- value | .0846195 .0056835 14.89 0.000 .07348 .095759 cap | .245775 .0214979 11.43 0.000 .20364 .2879101 _cons | -8.819493 6.304894 -1.40 0.162 -21.17686 3.537871 ------------------------------------------------------------------------------

Table 5.8 Explaining OECD unemployment, 1961-95

. * Version 2 downloaded from https://cep.lse.ac.uk/_new/publications/abstract.asp?index=502 . import excel "Nickell et al\DATASET.xls", sheet("LMIDB") cellrange(A2:AA707) firstrow clear (27 vars, 705 obs) . encode country, g(ccode) . xtset ccode year Panel variable: ccode (unbalanced) Time variable: year, 1960 to 1995 Delta: 1 unit . g ur_1 = L.ur (20 missing values generated) . g c_ud = udnet . *g c_ud = udnet-L.udnet . foreach var of varlist bd br c_ud co tw{ 2. egen `var'_mean = mean(`var') 3. } . *"All variables in the interaction terms are expressed as deviations from the sample means." P.14 . g gd_bd_br = (bd - bd_mean) * (brr - brr_mean) . g gd_co_ud = (c_ud - c_ud_mean) * (co - co_mean) . g gd_co_tw = (co - co_mean) * (tw - tw_mean) (43 missing values generated) . xtgls ur ur_1 ep brr bd gd_bd_br c_ud co gd_co_ud tw gd_co_tw lds tfphpc tts d2ms rirl i.ccode c.year#i.ccode i.year , > p(hetero) corr(psar1) rhotype(theil) igls note: 20.ccode#c.year omitted because of collinearity. (note: 106 observations dropped because only 1 obs in group) Iteration 1: Tolerance = 3.7255012 . . . Iteration 53: Tolerance = 8.238e-08 Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: panel-specific AR(1) Estimated covariances = 20 Number of obs = 599 Estimated autocorrelations = 20 Number of groups = 20 Estimated coefficients = 86 Obs per group: min = 12 avg = 29.95 max = 33 Wald chi2(85) = 46915.28 Prob > chi2 = 0.0000 --------------------------------------------------------------------------------- ur | Coefficient Std. err. z P>|z| [95% conf. interval] ----------------+---------------------------------------------------------------- ur_1 | .8613531 .0182546 47.19 0.000 .8255748 .8971314 ep | .2746168 .174397 1.57 0.115 -.0671951 .6164287 brr | 2.460365 .4096456 6.01 0.000 1.657474 3.263256 bd | .5830818 .1994344 2.92 0.003 .1921975 .9739661 gd_bd_br | 3.974759 .9444889 4.21 0.000 2.123595 5.825924 c_ud | -.2064364 .9207731 -0.22 0.823 -2.011118 1.598246 co | -.9594787 .2789043 -3.44 0.001 -1.506121 -.4128363 gd_co_ud | -7.283085 1.198052 -6.08 0.000 -9.631224 -4.934945 tw | 1.493038 .8723322 1.71 0.087 -.2167016 3.202778 gd_co_tw | -3.636719 1.059612 -3.43 0.001 -5.713521 -1.559918 lds | -26.22182 2.326425 -11.27 0.000 -30.78153 -21.66211 tfphpc | -18.12906 1.283634 -14.12 0.000 -20.64494 -15.61318 tts | 5.899416 1.782549 3.31 0.001 2.405685 9.393147 d2ms | .3802618 .2637265 1.44 0.149 -.1366327 .8971562 rirl | 1.521738 1.174045 1.30 0.195 -.7793483 3.822824 --------------------------------------------------------------------------------- Time and country dummies as well as country specific time trends are not shown here. Note also that the result presented here, which is based on version 2 of the data, deviates slightly from the result in the original paper.

Table 5.9 Wooldridge test for serial correlation using Grunfeld's data

. * "net describe st0039, from(http://www.stata-journal.com/software/sj3-2)" . import excel "grunfeld.xls", sheet("Sheet1") firstrow clear (5 vars, 200 obs) . xtset firm year Panel variable: firm (strongly balanced) Time variable: year, 1935 to 1954 Delta: 1 unit . xtserial invest value cap, output Linear regression Number of obs = 190 F(2, 9) = 47.80 Prob > F = 0.0000 R-squared = 0.4288 Root MSE = 42.896 (Std. err. adjusted for 10 clusters in firm) ------------------------------------------------------------------------------ | Robust D.invest | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- value | D1. | .0890628 .0145088 6.14 0.000 .0562416 .1218841 | cap | D1. | .278694 .138404 2.01 0.075 -.0343976 .5917857 ------------------------------------------------------------------------------ Wooldridge test for autocorrelation in panel data H0: no first-order autocorrelation F( 1, 9) = 263.592 Prob > F = 0.0000

Chapter 06. Seemingly Unrelated Regressions

N/A

Chapter 07. Simultaneous Equations

* Example 7.2. Load fixed-format or delimited raw data . infile /// > county year crmrte prbarr prbconv prbpris avgsen polpc /// > density taxpc west central urban pctmin80 wcon wtuc /// > wtrd wfir wser wmfg wfed wsta wloc mix /// > pctymle d82 d83 d84 d85 d86 d87 lcrmrte /// > lprbarr lprbconv lprbpris lavgsen lpolpc ldensity ltaxpc lwcon /// > lwtuc lwtrd lwfir lwser lwmfg lwfed lwsta lwloc /// > lmix lpctymle lpctmin clcrmrte clprbarr clprbcon clprbpri clavgsen /// > clpolpc cltaxpc clmix /// > using "cornwell.raw", clear (630 observations read) . xtset county year Panel variable: county (strongly balanced) Time variable: year, 81 to 87 Delta: 1 unit *export excel using "cornwell.xls", firstrow(variables) replace

Table 7.2 EC2SLS estimates for the crime data

. xtivreg lcrmrte lprbconv lprbpris lavgsen ldensity lwcon lwtuc lwtrd lwfir lwser lwmfg lwfed lwsta lwloc lpctymle lpct > min west central urban d82 d83 d84 d85 d86 d87 ( lprbarr lpolpc= ltaxpc lmix), ec2sls EC2SLS random-effects IV regression Number of obs = 630 Group variable: county Number of groups = 90 R-squared: Obs per group: Within = 0.4521 min = 7 Between = 0.8158 avg = 7.0 Overall = 0.7840 max = 7 Wald chi2(26) = 575.74 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lcrmrte | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lprbarr | -.4129261 .097402 -4.24 0.000 -.6038304 -.2220218 lpolpc | .4347492 .089695 4.85 0.000 .2589502 .6105482 lprbconv | -.3228872 .0535517 -6.03 0.000 -.4278465 -.2179279 lprbpris | -.1863195 .0419382 -4.44 0.000 -.2685169 -.1041222 lavgsen | -.0101765 .0270231 -0.38 0.706 -.0631408 .0427877 ldensity | .4290282 .0548483 7.82 0.000 .3215275 .536529 lwcon | -.0074751 .0395775 -0.19 0.850 -.0850455 .0700954 lwtuc | .045445 .0197926 2.30 0.022 .0066522 .0842379 lwtrd | -.0081412 .0413828 -0.20 0.844 -.0892499 .0729676 lwfir | -.0036395 .0289238 -0.13 0.900 -.0603292 .0530502 lwser | .0056098 .0201259 0.28 0.780 -.0338361 .0450557 lwmfg | -.2041398 .0804393 -2.54 0.011 -.361798 -.0464816 lwfed | -.1635108 .1594496 -1.03 0.305 -.4760263 .1490047 lwsta | -.0540503 .1056769 -0.51 0.609 -.2611732 .1530727 lwloc | .1630523 .119638 1.36 0.173 -.0714339 .3975384 lpctymle | -.1081057 .1396949 -0.77 0.439 -.3819026 .1656912 lpctmin | .189037 .0414988 4.56 0.000 .1077009 .2703731 west | -.2268433 .0995913 -2.28 0.023 -.4220387 -.0316479 central | -.1940428 .0598241 -3.24 0.001 -.3112958 -.0767898 urban | -.2251539 .1156302 -1.95 0.052 -.4517851 .0014772 d82 | .0107452 .0257969 0.42 0.677 -.0398158 .0613062 d83 | -.0837944 .0307088 -2.73 0.006 -.1439825 -.0236063 d84 | -.1034997 .0370885 -2.79 0.005 -.1761918 -.0308076 d85 | -.0957017 .0494502 -1.94 0.053 -.1926223 .0012189 d86 | -.0688982 .0595956 -1.16 0.248 -.1857036 .0479071 d87 | -.0314071 .0705197 -0.45 0.656 -.1696232 .1068091 _cons | -.9538033 1.283966 -0.74 0.458 -3.470331 1.562725 -------------+---------------------------------------------------------------- sigma_u | .21455964 sigma_e | .14923892 rho | .67394413 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Endogenous: lprbarr lpolpc Exogenous: lprbconv lprbpris lavgsen ldensity lwcon lwtuc lwtrd lwfir lwser lwmfg lwfed lwsta lwloc lpctymle lpctmin west central urban d82 d83 d84 d85 d86 d87 ltaxpc lmix

Table 7.3 Random effects 2SLS for crime data (G2SLS)

. xtivreg lcrmrte lprbconv lprbpris lavgsen ldensity lwcon lwtuc lwtrd lwfir lwser lwmfg lwfed lwsta lwloc lpctymle lpct > min west central urban d82 d83 d84 d85 d86 d87 ( lprbarr lpolpc= ltaxpc lmix), re G2SLS random-effects IV regression Number of obs = 630 Group variable: county Number of groups = 90 R-squared: Obs per group: Within = 0.4521 min = 7 Between = 0.8036 avg = 7.0 Overall = 0.7725 max = 7 Wald chi2(26) = 542.48 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lcrmrte | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lprbarr | -.4141383 .2210496 -1.87 0.061 -.8473875 .0191109 lpolpc | .5049461 .2277778 2.22 0.027 .0585098 .9513824 lprbconv | -.3432506 .1324648 -2.59 0.010 -.6028768 -.0836244 lprbpris | -.1900467 .0733392 -2.59 0.010 -.333789 -.0463045 lavgsen | -.0064389 .0289407 -0.22 0.824 -.0631617 .0502838 ldensity | .4343449 .0711496 6.10 0.000 .2948943 .5737956 lwcon | -.0042958 .0414226 -0.10 0.917 -.0854826 .0768911 lwtuc | .0444589 .0215448 2.06 0.039 .0022318 .0866859 lwtrd | -.0085579 .0419829 -0.20 0.838 -.0908428 .073727 lwfir | -.0040305 .0294569 -0.14 0.891 -.0617649 .0537038 lwser | .0105602 .0215823 0.49 0.625 -.0317403 .0528608 lwmfg | -.201802 .0839373 -2.40 0.016 -.3663161 -.0372878 lwfed | -.2134579 .2151046 -0.99 0.321 -.6350551 .2081393 lwsta | -.0601232 .1203149 -0.50 0.617 -.295936 .1756896 lwloc | .1835363 .1396775 1.31 0.189 -.0902265 .4572992 lpctymle | -.1458703 .2268086 -0.64 0.520 -.5904071 .2986664 lpctmin | .1948763 .0459385 4.24 0.000 .1048384 .2849141 west | -.2281821 .101026 -2.26 0.024 -.4261894 -.0301747 central | -.1987703 .0607475 -3.27 0.001 -.3178332 -.0797075 urban | -.2595451 .1499718 -1.73 0.084 -.5534844 .0343942 d82 | .0132147 .0299924 0.44 0.660 -.0455692 .0719987 d83 | -.0847693 .032001 -2.65 0.008 -.1474901 -.0220485 d84 | -.1062027 .0387893 -2.74 0.006 -.1822284 -.0301769 d85 | -.0977457 .0511681 -1.91 0.056 -.1980334 .002542 d86 | -.0719451 .0605819 -1.19 0.235 -.1906835 .0467933 d87 | -.0396595 .0758531 -0.52 0.601 -.1883289 .1090099 _cons | -.4538501 1.702983 -0.27 0.790 -3.791636 2.883935 -------------+---------------------------------------------------------------- sigma_u | .21455964 sigma_e | .14923892 rho | .67394413 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Endogenous: lprbarr lpolpc Exogenous: lprbconv lprbpris lavgsen ldensity lwcon lwtuc lwtrd lwfir lwser lwmfg lwfed lwsta lwloc lpctymle lpctmin west central urban d82 d83 d84 d85 d86 d87 ltaxpc lmix

Table 7.4 Fixed Effects 3SLS for Economic Growth and Foreign Aid

. u Bruckner2013/data-stata.dta, clear . encode country, gen(Iccode) *g lcru_l_sq = lcru_l^2 . keep if year >= 1960 (38 observations deleted) . xtset Iccode year Panel variable: Iccode (unbalanced) Time variable: year, 1960 to 2000 Delta: 1 unit . eststo su: qui reg3 (D.lgdp D.loda index_g_l D.lcru_l D.lcru_l_sq i.year i.Iccode) (D.loda D.lgdp D.polity2 war i.year > i.Iccode) . esttab su, drop(*.year *.Iccode) se ---------------------------- (1) D.lgdp ---------------------------- D_lgdp D.loda 0.120 (0.149) index_g_l 0.476 (0.291) D.lcru_l 0.273* (0.125) D.lcru_l_sq -0.0187* (0.00865) _cons -0.168 (0.156) ---------------------------- D_loda D.lgdp -3.801* (1.900) D.polity2 0.0167* (0.00832) war -0.0736 (0.0779) _cons 0.873*** (0.184) ---------------------------- N 1265 ---------------------------- Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 . est clear

Example 7.5. Empirical Example: Earnings Equation Using PSID Data

The data is missing ID and time variables. First, let's generate them. Fortunately, the data is already sorted. N=595 and T= 7) . import excel "wages.xls", sheet("Sheet1") firstrow clear (12 vars, 4,165 obs) . egen obs=seq() . gen id = floor((_n - 1) / 7) + 1 . gen year = 1981 + mod(_n - 1, 7) . rename *, lower // converts var-names to lower cases *export excel using "wagesol.xls", firstrow(variables) replace . xtset id year Panel variable: id (strongly balanced) Time variable: year, 1981 to 1987 Delta: 1 unit

Table 7.6 Hausman and Taylor estimates of a mincer wage equation

. g exp2 = exper^2 . xthtaylor lwage occ south smsa ind exper exp2 wks ms union fem blk ed, endog (exper exp2 wks ms union ed) Hausman–Taylor estimation Number of obs = 4,165 Group variable: id Number of groups = 595 Obs per group: min = 7 avg = 7 max = 7 Random effects u_i ~ i.i.d. Wald chi2(12) = 6891.87 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lwage | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- TVexogenous | occ | -.0207047 .0137809 -1.50 0.133 -.0477149 .0063055 south | .0074398 .031955 0.23 0.816 -.0551908 .0700705 smsa | -.0418334 .0189581 -2.21 0.027 -.0789906 -.0046761 ind | .0136039 .0152374 0.89 0.372 -.0162608 .0434686 TVendogenous | exper | .1131328 .002471 45.79 0.000 .1082898 .1179758 exp2 | -.0004189 .0000546 -7.67 0.000 -.0005259 -.0003119 wks | .0008374 .0005997 1.40 0.163 -.0003381 .0020129 ms | -.0298507 .01898 -1.57 0.116 -.0670508 .0073493 union | .0327714 .0149084 2.20 0.028 .0035514 .0619914 TIexogenous | fem | -.1309236 .126659 -1.03 0.301 -.3791707 .1173234 blk | -.2857479 .1557019 -1.84 0.066 -.5909179 .0194222 TIendogenous | ed | .137944 .0212485 6.49 0.000 .0962977 .1795902 | _cons | 2.912726 .2836522 10.27 0.000 2.356778 3.468674 -------------+---------------------------------------------------------------- sigma_u | .941803 sigma_e | .15180272 rho | .97467788 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Note: TV refers to time varying; TI refers to time invariant. . eststo HT

Table 7.7 Amemiya and MaCurdy estimates of a mincer wage equation

. xthtaylor lwage occ south smsa ind exper exp2 wks ms union fem blk ed, endog (exper exp2 wks ms union ed) amacurdy Amemiya–MaCurdy estimation Number of obs = 4,165 Group variable: id Number of groups = 595 Time variable: year Obs per group: min = 7 avg = 7 max = 7 Random effects u_i ~ i.i.d. Wald chi2(12) = 6879.20 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lwage | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- TVexogenous | occ | -.0208498 .0137653 -1.51 0.130 -.0478292 .0061297 south | .0072818 .0319365 0.23 0.820 -.0553126 .0698761 smsa | -.0419507 .0189471 -2.21 0.027 -.0790864 -.004815 ind | .0136289 .015229 0.89 0.371 -.0162194 .0434771 TVendogenous | exper | .1129704 .0024688 45.76 0.000 .1081316 .1178093 exp2 | -.0004214 .0000546 -7.72 0.000 -.0005283 -.0003145 wks | .0008381 .0005995 1.40 0.162 -.0003368 .002013 ms | -.0300894 .0189674 -1.59 0.113 -.0672649 .0070861 union | .0324752 .0148939 2.18 0.029 .0032837 .0616667 TIexogenous | fem | -.132008 .1266039 -1.04 0.297 -.380147 .1161311 blk | -.2859004 .1554857 -1.84 0.066 -.5906468 .0188459 TIendogenous | ed | .1372049 .0205695 6.67 0.000 .0968894 .1775205 | _cons | 2.927338 .2751274 10.64 0.000 2.388098 3.466578 -------------+---------------------------------------------------------------- sigma_u | .941803 sigma_e | .15180272 rho | .97467788 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Note: TV refers to time varying; TI refers to time invariant. . eststo AM . xtreg lwage occ south smsa ind exper exp2 wks ms union fem blk ed, re Random-effects GLS regression Number of obs = 4,165 Group variable: id Number of groups = 595 R-squared: Obs per group: Within = 0.6124 min = 7 Between = 0.2539 avg = 7.0 Overall = 0.2512 max = 7 Wald chi2(12) = 2654.74 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lwage | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- occ | -.0500664 .0166469 -3.01 0.003 -.0826937 -.0174391 south | -.0166176 .0265265 -0.63 0.531 -.0686086 .0353734 smsa | -.0138231 .0199927 -0.69 0.489 -.0530081 .0253619 ind | .0037441 .0172618 0.22 0.828 -.0300883 .0375766 exper | .0820544 .0028478 28.81 0.000 .0764729 .0876359 exp2 | -.0008084 .0000628 -12.87 0.000 -.0009316 -.0006853 wks | .0010347 .0007734 1.34 0.181 -.0004811 .0025505 ms | -.0746283 .0230052 -3.24 0.001 -.1197178 -.0295389 union | .0632232 .01707 3.70 0.000 .0297666 .0966798 fem | -.3392101 .0513033 -6.61 0.000 -.4397627 -.2386574 blk | -.2102803 .0579888 -3.63 0.000 -.3239363 -.0966243 ed | .0996585 .0057475 17.34 0.000 .0883937 .1109234 _cons | 4.26367 .0977162 43.63 0.000 4.07215 4.45519 -------------+---------------------------------------------------------------- sigma_u | .26265815 sigma_e | .15199443 rho | .74913777 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo GLS . xtreg lwage occ south smsa ind exper exp2 wks ms union fem blk ed, fe note: fem omitted because of collinearity. note: blk omitted because of collinearity. note: ed omitted because of collinearity. Fixed-effects (within) regression Number of obs = 4,165 Group variable: id Number of groups = 595 R-squared: Obs per group: Within = 0.6581 min = 7 Between = 0.0261 avg = 7.0 Overall = 0.0461 max = 7 F(9, 3561) = 761.75 corr(u_i, Xb) = -0.9100 Prob > F = 0.0000 ------------------------------------------------------------------------------ lwage | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- occ | -.0214765 .0137837 -1.56 0.119 -.0485012 .0055482 south | -.0018612 .0342993 -0.05 0.957 -.0691094 .065387 smsa | -.0424692 .0194284 -2.19 0.029 -.080561 -.0043773 ind | .0192101 .0154463 1.24 0.214 -.0110744 .0494946 exper | .1132083 .002471 45.81 0.000 .1083635 .1180531 exp2 | -.0004184 .0000546 -7.66 0.000 -.0005254 -.0003113 wks | .0008359 .0005997 1.39 0.163 -.0003398 .0020117 ms | -.0297258 .0189836 -1.57 0.117 -.0669456 .0074939 union | .0327849 .0149229 2.20 0.028 .0035266 .0620431 fem | 0 (omitted) blk | 0 (omitted) ed | 0 (omitted) _cons | 4.648767 .046022 101.01 0.000 4.558535 4.738999 -------------+---------------------------------------------------------------- sigma_u | 1.0338102 sigma_e | .15199443 rho | .97884144 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(594, 3561) = 38.25 Prob > F = 0.0000 . eststo Within

Table 7.5. Mincer Wage Equation. Dependent Variable: Log Wage

. esttab GLS Within HT AM, order(_cons wks south smsa ms exper exp2 occ ind union fem blk ed) se stats(N, fmt(%9.0g)) t > label ------------------------------------------------------------------------------------ (1) (2) (3) (4) LWAGE LWAGE LWAGE LWAGE ------------------------------------------------------------------------------------ Constant 4.264*** 4.649*** 2.913*** 2.927*** (0.0977) (0.0460) (0.284) (0.275) WKS 0.00103 0.000836 0.000837 0.000838 (0.000773) (0.000600) (0.000600) (0.000599) SOUTH -0.0166 -0.00186 0.00744 0.00728 (0.0265) (0.0343) (0.0320) (0.0319) SMSA -0.0138 -0.0425* -0.0418* -0.0420* (0.0200) (0.0194) (0.0190) (0.0189) MS -0.0746** -0.0297 -0.0299 -0.0301 (0.0230) (0.0190) (0.0190) (0.0190) EXPER 0.0821*** 0.113*** 0.113*** 0.113*** (0.00285) (0.00247) (0.00247) (0.00247) exp2 -0.000808*** -0.000418*** -0.000419*** -0.000421*** (0.0000628) (0.0000546) (0.0000546) (0.0000546) OCC -0.0501** -0.0215 -0.0207 -0.0208 (0.0166) (0.0138) (0.0138) (0.0138) IND 0.00374 0.0192 0.0136 0.0136 (0.0173) (0.0154) (0.0152) (0.0152) UNION 0.0632*** 0.0328* 0.0328* 0.0325* (0.0171) (0.0149) (0.0149) (0.0149) FEM -0.339*** 0 -0.131 -0.132 (0.0513) (.) (0.127) (0.127) BLK -0.210*** 0 -0.286 -0.286 (0.0580) (.) (0.156) (0.155) ED 0.0997*** 0 0.138*** 0.137*** (0.00575) (.) (0.0212) (0.0206) ------------------------------------------------------------------------------------ N 4165 4165 4165 4165 ------------------------------------------------------------------------------------ Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 . est clear

Chapter 08. Dynamic Panel Data Models

. import excel "cigar.xls", sheet("Sheet1") firstrow clear (9 vars, 1,380 obs) . forvalues year = 63(1)92 { 2. local id=`year'-62 3. gen dum`id' = (yr == `year' ) 4. } . g lnc = ln(c) . g lnrp = ln(100*pric/cpi) // CPI in 1983 is base . g lnrpn = ln(100*pimin/cpi) . g lnrdi = ln(100*ndi/cpi) . xtset state yr Panel variable: state (strongly balanced) Time variable: yr, 63 to 92 Delta: 1 unit

Table 8.2 Robust Arellano and Bond GMM estimates of cigarette demand

. xtabond2 lnc L.(lnc) lnrp lnrpn lnrdi dum3 dum8 dum10-dum29, gmm(L.(lnc),collapse) iv(lnrp lnrpn lnrdi dum3 dum8 dum10 > -dum29) noleveleq robust nomata twostep Building GMM instruments.. Estimating. Warning: Two-step estimated covariance matrix of moment conditions is singular. Number of instruments may be large relative to number of groups. Using a generalized inverse to calculate optimal weighting matrix for two-step estimation. Computing Windmeijer finite-sample correction............................................... Performing specification tests. Dynamic panel-data estimation, two-step difference GMM ------------------------------------------------------------------------------ Group variable: state Number of obs = 1288 Time variable : yr Number of groups = 46 Number of instruments = 53 Obs per group: min = 28 Wald chi2(25) = 5514.80 avg = 28.00 Prob > chi2 = 0.000 max = 28 ------------------------------------------------------------------------------ | Corrected lnc | Coefficient std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lnc | L1. | .6229851 .0899459 6.93 0.000 .4466945 .7992758 | lnrp | -.4037713 .0557992 -7.24 0.000 -.5131358 -.2944069 lnrpn | -.0860823 .0567726 -1.52 0.129 -.1973546 .02519 lnrdi | .1811735 .0296537 6.11 0.000 .1230533 .2392938 dum3 | .0130439 .0064342 2.03 0.043 .0004332 .0256546 dum8 | -.0229507 .0083476 -2.75 0.006 -.0393116 -.0065897 dum10 | .0265546 .0069401 3.83 0.000 .0129522 .040157 dum11 | -.0154596 .0093165 -1.66 0.097 -.0337197 .0028004 dum12 | -.0285942 .0100817 -2.84 0.005 -.0483539 -.0088345 dum13 | -.0414232 .0128014 -3.24 0.001 -.0665135 -.0163329 dum14 | -.0217906 .0141043 -1.54 0.122 -.0494345 .0058532 dum15 | -.0550672 .0156099 -3.53 0.000 -.0856621 -.0244724 dum16 | -.0455133 .015351 -2.96 0.003 -.0756007 -.0154259 dum17 | -.0894756 .0167478 -5.34 0.000 -.1223007 -.0566504 dum18 | -.1047575 .0189296 -5.53 0.000 -.1418588 -.0676562 dum19 | -.1280314 .0212807 -6.02 0.000 -.1697408 -.086322 dum20 | -.1210131 .0194657 -6.22 0.000 -.1591653 -.082861 dum21 | -.0942632 .0159669 -5.90 0.000 -.1255577 -.0629686 dum22 | -.0810146 .0126521 -6.40 0.000 -.1058123 -.056217 dum23 | -.0578651 .0105522 -5.48 0.000 -.078547 -.0371832 dum24 | -.0518459 .0110368 -4.70 0.000 -.0734776 -.0302141 dum25 | -.0585906 .0093694 -6.25 0.000 -.0769541 -.040227 dum26 | -.0615617 .0110503 -5.57 0.000 -.0832199 -.0399036 dum27 | -.0674198 .0076093 -8.86 0.000 -.0823336 -.0525059 dum28 | -.062461 .0096978 -6.44 0.000 -.0814683 -.0434537 dum29 | -.0557242 .0077968 -7.15 0.000 -.0710056 -.0404428 ------------------------------------------------------------------------------ Instruments for first differences equation Standard D.(lnrp lnrpn lnrdi dum3 dum8 dum10 dum11 dum12 dum13 dum14 dum15 dum16 dum17 dum18 dum19 dum20 dum21 dum22 dum23 dum24 dum25 dum26 dum27 dum28 dum29) GMM-type (missing=0, separate instruments for each period unless collapsed) L(1/.).L.lnc collapsed ------------------------------------------------------------------------------ Arellano-Bond test for AR(1) in first differences: z = -4.35 Pr > z = 0.000 Arellano-Bond test for AR(2) in first differences: z = 1.53 Pr > z = 0.127 ------------------------------------------------------------------------------ Sargan test of overid. restrictions: chi2(27) = 67.91 Prob > chi2 = 0.000 (Not robust, but not weakened by many instruments.) Hansen test of overid. restrictions: chi2(27) = 27.16 Prob > chi2 = 0.455 (Robust, but weakened by many instruments.)

Table 8.3 System GMM estimates of cigarette demand

. xtabond2 lnc L.(lnc) lnrp lnrpn lnrdi dum3 dum8 dum10-dum29, gmm(L.(lnc),collapse) iv(lnrp lnrpn lnrdi dum3 dum8 dum10 > -dum29) robust nomata twostep Building GMM instruments.. Estimating. Warning: Two-step estimated covariance matrix of moment conditions is singular. Number of instruments may be large relative to number of groups. Using a generalized inverse to calculate optimal weighting matrix for two-step estimation. Computing Windmeijer finite-sample correction............................................... Performing specification tests. Dynamic panel-data estimation, two-step system GMM ------------------------------------------------------------------------------ Group variable: state Number of obs = 1334 Time variable : yr Number of groups = 46 Number of instruments = 55 Obs per group: min = 29 Wald chi2(25) = 6025.77 avg = 29.00 Prob > chi2 = 0.000 max = 29 ------------------------------------------------------------------------------ | Corrected lnc | Coefficient std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lnc | L1. | .6097922 .1075885 5.67 0.000 .3989226 .8206619 | lnrp | -.5135009 .1275413 -4.03 0.000 -.7634772 -.2635245 lnrpn | .0240955 .060918 0.40 0.692 -.0953015 .1434925 lnrdi | .1743783 .0474192 3.68 0.000 .0814383 .2673183 dum3 | .0111092 .0083385 1.33 0.183 -.005234 .0274524 dum8 | -.0193185 .0086728 -2.23 0.026 -.036317 -.0023201 dum10 | .0292373 .0076768 3.81 0.000 .0141911 .0442835 dum11 | -.0089089 .0101159 -0.88 0.378 -.0287356 .0109179 dum12 | -.0226511 .0147128 -1.54 0.124 -.0514877 .0061856 dum13 | -.0352768 .0172662 -2.04 0.041 -.0691178 -.0014357 dum14 | -.0166988 .0138771 -1.20 0.229 -.0438973 .0104998 dum15 | -.0506543 .0185271 -2.73 0.006 -.0869668 -.0143419 dum16 | -.0417593 .0160734 -2.60 0.009 -.0732627 -.010256 dum17 | -.0847489 .0235934 -3.59 0.000 -.1309911 -.0385067 dum18 | -.1038062 .0307475 -3.38 0.001 -.1640703 -.0435421 dum19 | -.1255405 .0377838 -3.32 0.001 -.1995953 -.0514857 dum20 | -.1199206 .0298965 -4.01 0.000 -.1785167 -.0613244 dum21 | -.094771 .0174418 -5.43 0.000 -.1289563 -.0605856 dum22 | -.0798828 .0127865 -6.25 0.000 -.104944 -.0548217 dum23 | -.0580374 .0133836 -4.34 0.000 -.0842687 -.0318061 dum24 | -.053246 .0120799 -4.41 0.000 -.0769221 -.0295699 dum25 | -.060592 .0103091 -5.88 0.000 -.0807975 -.0403865 dum26 | -.0576665 .0135268 -4.26 0.000 -.0841786 -.0311544 dum27 | -.066534 .0079063 -8.42 0.000 -.08203 -.051038 dum28 | -.0624675 .0091624 -6.82 0.000 -.0804256 -.0445095 dum29 | -.0547591 .0102868 -5.32 0.000 -.0749208 -.0345973 _cons | 2.51039 .8051728 3.12 0.002 .9322799 4.088499 ------------------------------------------------------------------------------ Instruments for first differences equation Standard D.(lnrp lnrpn lnrdi dum3 dum8 dum10 dum11 dum12 dum13 dum14 dum15 dum16 dum17 dum18 dum19 dum20 dum21 dum22 dum23 dum24 dum25 dum26 dum27 dum28 dum29) GMM-type (missing=0, separate instruments for each period unless collapsed) L(1/.).L.lnc collapsed Instruments for levels equation Standard _cons lnrp lnrpn lnrdi dum3 dum8 dum10 dum11 dum12 dum13 dum14 dum15 dum16 dum17 dum18 dum19 dum20 dum21 dum22 dum23 dum24 dum25 dum26 dum27 dum28 dum29 GMM-type (missing=0, separate instruments for each period unless collapsed) D.L.lnc collapsed ------------------------------------------------------------------------------ Arellano-Bond test for AR(1) in first differences: z = -4.15 Pr > z = 0.000 Arellano-Bond test for AR(2) in first differences: z = 1.29 Pr > z = 0.196 ------------------------------------------------------------------------------ Sargan test of overid. restrictions: chi2(28) = 85.97 Prob > chi2 = 0.000 (Not robust, but not weakened by many instruments.) Hansen test of overid. restrictions: chi2(28) = 28.79 Prob > chi2 = 0.423 (Robust, but weakened by many instruments.)

Table 8.4 Keane and Runkle estimates of cigarette demand in levels

. xtkr lnc lnrp lnrpn lnrdi (l.lnc=l.lnrp l.lnrpn l.lnrdi) Keane-Runkle (1992) Regression Number of Obs: 1334 Number of Panel Units: 46 ------------------------------------------------------------------------------ lnc | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lnrp | -.3872708 .0242384 -15.98 0.000 -.4347772 -.3397643 lnrpn | .0927905 .0271084 3.42 0.001 .0396591 .145922 lnrdi | .0773962 .0126045 6.14 0.000 .0526919 .1021006 | lnc | L1. | .6655751 .0284007 23.44 0.000 .6099108 .7212394 | constant | 2.225425 .2024251 10.99 0.000 1.82868 2.622171 ------------------------------------------------------------------------------ Instruments: lnrp lnrpn lnrdi constant L.lnrp L.lnrpn L.lnrdi

Table 8.5 Keane and Runkle estimates of cigarette demand in differences

. xtkr d.lnc d.lnrp d.lnrpn d.lnrdi (d.l.lnc=l(1/2).lnrp l(1/2).lnrpn l(1/2).lnrdi) Keane-Runkle (1992) Regression Number of Obs: 1288 Number of Panel Units: 46 ------------------------------------------------------------------------------ D.lnc | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- lnrp | D1. | -.3397847 .0184742 -18.39 0.000 -.3759936 -.3035759 | lnrpn | D1. | .0700778 .0185437 3.78 0.000 .0337328 .1064228 | lnrdi | D1. | .2267432 .0202211 11.21 0.000 .1871106 .2663758 | lnc | LD. | .4038734 .02775 14.55 0.000 .3494843 .4582624 | constant | -.0051304 .0005255 -9.76 0.000 -.0061604 -.0041004 ------------------------------------------------------------------------------ Instruments: D.lnrp D.lnrpn D.lnrdi constant L.lnrp L2.lnrp L.lnrpn L2.lnrpn L.lnrdi L2.lnrdi

Table 8.6 Robust Arellano and Bond estimates of the democracy equation

*xtabond2 dem L.(dem educ) yr* if year >=1960 & year <=2000 & year>=(indyear+5), gmm(L.(dem)) iv(L.educ yr*) noleveleq > robust nomata * Data Not Available

Table 8.7 System GMM estimates of the democracy equation

*xtabond2 dem L.(dem educ) yr* if year >=1960 & year <=2000 & year>=(indyear+5), gmm(L.(dem)) iv(L.educ yr*) robust no > mata * Data Not Available

Chapter 09. Unbalanced PanelData Models

. import excel "hedonic.xls", sheet("harris1") firstrow clear (16 vars, 506 obs) . xtset townid Panel variable: townid (unbalanced)

Table 9.2

. xtreg mv crim zn indus chas nox rm age dis rad tax pt b lst, mle Fitting constant-only model: Iteration 0: Log likelihood = -70.952294 Iteration 1: Log likelihood = -67.800401 Iteration 2: Log likelihood = -65.887636 Iteration 3: Log likelihood = -65.787619 Iteration 4: Log likelihood = -65.787133 Fitting full model: Iteration 0: Log likelihood = 213.22614 Iteration 1: Log likelihood = 229.23044 Iteration 2: Log likelihood = 235.97101 Iteration 3: Log likelihood = 236.26816 Iteration 4: Log likelihood = 236.26921 Random-effects ML regression Number of obs = 506 Group variable: townid Number of groups = 92 Random effects u_i ~ Gaussian Obs per group: min = 1 avg = 5.5 max = 30 LR chi2(13) = 604.11 Log likelihood = 236.26921 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ mv | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- crim | -.0071948 .0010277 -7.00 0.000 -.009209 -.0051806 zn | .0000286 .0006894 0.04 0.967 -.0013226 .0013799 indus | .0022167 .0043906 0.50 0.614 -.0063887 .0108221 chas | -.0119739 .028971 -0.41 0.679 -.0687561 .0448083 nox | -.0058672 .0012282 -4.78 0.000 -.0082744 -.00346 rm | .0092024 .0011643 7.90 0.000 .0069204 .0114843 age | -.000943 .0004614 -2.04 0.041 -.0018473 -.0000387 dis | -.1298568 .0469261 -2.77 0.006 -.2218303 -.0378833 rad | .0971025 .0284233 3.42 0.001 .0413939 .152811 tax | -.0003741 .0001895 -1.97 0.048 -.0007456 -2.59e-06 ptratio | -.0297989 .0097987 -3.04 0.002 -.0490041 -.0105938 b | .5778527 .0999608 5.78 0.000 .381933 .7737723 lstat | -.2837923 .02405 -11.80 0.000 -.3309295 -.2366552 _cons | 9.675679 .2069417 46.76 0.000 9.270081 10.08128 -------------+---------------------------------------------------------------- /sigma_u | .1337509 .0132895 .1100833 .1625071 /sigma_e | .1304801 .0045557 .1218498 .1397217 rho | .5123767 .0546929 .4060176 .6178576 ------------------------------------------------------------------------------ LR test of sigma_u=0: chibar2(01) = 172.71 Prob >= chibar2 = 0.000 . eststo mle

Table 9.3 Hedonic housing equation: Swamy and Arora estimator

. xtreg mv crim zn indus chas nox rm age dis rad tax pt b lst, sa Random-effects GLS regression Number of obs = 506 Group variable: townid Number of groups = 92 R-squared: Obs per group: Within = 0.6682 min = 1 Between = 0.8088 avg = 5.5 Overall = 0.7875 max = 30 Wald chi2(13) = 1169.62 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ mv | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- crim | -.0072338 .0010346 -6.99 0.000 -.0092616 -.0052061 zn | .0000396 .0006878 0.06 0.954 -.0013084 .0013876 indus | .0020794 .0043403 0.48 0.632 -.0064273 .0105861 chas | -.0105913 .0289598 -0.37 0.715 -.0673515 .046169 nox | -.005863 .0012455 -4.71 0.000 -.0083041 -.0034219 rm | .0091773 .0011792 7.78 0.000 .0068662 .0114885 age | -.0009272 .0004647 -2.00 0.046 -.0018379 -.0000164 dis | -.1328824 .0456826 -2.91 0.004 -.2224185 -.0433462 rad | .0968634 .0283495 3.42 0.001 .0412994 .1524274 tax | -.0003747 .000189 -1.98 0.047 -.0007452 -4.25e-06 ptratio | -.029723 .0097538 -3.05 0.002 -.0488402 -.0106059 b | .5750649 .101031 5.69 0.000 .3770479 .773082 lstat | -.28514 .0238546 -11.95 0.000 -.3318942 -.2383859 _cons | 9.677802 .2071417 46.72 0.000 9.271811 10.08379 -------------+---------------------------------------------------------------- sigma_u | .12973801 sigma_e | .13024875 rho | .49803552 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . eststo sa

Table 9.1. Incompelete table

. qui eststo ols: reg mv crim zn indus chas nox rm age dis rad tax pt b lst, . qui eststo re: xtreg mv crim zn indus chas nox rm age dis rad tax pt b lst, re . qui eststo fe: xtreg mv crim zn indus chas nox rm age dis rad tax pt b lst, fe . esttab ols fe sa re mle, se stats(N, fmt(%9.0g)) -------------------------------------------------------------------------------------------- (1) (2) (3) (4) (5) mv mv mv mv mv -------------------------------------------------------------------------------------------- main crim -0.0119*** -0.00625*** -0.00723*** -0.00762*** -0.00719*** (0.00124) (0.00104) (0.00103) (0.00106) (0.00103) zn 0.0000803 0 0.0000396 0.000108 0.0000286 (0.000506) (.) (0.000688) (0.000618) (0.000689) indus 0.000241 0 0.00208 0.00111 0.00222 (0.00236) (.) (0.00434) (0.00377) (0.00439) chas 0.0914** -0.0452 -0.0106 0.00239 -0.0120 (0.0332) (0.0299) (0.0290) (0.0295) (0.0290) nox -0.00638*** -0.00559*** -0.00586*** -0.00582*** -0.00587*** (0.00113) (0.00135) (0.00125) (0.00124) (0.00123) rm 0.00633*** 0.00927*** 0.00918*** 0.00890*** 0.00920*** (0.00131) (0.00122) (0.00118) (0.00120) (0.00116) age 0.0000898 -0.00141** -0.000927* -0.000784 -0.000943* (0.000526) (0.000486) (0.000465) (0.000472) (0.000461) dis -0.191*** 0.0801 -0.133** -0.154*** -0.130** (0.0334) (0.0712) (0.0457) (0.0426) (0.0469) rad 0.0957*** 0 0.0969*** 0.0953*** 0.0971*** (0.0191) (.) (0.0283) (0.0251) (0.0284) tax -0.000420*** 0 -0.000375* -0.000380* -0.000374* (0.000123) (.) (0.000189) (0.000167) (0.000190) ptratio -0.0311*** 0 -0.0297** -0.0293*** -0.0298** (0.00501) (.) (0.00975) (0.00847) (0.00980) b 0.364*** 0.663*** 0.575*** 0.549*** 0.578*** (0.103) (0.103) (0.101) (0.103) (0.1000) lstat -0.371*** -0.245*** -0.285*** -0.298*** -0.284*** (0.0250) (0.0256) (0.0239) (0.0240) (0.0241) _cons 9.756*** 8.993*** 9.678*** 9.693*** 9.676*** (0.150) (0.135) (0.207) (0.189) (0.207) -------------------------------------------------------------------------------------------- sigma_u _cons 0.134*** (0.0133) -------------------------------------------------------------------------------------------- sigma_e _cons 0.130*** (0.00456) -------------------------------------------------------------------------------------------- N 506 506 506 506 506 -------------------------------------------------------------------------------------------- Standard errors in parentheses * p<0.05, ** p<0.01, *** p<0.001 . est clear

Table 9.5 Nested Public Capital Equation: MLE Estimator

. u productivity, clear (Public Capital Productivity) . xtset state year Panel variable: state (strongly balanced) Time variable: year, 1970 to 1986 Delta: 1 unit . xtmixed gsp private emp hwy water other unemp || region: || state:, mle Performing EM optimization: Performing gradient-based optimization: Iteration 0: Log likelihood = 1430.5017 Iteration 1: Log likelihood = 1430.5017 Computing standard errors: Mixed-effects ML regression Number of obs = 816 Grouping information ------------------------------------------------------------- | No. of Observations per group Group variable | groups Minimum Average Maximum ----------------+-------------------------------------------- region | 9 51 90.7 136 state | 48 17 17.0 17 ------------------------------------------------------------- Wald chi2(6) = 18829.06 Log likelihood = 1430.5017 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ gsp | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- private | .2671484 .0212591 12.57 0.000 .2254814 .3088154 emp | .754072 .0261868 28.80 0.000 .7027468 .8053973 hwy | .0709767 .023041 3.08 0.002 .0258172 .1161363 water | .0761187 .0139248 5.47 0.000 .0488266 .1034109 other | -.0999955 .0169366 -5.90 0.000 -.1331906 -.0668004 unemp | -.0058983 .0009031 -6.53 0.000 -.0076684 -.0041282 _cons | 2.128823 .1543854 13.79 0.000 1.826233 2.431413 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects parameters | Estimate Std. err. [95% conf. interval] -----------------------------+------------------------------------------------ region: Identity | sd(_cons) | .038087 .0170591 .0158316 .091628 -----------------------------+------------------------------------------------ state: Identity | sd(_cons) | .0792193 .0093861 .0628027 .0999273 -----------------------------+------------------------------------------------ sd(Residual) | .0366893 .000939 .0348944 .0385766 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(2) = 1154.73 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference.

Table 9.6 Nested Public Capital Equation: REML Estimator

. xtmixed gsp private emp hwy water other unemp || region: || state:, reml Performing EM optimization: Performing gradient-based optimization: Iteration 0: Log restricted-likelihood = 1404.7101 Iteration 1: Log restricted-likelihood = 1404.7101 Computing standard errors: Mixed-effects REML regression Number of obs = 816 Grouping information ------------------------------------------------------------- | No. of Observations per group Group variable | groups Minimum Average Maximum ----------------+-------------------------------------------- region | 9 51 90.7 136 state | 48 17 17.0 17 ------------------------------------------------------------- Wald chi2(6) = 18382.38 Log restricted-likelihood = 1404.7101 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ gsp | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- private | .2660308 .0215471 12.35 0.000 .2237993 .3082623 emp | .7555059 .0264556 28.56 0.000 .7036539 .807358 hwy | .0718857 .0233478 3.08 0.002 .0261249 .1176465 water | .0761552 .0139952 5.44 0.000 .0487251 .1035853 other | -.1005396 .0170173 -5.91 0.000 -.1338929 -.0671863 unemp | -.0058815 .0009093 -6.47 0.000 -.0076636 -.0040994 _cons | 2.126995 .1574865 13.51 0.000 1.818327 2.435663 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects parameters | Estimate Std. err. [95% conf. interval] -----------------------------+------------------------------------------------ region: Identity | sd(_cons) | .0435474 .0186293 .0188289 .1007164 -----------------------------+------------------------------------------------ state: Identity | sd(_cons) | .0802738 .0095512 .0635762 .1013567 -----------------------------+------------------------------------------------ sd(Residual) | .0368008 .0009442 .034996 .0386986 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(2) = 1162.40 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference.

Chapter 10. SpecialTopics

. infile /// > OBSNO YEAR CUSIP ARDSSIC SCISECT LOGK SUMPAT PAT PAT1 /// > PAT2 PAT3 PAT4 LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 /// > using patentdata.asc, clear (1,730 observations read) . forvalues yr = 1(1)5 { 2. gen dyear`yr' = (YEAR == `yr' ) 3. } . xtset OBSNO YEAR Panel variable: OBSNO (strongly balanced) Time variable: YEAR, 1 to 5 Delta: 1 unit

Table 10.1 Poisson fixed effects for the R & D data

. xtpois PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5,fe note: 22 groups (110 obs) dropped because of all zero outcomes Iteration 0: Log likelihood = -3660.2656 Iteration 1: Log likelihood = -3536.3518 Iteration 2: Log likelihood = -3536.3086 Iteration 3: Log likelihood = -3536.3086 Conditional fixed-effects Poisson regression Number of obs = 1,620 Group variable: OBSNO Number of groups = 324 Obs per group: min = 5 avg = 5.0 max = 5 Wald chi2(10) = 245.39 Log likelihood = -3536.3086 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ PAT | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- LOGR | .3222105 .0459412 7.01 0.000 .2321674 .4122535 LOGR1 | -.0871295 .0486887 -1.79 0.074 -.1825576 .0082986 LOGR2 | .0785816 .044784 1.75 0.079 -.0091934 .1663567 LOGR3 | .00106 .0414151 0.03 0.980 -.0801122 .0822322 LOGR4 | -.0046414 .0378489 -0.12 0.902 -.0788238 .0695411 LOGR5 | .0026068 .0322596 0.08 0.936 -.0606209 .0658346 dyear2 | -.0426076 .013132 -3.24 0.001 -.0683458 -.0168695 dyear3 | -.0400462 .0134677 -2.97 0.003 -.0664423 -.01365 dyear4 | -.1571185 .0142281 -11.04 0.000 -.1850051 -.1292319 dyear5 | -.1980306 .0152946 -12.95 0.000 -.2280074 -.1680538 ------------------------------------------------------------------------------

Table 10.2 Negative binomial fixed effects for the R & D data

. xtnbreg PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5,fe note: 22 groups (110 obs) dropped because of all zero outcomes Iteration 0: Log likelihood = -3281.3343 Iteration 1: Log likelihood = -3210.112 Iteration 2: Log likelihood = -3206.8772 Iteration 3: Log likelihood = -3206.867 Iteration 4: Log likelihood = -3206.867 Conditional FE negative binomial regression Number of obs = 1,620 Group variable: OBSNO Number of groups = 324 Obs per group: min = 5 avg = 5.0 max = 5 Wald chi2(10) = 117.12 Log likelihood = -3206.867 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ PAT | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- LOGR | .3188563 .0673654 4.73 0.000 .1868225 .4508902 LOGR1 | -.080442 .0773311 -1.04 0.298 -.2320082 .0711241 LOGR2 | .0559045 .0710929 0.79 0.432 -.0834351 .1952441 LOGR3 | -.0128025 .0659707 -0.19 0.846 -.1421028 .1164978 LOGR4 | .0355272 .0620031 0.57 0.567 -.0859966 .1570511 LOGR5 | .0094533 .0516237 0.18 0.855 -.0917273 .1106338 dyear2 | -.0422643 .0249051 -1.70 0.090 -.0910773 .0065488 dyear3 | -.0488698 .0253965 -1.92 0.054 -.098646 .0009063 dyear4 | -.1606011 .0262724 -6.11 0.000 -.2120941 -.1091081 dyear5 | -.2154138 .0265014 -8.13 0.000 -.2673556 -.163472 _cons | 2.423638 .1749545 13.85 0.000 2.080734 2.766543 ------------------------------------------------------------------------------

Table 10.3 Poisson random effects for the R & D data

. xtpois PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT, re Fitting Poisson model: Iteration 0: Log likelihood = -17836.658 Iteration 1: Log likelihood = -17834.138 Iteration 2: Log likelihood = -17834.138 Fitting full model: Iteration 0: Log likelihood = -5303.2636 Iteration 1: Log likelihood = -5241.765 Iteration 2: Log likelihood = -5234.9526 Iteration 3: Log likelihood = -5234.9265 Iteration 4: Log likelihood = -5234.9265 Random-effects Poisson regression Number of obs = 1,730 Group variable: OBSNO Number of groups = 346 Random effects u_i ~ Gamma Obs per group: min = 5 avg = 5.0 max = 5 Wald chi2(12) = 1272.14 Log likelihood = -5234.9265 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ PAT | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- LOGR | .4034537 .0435022 9.27 0.000 .318191 .4887165 LOGR1 | -.0461765 .0482224 -0.96 0.338 -.1406906 .0483376 LOGR2 | .1079235 .0447115 2.41 0.016 .0202905 .1955565 LOGR3 | .0297733 .0413235 0.72 0.471 -.0512193 .110766 LOGR4 | .0106957 .0377074 0.28 0.777 -.0632094 .0846008 LOGR5 | .0406111 .0315738 1.29 0.198 -.0212724 .1024946 dyear2 | -.0449624 .0131291 -3.42 0.001 -.070695 -.0192298 dyear3 | -.0483864 .0134018 -3.61 0.000 -.0746534 -.0221193 dyear4 | -.1741619 .0139702 -12.47 0.000 -.201543 -.1467809 dyear5 | -.2258977 .0146645 -15.40 0.000 -.2546396 -.1971557 LOGK | .2916932 .0393368 7.42 0.000 .2145945 .368792 SCISECT | .2570001 .1122716 2.29 0.022 .0369517 .4770484 _cons | .4107881 .1467443 2.80 0.005 .1231746 .6984016 -------------+---------------------------------------------------------------- /lnalpha | -.156739 .0809735 -.3154441 .0019661 -------------+---------------------------------------------------------------- alpha | .8549271 .0692264 .7294648 1.001968 ------------------------------------------------------------------------------ LR test of alpha=0: chibar2(01) = 2.5e+04 Prob >= chibar2 = 0.000

Table 10.4 Negative binomial random effects for the R & D data

. xtnbreg PAT LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT, re Fitting negative binomial (constant dispersion) model: Iteration 0: Log likelihood = -17836.658 Iteration 1: Log likelihood = -17834.138 Iteration 2: Log likelihood = -17834.138 Iteration 0: Log likelihood = -37163.276 Iteration 1: Log likelihood = -17331.718 Iteration 2: Log likelihood = -8376.139 (backed up) Iteration 3: Log likelihood = -6999.1967 Iteration 4: Log likelihood = -6948.0162 Iteration 5: Log likelihood = -6948.0022 Iteration 6: Log likelihood = -6948.0022 Iteration 0: Log likelihood = -6948.0022 Iteration 1: Log likelihood = -6484.3647 (not concave) Iteration 2: Log likelihood = -6063.4801 Iteration 3: Log likelihood = -5996.6042 Iteration 4: Log likelihood = -5954.4866 Iteration 5: Log likelihood = -5954.1073 Iteration 6: Log likelihood = -5954.1071 Fitting full model: Iteration 0: Log likelihood = -5074.487 Iteration 1: Log likelihood = -4961.2657 Iteration 2: Log likelihood = -4948.6428 Iteration 3: Log likelihood = -4948.4945 Iteration 4: Log likelihood = -4948.4944 Random-effects negative binomial regression Number of obs = 1,730 Group variable: OBSNO Number of groups = 346 Random effects u_i ~ Beta Obs per group: min = 5 avg = 5.0 max = 5 Wald chi2(12) = 944.21 Log likelihood = -4948.4944 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ PAT | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- LOGR | .3503119 .0652818 5.37 0.000 .2223619 .4782619 LOGR1 | -.0030317 .0750916 -0.04 0.968 -.1502085 .1441452 LOGR2 | .1049876 .0688488 1.52 0.127 -.0299537 .2399289 LOGR3 | .0163523 .0636376 0.26 0.797 -.1083752 .1410797 LOGR4 | .0359425 .0587161 0.61 0.540 -.0791389 .1510239 LOGR5 | .0718323 .0482887 1.49 0.137 -.0228119 .1664764 dyear2 | -.0436736 .0213435 -2.05 0.041 -.085506 -.0018411 dyear3 | -.0556597 .0218572 -2.55 0.011 -.098499 -.0128203 dyear4 | -.1831055 .0227183 -8.06 0.000 -.2276326 -.1385784 dyear5 | -.2300438 .0231525 -9.94 0.000 -.2754219 -.1846658 LOGK | .161937 .0417874 3.88 0.000 .0800351 .2438388 SCISECT | .1176419 .1066164 1.10 0.270 -.0913224 .3266063 _cons | .8995618 .1681113 5.35 0.000 .5700698 1.229054 -------------+---------------------------------------------------------------- /ln_r | .9877591 .0961426 .7993231 1.176195 /ln_s | .7009608 .1079684 .4893467 .9125748 -------------+---------------------------------------------------------------- r | 2.68521 .2581631 2.224035 3.242015 s | 2.015688 .2176306 1.63125 2.490728 ------------------------------------------------------------------------------ LR test vs. pooled: chibar2(01) = 2011.23 Prob >= chibar2 = 0.000

Chapter 11. Limited Dependent Variables and PanelData

* Fernandez-Val (2009) downloaded from Open ICPSR . infile /// > id year lfp lfp_1 kids0_2 kids3_5 kids6_17 loghusbandincome /// > age age2 dy1-dy8 using "Fernandez-Val-2009\lfp_psid_fs.txt", clear (13,149 observations read) . xtset id year Panel variable: id (strongly balanced) Time variable: year, 1980 to 1988 Delta: 1 unit

Table 11.1 Conditional Logit: Female Labor Force Participation

. xtlogit lfp kids0_2 kids3_5 kids6_17 loghusbandincome age age2, fe note: multiple positive outcomes within groups encountered. note: 797 groups (7,173 obs) omitted because of all positive or all negative outcomes. Iteration 0: Log likelihood = -2306.0175 Iteration 1: Log likelihood = -2267.9125 Iteration 2: Log likelihood = -2267.8037 Iteration 3: Log likelihood = -2267.8037 Conditional fixed-effects logistic regression Number of obs = 5,976 Group variable: id Number of groups = 664 Obs per group: min = 9 avg = 9.0 max = 9 LR chi2(6) = 272.67 Log likelihood = -2267.8037 Prob > chi2 = 0.0000 ---------------------------------------------------------------------------------- lfp | Coefficient Std. err. z P>|z| [95% conf. interval] -----------------+---------------------------------------------------------------- kids0_2 | -1.086185 .0912304 -11.91 0.000 -1.264993 -.9073763 kids3_5 | -.6265956 .0835397 -7.50 0.000 -.7903304 -.4628607 kids6_17 | -.206979 .0672433 -3.08 0.002 -.3387734 -.0751847 loghusbandincome | -.3662394 .0880333 -4.16 0.000 -.5387814 -.1936974 age | 3.641422 .6080303 5.99 0.000 2.449705 4.83314 age2 | -.4520102 .0807705 -5.60 0.000 -.6103174 -.2937029 ----------------------------------------------------------------------------------

Table 11.2 Probit Random Effects: Female Labor Force Participatio

. xtprobit lfp kids0_2 kids3_5 kids6_17 loghusbandincome age age2, re Fitting comparison model: Iteration 0: Log likelihood = -7750.2801 Iteration 1: Log likelihood = -7473.199 Iteration 2: Log likelihood = -7472.7313 Iteration 3: Log likelihood = -7472.7313 Fitting full model: rho = 0.0 Log likelihood = -7472.7313 rho = 0.1 Log likelihood = -6451.8464 rho = 0.2 Log likelihood = -5922.2083 rho = 0.3 Log likelihood = -5592.5289 rho = 0.4 Log likelihood = -5369.9071 rho = 0.5 Log likelihood = -5215.1801 rho = 0.6 Log likelihood = -5112.0359 rho = 0.7 Log likelihood = -5062.9248 rho = 0.8 Log likelihood = -5106.2435 Iteration 0: Log likelihood = -5049.2731 Iteration 1: Log likelihood = -4938.4733 Iteration 2: Log likelihood = -4928.4508 Iteration 3: Log likelihood = -4928.4235 Iteration 4: Log likelihood = -4928.4235 (backed up) Iteration 5: Log likelihood = -4928.3851 Iteration 6: Log likelihood = -4928.3851 Random-effects probit regression Number of obs = 13,149 Group variable: id Number of groups = 1,461 Random effects u_i ~ Gaussian Obs per group: min = 9 avg = 9.0 max = 9 Integration method: mvaghermite Integration pts. = 12 Wald chi2(6) = 330.65 Log likelihood = -4928.3851 Prob > chi2 = 0.0000 ---------------------------------------------------------------------------------- lfp | Coefficient Std. err. z P>|z| [95% conf. interval] -----------------+---------------------------------------------------------------- kids0_2 | -.6865494 .0489026 -14.04 0.000 -.7823968 -.5907021 kids3_5 | -.4050329 .0441319 -9.18 0.000 -.4915299 -.318536 kids6_17 | -.1290886 .0320563 -4.03 0.000 -.1919179 -.0662594 loghusbandincome | -.2538797 .0440499 -5.76 0.000 -.340216 -.1675435 age | 2.119458 .2901562 7.30 0.000 1.550763 2.688154 age2 | -.2832263 .037195 -7.61 0.000 -.3561272 -.2103254 _cons | .6753673 .6574111 1.03 0.304 -.6131348 1.963869 -----------------+---------------------------------------------------------------- /lnsig2u | 1.296086 .0686458 1.161543 1.43063 -----------------+---------------------------------------------------------------- sigma_u | 1.911796 .0656184 1.787417 2.04483 rho | .7851756 .0115788 .761613 .8069994 ---------------------------------------------------------------------------------- LR test of rho=0: chibar2(01) = 5088.69 Prob >= chibar2 = 0.000

Table 11.3 Union Membership: Random-effects probit

. infile /// > nr year black married educ union d81 d82 d83 d84 d85 d86 d87 /// > union80 union_1 marravg educu80 marr81 marr82 marr83 marr84 /// > marr85 marr86 marr87 using jmw-data/union.raw, clear (4,360 observations read) . u jmw-data/union.dta, clear . xtset nr year Panel variable: nr (strongly balanced) Time variable: year, 1980 to 1987 Delta: 1 unit . xtprobit union married union_1 union80 marr81 marr82 marr83 marr84 marr85 marr86 marr87 d81 d82 d83 d84 d85 d86, re Fitting comparison model: Iteration 0: Log likelihood = -2115.4174 Iteration 1: Log likelihood = -1370.5301 Iteration 2: Log likelihood = -1366.0556 Iteration 3: Log likelihood = -1366.0497 Iteration 4: Log likelihood = -1366.0497 Fitting full model: rho = 0.0 Log likelihood = -1366.0497 rho = 0.1 Log likelihood = -1346.9419 rho = 0.2 Log likelihood = -1342.4578 rho = 0.3 Log likelihood = -1345.9175 Iteration 0: Log likelihood = -1342.4578 Iteration 1: Log likelihood = -1315.5077 Iteration 2: Log likelihood = -1306.5529 Iteration 3: Log likelihood = -1288.3926 Iteration 4: Log likelihood = -1288.0839 Iteration 5: Log likelihood = -1288.0834 Iteration 6: Log likelihood = -1288.0834 Random-effects probit regression Number of obs = 3,815 Group variable: nr Number of groups = 545 Random effects u_i ~ Gaussian Obs per group: min = 7 avg = 7.0 max = 7 Integration method: mvaghermite Integration pts. = 12 Wald chi2(16) = 348.98 Log likelihood = -1288.0834 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ union | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- married | .1672066 .1106776 1.51 0.131 -.0497176 .3841307 union_1 | .8929075 .0924593 9.66 0.000 .7116907 1.074124 union80 | 1.490334 .1661415 8.97 0.000 1.164702 1.815965 marr81 | .0631461 .2160679 0.29 0.770 -.3603392 .4866315 marr82 | -.1229025 .2552495 -0.48 0.630 -.6231824 .3773774 marr83 | -.0719672 .2582289 -0.28 0.780 -.5780866 .4341522 marr84 | -.0001787 .2781883 -0.00 0.999 -.5454177 .5450603 marr85 | .3825586 .2623512 1.46 0.145 -.1316403 .8967576 marr86 | .1210022 .263442 0.46 0.646 -.3953346 .637339 marr87 | -.4209373 .2064262 -2.04 0.041 -.8255251 -.0163494 d81 | -.0739664 .118948 -0.62 0.534 -.3071002 .1591675 d82 | -.0464172 .1172915 -0.40 0.692 -.2763044 .1834699 d83 | -.1629567 .1178112 -1.38 0.167 -.3938625 .0679491 d84 | -.1235878 .1170587 -1.06 0.291 -.3530187 .1058431 d85 | -.3403144 .1196731 -2.84 0.004 -.5748693 -.1057595 d86 | -.3897729 .1198515 -3.25 0.001 -.6246776 -.1548683 _cons | -1.727352 .144532 -11.95 0.000 -2.010629 -1.444074 -------------+---------------------------------------------------------------- /lnsig2u | .1778768 .1659054 -.1472918 .5030454 -------------+---------------------------------------------------------------- sigma_u | 1.093013 .0906684 .9290006 1.285982 rho | .5443523 .04115 .4632435 .6231747 ------------------------------------------------------------------------------ LR test of rho=0: chibar2(01) = 155.93 Prob >= chibar2 = 0.000 ********************************************************* *********** Chapter 12. Nonstationary Panels ************ ********************************************************* * Data Not Available ********************************************************* ******** Chapter 13. Spatial Panel Data Models ********** ********************************************************* * Data Not Available . log close name: <baltagipd> log: ~\baltagi_panel_data_econometrics.smcl log type: smcl closed on: 3 Jun 2025, 01:42:57 ------------------------------------------------------------------------------------------------------------------------