-------------------------------------------------------------------------------------------------------- log: C:\UpCD1\WORK\Stata\panel_1.log log type: text opened on: 9 Sep 2003, 23:30:20 . . set mem 200m (204800k) . set more off . set matsize 800 . . ***************************************** . * xt * . ***************************************** . . use abdata.dta, clear . * use http://www.stata-press.com/data/r8/abdata, clear . . * use http://www.stata-press.com/data/r8/nlswork, clear . * use http://www.stata-press.com/data/r8/union, clear . . * tsset id year . ** Some commands such as "xtabond" require tsset. . . * iis id, clear . * tis year, clear . ** iis and tis are alternatives to i() and t() option. . ** These override previous setting specified by iis or tis. . . ** describe pattern of the panel-data . list in 1/6, separator(0) divider +---------------------------------------------------------------------------------------------+ 1. | c1 | ind | year | emp | wage | cap | indoutpt | n | w | k | | 1-1 | 7 | 1977 | 5.041 | 13.1516 | .5894 | 95.7072 | 1.617604 | 2.576543 | -.5286502 | |--------------------------------------------------------------------------------+------------| | ys | rec | yearm1 | id | nL1 | nL2 | wL1 | kL1 | kL2 | | 4.561294 | 1 | 1977 | 1 | . | . | . | . | . | |----------+----------------------------------------------------------------------------------| | ysL1 | ysL2 | yr1976 | yr1977 | yr1978 | yr1979 | yr1980 | yr1981 | yr1982 | yr1983 | | . | . | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | |---------------------------------------------------------------------------------------------| | yr1984 | | 0 | +---------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------+ 2. | c1 | ind | year | emp | wage | cap | indoutpt | n | w | k | | 2-1 | 7 | 1978 | 5.6 | 12.3018 | .6318 | 97.3569 | 1.722767 | 2.509746 | -.4591824 | |--------------------------------------------------------------------------------+------------| | ys | rec | yearm1 | id | nL1 | nL2 | wL1 | kL1 | kL2 | | 4.578383 | 2 | 1977 | 1 | 1.617604 | . | 2.576543 | -.5286502 | . | |----------+----------------------------------------------------------------------------------| | ysL1 | ysL2 | yr1976 | yr1977 | yr1978 | yr1979 | yr1980 | yr1981 | yr1982 | yr1983 | | 4.561294 | . | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | |---------------------------------------------------------------------------------------------| | yr1984 | | 0 | +---------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------+ 3. | c1 | ind | year | emp | wage | cap | indoutpt | n | w | k | | 3-1 | 7 | 1979 | 5.015 | 12.8395 | .6771 | 99.6083 | 1.612433 | 2.552526 | -.3899363 | |--------------------------------------------------------------------------------+------------| | ys | rec | yearm1 | id | nL1 | nL2 | wL1 | kL1 | kL2 | | 4.601245 | 3 | 1978 | 1 | 1.722767 | 1.617604 | 2.509746 | -.4591824 | -.5286502 | |----------+----------------------------------------------------------------------------------| | ysL1 | ysL2 | yr1976 | yr1977 | yr1978 | yr1979 | yr1980 | yr1981 | yr1982 | yr1983 | | 4.578383 | 4.561294 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | |---------------------------------------------------------------------------------------------| | yr1984 | | 0 | +---------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------+ 4. | c1 | ind | year | emp | wage | cap | indoutpt | n | w | k | | 4-1 | 7 | 1980 | 4.715 | 13.8039 | .6171 | 100.5501 | 1.550749 | 2.624951 | -.4827242 | |--------------------------------------------------------------------------------+------------| | ys | rec | yearm1 | id | nL1 | nL2 | wL1 | kL1 | kL2 | | 4.610656 | 4 | 1979 | 1 | 1.612433 | 1.722767 | 2.552526 | -.3899363 | -.4591824 | |----------+----------------------------------------------------------------------------------| | ysL1 | ysL2 | yr1976 | yr1977 | yr1978 | yr1979 | yr1980 | yr1981 | yr1982 | yr1983 | | 4.601245 | 4.578383 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | |---------------------------------------------------------------------------------------------| | yr1984 | | 0 | +---------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------+ 5. | c1 | ind | year | emp | wage | cap | indoutpt | n | w | k | | 5-1 | 7 | 1981 | 4.093 | 14.2897 | .5076 | 99.5581 | 1.409278 | 2.659539 | -.6780615 | |--------------------------------------------------------------------------------+------------| | ys | rec | yearm1 | id | nL1 | nL2 | wL1 | kL1 | kL2 | | 4.600741 | 5 | 1980 | 1 | 1.550749 | 1.612433 | 2.624951 | -.4827242 | -.3899363 | |----------+----------------------------------------------------------------------------------| | ysL1 | ysL2 | yr1976 | yr1977 | yr1978 | yr1979 | yr1980 | yr1981 | yr1982 | yr1983 | | 4.610656 | 4.601245 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | |---------------------------------------------------------------------------------------------| | yr1984 | | 0 | +---------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------+ 6. | c1 | ind | year | emp | wage | cap | indoutpt | n | w | k | | 6-1 | 7 | 1982 | 3.166 | 14.8681 | .4229 | 98.6151 | 1.152469 | 2.699218 | -.8606195 | |--------------------------------------------------------------------------------+------------| | ys | rec | yearm1 | id | nL1 | nL2 | wL1 | kL1 | kL2 | | 4.591224 | 6 | 1981 | 1 | 1.409278 | 1.550749 | 2.659539 | -.6780615 | -.4827242 | |----------+----------------------------------------------------------------------------------| | ysL1 | ysL2 | yr1976 | yr1977 | yr1978 | yr1979 | yr1980 | yr1981 | yr1982 | yr1983 | | 4.600741 | 4.610656 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | |---------------------------------------------------------------------------------------------| | yr1984 | | 0 | +---------------------------------------------------------------------------------------------+ . . xtdes, patterns(15) i(id) t(year) id: 1, 2, ..., 140 n = 140 year: 1976, 1977, ..., 1984 T = 9 Delta(year) = 1; (1984-1976)+1 = 9 (id*year uniquely identifies each observation) Distribution of T_i: min 5% 25% 50% 75% 95% max 7 7 7 7 8 9 9 Freq. Percent Cum. | Pattern ---------------------------+----------- 62 44.29 44.29 | 1111111.. 39 27.86 72.14 | .1111111. 19 13.57 85.71 | .11111111 14 10.00 95.71 | 111111111 4 2.86 98.57 | 11111111. 2 1.43 100.00 | ..1111111 ---------------------------+----------- 140 100.00 | XXXXXXXXX . . ***************************************** . * xtdata * . ***************************************** . . use nlswork.dta, clear (National Longitudinal Survey. Young Women 14-26 years of age in 1968) . * use http://www.stata-press.com/data/r8/nlswork, clear . . generate age2 = age^2 (24 missing values generated) . generate ttl_exp2 = ttl_exp^2 . generate byte black = race==2 . . xtdata ln_w grade age* ttl_exp* tenure* black not_smsa south, be clear i(id) . ** xtdata converts the data into a form suitable for between estimation. . regress ln_w grade age* ttl_exp* tenure* black not_smsa south Source | SS df MS Number of obs = 4697 -------------+------------------------------ F( 9, 4687) = 489.74 Model | 410.482313 9 45.6091459 Prob > F = 0.0000 Residual | 436.494295 4687 .093128717 R-squared = 0.4846 -------------+------------------------------ Adj R-squared = 0.4837 Total | 846.976608 4696 .180361288 Root MSE = .30517 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- grade | .0605624 .0020106 30.12 0.000 .0566206 .0645042 age | .0336621 .0087678 3.84 0.000 .0164731 .050851 age2 | -.0006308 .0001436 -4.39 0.000 -.0009123 -.0003492 ttl_exp | .0348104 .0048532 7.17 0.000 .0252959 .0443249 ttl_exp2 | -.000436 .0002824 -1.54 0.123 -.0009897 .0001176 tenure | .0302555 .0022604 13.38 0.000 .0258241 .034687 black | -.0563488 .010567 -5.33 0.000 -.0770651 -.0356324 not_smsa | -.1869933 .0113065 -16.54 0.000 -.2091593 -.1648273 south | -.0968865 .010182 -9.52 0.000 -.1168479 -.076925 _cons | .3182529 .1216441 2.62 0.009 .0797732 .5567325 ------------------------------------------------------------------------------ . ** Thus, this gives the be estimator. . . * xtdata ln_w grade age* ttl_exp* tenure* black not_smsa south, fe clear i(id) . * regress ln_w grade age* ttl_exp* tenure* black not_smsa south . . ***************************************** . * xtdes * . ***************************************** . . use nlswork.dta, clear (National Longitudinal Survey. Young Women 14-26 years of age in 1968) . * use http://www.stata-press.com/data/r8/nlswork, clear . . xtdes, patterns(15) i(id) t(year) idcode: 1, 2, ..., 5159 n = 4711 year: 68, 69, ..., 88 T = 15 Delta(year) = 1; (88-68)+1 = 21 (idcode*year uniquely identifies each observation) Distribution of T_i: min 5% 25% 50% 75% 95% max 1 1 3 5 9 13 15 Freq. Percent Cum. | Pattern ---------------------------+----------------------- 136 2.89 2.89 | 1.................... 114 2.42 5.31 | ....................1 89 1.89 7.20 | .................1.11 87 1.85 9.04 | ...................11 86 1.83 10.87 | 111111.1.11.1.11.1.11 61 1.29 12.16 | ..............11.1.11 56 1.19 13.35 | 11................... 54 1.15 14.50 | ...............1.1.11 54 1.15 15.64 | .......1.11.1.11.1.11 49 1.04 16.68 | .........11.1.11.1.11 45 0.96 17.64 | ............1.11.1.11 43 0.91 18.55 | 1111................. 42 0.89 19.44 | ...1................. 40 0.85 20.29 | .....1.1.11.1.11.1.11 38 0.81 21.10 | ....11.1.11.1.11.1.11 3717 78.90 100.00 | (other patterns) ---------------------------+----------------------- 4711 100.00 | XXXXXX.X.XX.X.XX.X.XX . . ***************************************** . * xtsum * . ***************************************** . . xtsum wks_work Variable | Mean Std. Dev. Min Max | Observations -----------------+--------------------------------------------+---------------- wks_work overall | 53.98933 29.03232 0 104 | N = 27831 between | 20.64508 0 104 | n = 4686 within | 23.96999 -18.43924 131.156 | T-bar = 5.93918 . . xtsum birth_yr Variable | Mean Std. Dev. Min Max | Observations -----------------+--------------------------------------------+---------------- birth_yr overall | 48.08509 3.012837 41 54 | N = 28534 between | 3.051795 41 54 | n = 4711 within | 0 48.08509 48.08509 | T-bar = 6.05689 . ** As this is time invariant, its within std dev is zero. . . ***************************************** . * xttab * . ***************************************** . . xttab wks_work Overall Between Within wks_work | Freq. Percent Freq. Percent Percent ----------+----------------------------------------------------- 0 | 478 1.72 456 9.73 15.11 1 | 157 0.56 154 3.29 14.66 2 | 184 0.66 175 3.73 15.45 3 | 180 0.65 173 3.69 15.76 4 | 220 0.79 209 4.46 16.15 5 | 144 0.52 139 2.97 15.00 6 | 166 0.60 162 3.46 14.81 7 | 122 0.44 120 2.56 14.10 8 | 226 0.81 215 4.59 14.41 9 | 178 0.64 171 3.65 15.10 10 | 164 0.59 155 3.31 14.66 11 | 140 0.50 134 2.86 14.58 12 | 220 0.79 209 4.46 16.05 13 | 190 0.68 187 3.99 14.56 14 | 145 0.52 138 2.94 15.28 15 | 167 0.60 164 3.50 14.79 16 | 198 0.71 189 4.03 14.59 17 | 200 0.72 197 4.20 14.28 18 | 166 0.60 163 3.48 13.29 19 | 156 0.56 154 3.29 13.65 20 | 255 0.92 244 5.21 14.41 21 | 161 0.58 156 3.33 14.61 22 | 228 0.82 226 4.82 14.43 23 | 132 0.47 129 2.75 12.78 24 | 183 0.66 180 3.84 13.95 25 | 160 0.57 158 3.37 12.96 26 | 415 1.49 392 8.37 14.53 27 | 129 0.46 125 2.67 13.07 28 | 179 0.64 174 3.71 12.87 29 | 125 0.45 124 2.65 12.54 30 | 250 0.90 246 5.25 13.16 31 | 135 0.49 131 2.80 14.39 32 | 161 0.58 161 3.44 12.85 33 | 132 0.47 129 2.75 13.39 34 | 166 0.60 160 3.41 13.54 35 | 211 0.76 203 4.33 13.25 36 | 248 0.89 240 5.12 13.48 37 | 162 0.58 156 3.33 12.45 38 | 165 0.59 162 3.46 12.28 39 | 260 0.93 254 5.42 12.79 40 | 297 1.07 278 5.93 13.87 41 | 187 0.67 183 3.91 12.90 42 | 228 0.82 221 4.72 11.93 43 | 207 0.74 195 4.16 13.42 44 | 276 0.99 263 5.61 12.76 45 | 252 0.91 240 5.12 12.16 46 | 344 1.24 326 6.96 12.57 47 | 322 1.16 302 6.44 12.63 48 | 541 1.94 491 10.48 13.02 49 | 540 1.94 513 10.95 11.96 50 | 778 2.80 684 14.60 12.87 51 | 927 3.33 791 16.88 13.27 52 | 3821 13.73 2151 45.90 22.23 53 | 923 3.32 810 17.29 12.63 54 | 655 2.35 595 12.70 12.40 55 | 505 1.81 460 9.82 11.96 56 | 421 1.51 402 8.58 11.95 57 | 215 0.77 209 4.46 11.63 58 | 153 0.55 152 3.24 11.89 59 | 98 0.35 98 2.09 12.14 60 | 86 0.31 84 1.79 13.96 61 | 73 0.26 71 1.52 13.42 62 | 78 0.28 77 1.64 12.11 63 | 33 0.12 33 0.70 13.41 64 | 60 0.22 60 1.28 13.07 65 | 77 0.28 74 1.58 13.10 66 | 130 0.47 127 2.71 13.46 67 | 76 0.27 76 1.62 12.18 68 | 148 0.53 148 3.16 12.89 69 | 173 0.62 173 3.69 11.68 70 | 275 0.99 269 5.74 12.99 71 | 265 0.95 264 5.63 12.58 72 | 295 1.06 288 6.15 13.04 73 | 181 0.65 181 3.86 12.69 74 | 161 0.58 157 3.35 12.77 75 | 119 0.43 119 2.54 13.57 76 | 148 0.53 144 3.07 13.42 77 | 65 0.23 65 1.39 11.75 78 | 267 0.96 262 5.59 12.56 79 | 21 0.08 21 0.45 13.73 80 | 86 0.31 82 1.75 15.55 81 | 21 0.08 21 0.45 12.96 82 | 59 0.21 59 1.26 14.50 83 | 9 0.03 9 0.19 10.84 84 | 61 0.22 58 1.24 14.06 85 | 35 0.13 35 0.75 12.77 86 | 76 0.27 74 1.58 12.65 87 | 23 0.08 22 0.47 17.29 88 | 60 0.22 59 1.26 12.27 89 | 35 0.13 35 0.75 12.50 90 | 56 0.20 56 1.20 12.02 91 | 41 0.15 40 0.85 12.62 92 | 73 0.26 71 1.52 13.47 93 | 33 0.12 33 0.70 12.31 94 | 94 0.34 92 1.96 12.37 95 | 57 0.20 55 1.17 11.45 96 | 156 0.56 145 3.09 12.87 97 | 86 0.31 84 1.79 11.61 98 | 1975 7.10 1389 29.64 15.52 99 | 21 0.08 21 0.45 12.57 100 | 104 0.37 103 2.20 13.10 101 | 34 0.12 34 0.73 10.79 102 | 99 0.36 97 2.07 13.45 103 | 52 0.19 52 1.11 11.43 104 | 2406 8.65 1653 35.28 17.40 ----------+----------------------------------------------------- Total | 27831 100.00 23850 508.96 14.50 (n = 4686) . . xttab birth_yr Overall Between Within birth_yr | Freq. Percent Freq. Percent Percent ----------+----------------------------------------------------- 41 | 26 0.09 3 0.06 100.00 42 | 574 2.01 93 1.97 100.00 43 | 1522 5.33 248 5.26 100.00 44 | 2095 7.34 320 6.79 100.00 45 | 2311 8.10 368 7.81 100.00 46 | 2707 9.49 418 8.87 100.00 47 | 3040 10.65 486 10.32 100.00 48 | 3017 10.57 458 9.72 100.00 49 | 3095 10.85 490 10.40 100.00 50 | 2718 9.53 481 10.21 100.00 51 | 2765 9.69 484 10.27 100.00 52 | 2722 9.54 494 10.49 100.00 53 | 1935 6.78 367 7.79 100.00 54 | 7 0.02 1 0.02 100.00 ----------+----------------------------------------------------- Total | 28534 100.00 4711 100.00 100.00 (n = 4711) . ** As this is time invariant, its within percentage is 100. . . . ***************************************** . * xtgls * . ***************************************** . . ** xtgls fits "Cross-sectional time series" linear models using feasible GLS (not panel estimation). . . use abdata.dta, clear . * use http://www.stata-press.com/data/r8/abdata, clear . . ** estimate the model using GLS . * Dep var = n (log of employment in firm i and time t) . * Regressors = w (log of wage) k (log of capital stock) ys (log of industry output) . . xtgls n w k ys, i(id) t(year) nmk Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: homoskedastic Correlation: no autocorrelation Estimated covariances = 1 Number of obs = 1031 Estimated autocorrelations = 0 Number of groups = 140 Estimated coefficients = 4 Obs per group: min = 7 avg = 7.364286 max = 9 Wald chi2(3) = 5220.35 Log likelihood = -834.5829 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.3669498 .0646708 -5.67 0.000 -.4937023 -.2401974 k | .8090177 .0112526 71.90 0.000 .7869631 .8310724 ys | .4791144 .1810233 2.65 0.008 .1243153 .8339135 _cons | .3444255 .860552 0.40 0.689 -1.342226 2.031077 ------------------------------------------------------------------------------ . ** Estimating the model using default options (homosekdasticity, no autocorrelation) . . ** xtgls n w k ys, i(id) t(year) igls panels(correlated) . ** MLE estimation of by specifying the igls option, which iterates the GLS estimates. . ** The above does not work, since the panel should be balanced. . ** We now use a different data set, which is a balanced panel. . . use invest2.dta, clear . * use http://www.stata-press.com/data/r8/invest2, clear . . xtgls invest market stock, i(company) panels(iid) corr(independent) nmk Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: homoskedastic Correlation: no autocorrelation Estimated covariances = 1 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 341.63 Log likelihood = -624.9928 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .1050854 .0113778 9.24 0.000 .0827853 .1273855 stock | .3053655 .0435078 7.02 0.000 .2200918 .3906393 _cons | -48.02974 21.48016 -2.24 0.025 -90.13009 -5.929387 ------------------------------------------------------------------------------ . ** same as regress (iid, homoskedasticity, no autocorrelation) . ** nmk specifies std error to be normalized by n-k. . . xtgls invest market stock, i(company) panels(hetero) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: no autocorrelation Estimated covariances = 5 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 865.38 Log likelihood = -570.1305 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0949905 .007409 12.82 0.000 .0804692 .1095118 stock | .3378129 .0302254 11.18 0.000 .2785722 .3970535 _cons | -36.2537 6.124363 -5.92 0.000 -48.25723 -24.25017 ------------------------------------------------------------------------------ . ** iid, heteroskedasticity, no autocorrelation . . xtgls invest market stock, i(company) t(time) panels(correlated) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic with cross-sectional correlation Correlation: no autocorrelation Estimated covariances = 15 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 1285.19 Log likelihood = -537.8045 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0961894 .0054752 17.57 0.000 .0854583 .1069206 stock | .3095321 .0179851 17.21 0.000 .2742819 .3447822 _cons | -38.36128 5.344871 -7.18 0.000 -48.83703 -27.88552 ------------------------------------------------------------------------------ . ** correlated, heteroskedasticity, no autocorrelation . . xtgls invest market stock, i(company) t(time) panels(correlated) igls nolog Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic with cross-sectional correlation Correlation: no autocorrelation Estimated covariances = 15 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 558.51 Log likelihood = -515.4222 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .023631 .004291 5.51 0.000 .0152207 .0320413 stock | .1709472 .0152526 11.21 0.000 .1410526 .2008417 _cons | -2.216508 1.958845 -1.13 0.258 -6.055774 1.622759 ------------------------------------------------------------------------------ . ** correlated, heteroskedasticity, no autocorrelation . ** MLE estimation by iterative GLS (1046 iterations for this case.) . . xtgls invest market stock, i(company) panels(hetero) corr(ar1) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: common AR(1) coefficient for all panels (0.8651) Estimated covariances = 5 Number of obs = 100 Estimated autocorrelations = 1 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 119.69 Log likelihood = -506.0909 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0744315 .0097937 7.60 0.000 .0552362 .0936268 stock | .2874294 .0475391 6.05 0.000 .1942545 .3806043 _cons | -18.96238 17.64943 -1.07 0.283 -53.55464 15.62987 ------------------------------------------------------------------------------ . ** iid, heteroskedasticity, common ar1 autocorrelation . . xtgls invest market stock, i(company) panels(hetero) corr(psar1) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: panel-specific AR(1) Estimated covariances = 5 Number of obs = 100 Estimated autocorrelations = 5 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 214.61 Log likelihood = -499.2096 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0794318 .008779 9.05 0.000 .0622253 .0966383 stock | .3542689 .0408075 8.68 0.000 .2742877 .4342501 _cons | -12.13555 14.0209 -0.87 0.387 -39.616 15.3449 ------------------------------------------------------------------------------ . ** iid, heteroskedasticity, hetero ar1 autocorrelation . . xtgls invest market stock, i(company) t(time) panels(correlated) corr(psar1) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic with cross-sectional correlation Correlation: panel-specific AR(1) Estimated covariances = 15 Number of obs = 100 Estimated autocorrelations = 5 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 331.55 Log likelihood = -484.6178 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0820264 .0081381 10.08 0.000 .066076 .0979767 stock | .3800689 .0313874 12.11 0.000 .3185508 .441587 _cons | -11.51848 12.69055 -0.91 0.364 -36.39151 13.35455 ------------------------------------------------------------------------------ . ** correlated, heteroskedasticity, hetero ar1 autocorrelation . . matrix list e(Sigma) symmetric e(Sigma)[5,5] _ee _ee2 _ee3 _ee4 _ee5 _ee 4736.5467 _ee2 -152.24615 300.90041 _ee3 835.57421 215.92407 1231.3176 _ee4 -61.936167 116.27065 415.96316 296.20356 _ee5 -1378.6715 64.390033 1054.5174 680.32145 8631.0732 . ** Estimated cross-sectional covariances . . predict new_inv1, xb . list new_inv1 +----------+ | new_inv1 | |----------| 1. | 242.0638 | 2. | 390.8554 | 3. | 489.9985 | 4. | 297.0259 | 5. | 419.5836 | |----------| 6. | 448.154 | 7. | 458.7935 | 8. | 370.0102 | 9. | 421.368 | 10. | 424.3214 | |----------| 11. | 486.2812 | 12. | 543.3482 | 13. | 567.1699 | 14. | 606.0283 | 15. | 679.7037 | |----------| 16. | 714.2354 | 17. | 843.9241 | 18. | 936.1417 | 19. | 1175.962 | 20. | 1293.452 | |----------| 21. | 26.71825 | 22. | 61.0799 | 23. | 74.17301 | 24. | 44.08843 | 25. | 68.67327 | |----------| 26. | 73.68292 | 27. | 69.85486 | 28. | 49.32307 | 29. | 62.24846 | 30. | 68.7629 | |----------| 31. | 78.66039 | 32. | 94.02652 | 33. | 72.76545 | 34. | 87.34061 | 35. | 92.92383 | |----------| 36. | 107.394 | 37. | 132.1849 | 38. | 158.5627 | 39. | 202.1728 | 40. | 203.853 | |----------| 41. | 121.6723 | 42. | 193.5094 | 43. | 263.2741 | 44. | 215.1574 | 45. | 239.1493 | |----------| 46. | 234.299 | 47. | 222.8833 | 48. | 228.1232 | 49. | 253.5625 | 50. | 248.9925 | |----------| 51. | 274.6359 | 52. | 301.1242 | 53. | 297.838 | 54. | 326.614 | 55. | 340.9235 | |----------| 56. | 366.6416 | 57. | 392.8605 | 58. | 435.0397 | 59. | 487.1844 | 60. | 552.7093 | |----------| 61. | 4.873693 | 62. | 31.11118 | 63. | 51.09124 | 64. | 41.32834 | 65. | 40.05864 | |----------| 66. | 50.10691 | 67. | 46.29637 | 68. | 57.6229 | 69. | 71.186 | 70. | 74.54972 | |----------| 71. | 84.06972 | 72. | 83.54849 | 73. | 78.3973 | 74. | 92.44457 | 75. | 90.26228 | |----------| 76. | 92.54008 | 77. | 97.14713 | 78. | 114.6605 | 79. | 152.816 | 80. | 167.1474 | |----------| 81. | 120.6819 | 82. | 155.9048 | 83. | 252.8948 | 84. | 235.1787 | 85. | 267.8793 | |----------| 86. | 265.7909 | 87. | 283.0953 | 88. | 279.8905 | 89. | 266.0168 | 90. | 243.3464 | |----------| 91. | 221.5054 | 92. | 246.4914 | 93. | 236.5005 | 94. | 238.4831 | 95. | 258.6617 | |----------| 96. | 262.0612 | 97. | 306.3024 | 98. | 334.4358 | 99. | 392.1126 | 100. | 416.5404 | +----------+ . . ***************************************** . * xtreg * . ***************************************** . . use abdata.dta, clear . * use http://www.stata-press.com/data/r8/abdata, clear . . ** estimate GLS random-effects model . xtreg n w k ys, re i(id) theta Random-effects GLS regression Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.6108 Obs per group: min = 7 between = 0.8479 avg = 7.4 overall = 0.8356 max = 9 Random effects u_i ~ Gaussian Wald chi2(3) = 2018.16 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------- theta -------------------- min 5% median 95% max 0.9066 0.9066 0.9066 0.9175 0.9175 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2900276 .0492318 -5.89 0.000 -.3865201 -.193535 k | .639224 .0176213 36.28 0.000 .6046868 .6737611 ys | .4400795 .0529618 8.31 0.000 .3362762 .5438828 _cons | .2236526 .3125287 0.72 0.474 -.3888925 .8361977 -------------+---------------------------------------------------------------- sigma_u | .52415108 sigma_e | .13015331 rho | .94192191 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . . xttest0 Breusch and Pagan Lagrangian multiplier test for random effects: n[id,t] = Xb + u[id] + e[id,t] Estimated results: | Var sd = sqrt(Var) ---------+----------------------------- n | 1.79964 1.341506 e | .0169399 .1301533 u | .2747344 .5241511 Test: Var(u) = 0 chi2(1) = 3044.54 Prob > chi2 = 0.0000 . ** Breusch and Pagan LM test for random effects, modified by Baltagi and Li (1990; see manual, p. 210 > ) . . xthausman (Warning: xthausman is no longer a supported command; use -hausman-. For instructions, see help hausman.) Hausman specification test ---- Coefficients ---- | Fixed Random n | Effects Effects Difference -------------+----------------------------------------- w | -.3106425 -.2900276 -.020615 k | .5489458 .639224 -.0902782 ys | .5370108 .4400795 .0969313 Test: Ho: difference in coefficients not systematic chi2( 3) = (b-B)'[S^(-1)](b-B), S = (S_fe - S_re) = 62.86 Prob>chi2 = 0.0000 . ** Performs the Hausman specification test for RE versus FE. . . xtreg n w k ys, re i(id) Random-effects GLS regression Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.6108 Obs per group: min = 7 between = 0.8479 avg = 7.4 overall = 0.8356 max = 9 Random effects u_i ~ Gaussian Wald chi2(3) = 2018.16 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2900276 .0492318 -5.89 0.000 -.3865201 -.193535 k | .639224 .0176213 36.28 0.000 .6046868 .6737611 ys | .4400795 .0529618 8.31 0.000 .3362762 .5438828 _cons | .2236526 .3125287 0.72 0.474 -.3888925 .8361977 -------------+---------------------------------------------------------------- sigma_u | .52415108 sigma_e | .13015331 rho | .94192191 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . ** RE GLS . . xtreg n w k ys, mle i(id) nolog Random-effects ML regression Number of obs = 1031 Group variable (i): id Number of groups = 140 Random effects u_i ~ Gaussian Obs per group: min = 7 avg = 7.4 max = 9 LR chi2(3) = 1061.51 Log likelihood = 281.8318 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2924432 .0486851 -6.01 0.000 -.3878643 -.1970221 k | .6257345 .0194888 32.11 0.000 .5875372 .6639317 ys | .4545622 .0528578 8.60 0.000 .3509627 .5581616 _cons | .1585114 .3111881 0.51 0.610 -.4514062 .7684289 -------------+---------------------------------------------------------------- /sigma_u | .5936612 .0384053 15.46 0.000 .5183882 .6689343 /sigma_e | .1308945 .0031385 41.71 0.000 .124743 .1370459 -------------+---------------------------------------------------------------- rho | .9536394 .0062174 .9401097 .9645981 ------------------------------------------------------------------------------ Likelihood-ratio test of sigma_u=0: chibar2(01)= 2232.83 Prob>=chibar2 = 0.000 . ** estimate ML RE model (supressing iterations with nolog) . . xtreg n w k ys, re i(id) sa Random-effects GLS regression Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.6109 Obs per group: min = 7 between = 0.8479 avg = 7.4 overall = 0.8356 max = 9 Random effects u_i ~ Gaussian Wald chi2(3) = 2009.17 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2902757 .0491787 -5.90 0.000 -.3866643 -.1938872 k | .6377494 .0176602 36.11 0.000 .603136 .6723627 ys | .4416624 .052888 8.35 0.000 .3380038 .545321 _cons | .216483 .3121842 0.69 0.488 -.3953868 .8283527 -------------+---------------------------------------------------------------- sigma_u | .53075637 sigma_e | .13015331 rho | .943277 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . ** RE: using the small-sample Swamy-Arora estimator by Baltagi and Chang (1994; see manual, p. 209) . . xtreg n w k ys, pa i(id) nolog GEE population-averaged model Number of obs = 1031 Group variable: id Number of groups = 140 Link: identity Obs per group: min = 7 Family: Gaussian avg = 7.4 Correlation: exchangeable max = 9 Wald chi2(3) = 2233.31 Scale parameter: .3835653 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2950091 .044277 -6.66 0.000 -.3817905 -.2082278 k | .612925 .0167513 36.59 0.000 .5800931 .6457569 ys | .4683177 .0474337 9.87 0.000 .3753493 .5612861 _cons | .0974951 .2816809 0.35 0.729 -.4545894 .6495795 ------------------------------------------------------------------------------ . ** GEE population-averaged model; equivalent to the RE . ** also equivalent to the following xtgee . . xtgee n w k ys, family(gaussian) link(id) corr(exchangeable) Iteration 1: tolerance = .16199051 Iteration 2: tolerance = .02512292 Iteration 3: tolerance = .00074407 Iteration 4: tolerance = .0000217 Iteration 5: tolerance = 6.324e-07 GEE population-averaged model Number of obs = 1031 Group variable: id Number of groups = 140 Link: identity Obs per group: min = 7 Family: Gaussian avg = 7.4 Correlation: exchangeable max = 9 Wald chi2(3) = 2233.31 Scale parameter: .3835653 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2950091 .044277 -6.66 0.000 -.3817905 -.2082278 k | .612925 .0167513 36.59 0.000 .5800931 .6457569 ys | .4683177 .0474337 9.87 0.000 .3753493 .5612861 _cons | .0974951 .2816809 0.35 0.729 -.4545894 .6495795 ------------------------------------------------------------------------------ . . xtreg n w k ys, re i(id) Random-effects GLS regression Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.6108 Obs per group: min = 7 between = 0.8479 avg = 7.4 overall = 0.8356 max = 9 Random effects u_i ~ Gaussian Wald chi2(3) = 2018.16 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2900276 .0492318 -5.89 0.000 -.3865201 -.193535 k | .639224 .0176213 36.28 0.000 .6046868 .6737611 ys | .4400795 .0529618 8.31 0.000 .3362762 .5438828 _cons | .2236526 .3125287 0.72 0.474 -.3888925 .8361977 -------------+---------------------------------------------------------------- sigma_u | .52415108 sigma_e | .13015331 rho | .94192191 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . ** Between estimator . . xtreg n w k ys, be i(id) wls Between regression (regression on group means) Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.5879 Obs per group: min = 7 between = 0.8435 avg = 7.4 overall = 0.8282 max = 9 F(3,136) = 244.26 sd(u_i + avg(e_i.))= .5325667 Prob > F = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.4258937 .1844023 -2.31 0.022 -.7905605 -.0612268 k | .8146681 .0301341 27.03 0.000 .7550761 .8742601 ys | 1.738514 1.177977 1.48 0.142 -.5910059 4.068034 _cons | -5.308935 5.382833 -0.99 0.326 -15.95381 5.335944 ------------------------------------------------------------------------------ . ** Between estimator . ** (wls is used for unbalanced panel, and a stabilized variance is used.) . . xtreg n w k ys, fe i(id) Fixed-effects (within) regression Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.6143 Obs per group: min = 7 between = 0.8483 avg = 7.4 overall = 0.8348 max = 9 F(3,888) = 471.39 corr(u_i, Xb) = 0.5926 Prob > F = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.3106425 .0499301 -6.22 0.000 -.4086372 -.2126478 k | .5489458 .0211507 25.95 0.000 .5074346 .590457 ys | .5370108 .0534193 10.05 0.000 .432168 .6418535 _cons | -.2159137 .3108411 -0.69 0.487 -.8259826 .3941552 -------------+---------------------------------------------------------------- sigma_u | .66133388 sigma_e | .13015331 rho | .96271232 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(139, 888) = 123.02 Prob > F = 0.0000 . ** Estimating the Fixed-effects model . . ***************************************** . * xtregar * . ***************************************** . . ** FE and RE with AR(1) error . . use grunfeld.dta, clear . * use http://www.stata-press.com/data/r8/grunfeld, clear . . tsset panel variable: company, 1 to 10 time variable: year, 1935 to 1954 . * tsset company year . . xtregar invest mvalue kstock, fe FE (within) regression with AR(1) disturbances Number of obs = 190 Group variable (i): company Number of groups = 10 R-sq: within = 0.5927 Obs per group: min = 19 between = 0.7989 avg = 19.0 overall = 0.7904 max = 19 F(2,178) = 129.49 corr(u_i, Xb) = -0.0454 Prob > F = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mvalue | .0949999 .0091377 10.40 0.000 .0769677 .113032 kstock | .350161 .0293747 11.92 0.000 .2921935 .4081286 _cons | -63.22022 5.648271 -11.19 0.000 -74.36641 -52.07402 -------------+---------------------------------------------------------------- rho_ar | .67210608 sigma_u | 91.507609 sigma_e | 40.992469 rho_fov | .8328647 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(9,178) = 11.53 Prob > F = 0.0000 . ** Estimating the Fixed-effects model with ar(1) error . . xtregar invest mvalue kstock, re RE GLS regression with AR(1) disturbances Number of obs = 200 Group variable (i): company Number of groups = 10 R-sq: within = 0.7649 Obs per group: 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 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- mvalue | .0949215 .0082168 11.55 0.000 .0788168 .1110262 kstock | .3196589 .0258618 12.36 0.000 .2689707 .3703471 _cons | -44.38123 26.97525 -1.65 0.100 -97.25175 8.489292 -------------+---------------------------------------------------------------- rho_ar | .67210608 (estimated autocorrelation coefficient) sigma_u | 74.517098 sigma_e | 41.482494 rho_fov | .7634186 (fraction of variance due to u_i) theta | .67315699 ------------------------------------------------------------------------------ . ** Estimating the Fixed-effects model with ar(1) error . . ***************************************** . * xtivreg * . ***************************************** . ** Estimating instrumental variable panel data models . . use abdata.dta, clear . * use http://www.stata-press.com/data/r8/abdata, clear . . tsset id year panel variable: id, 1 to 140 time variable: year, 1976 to 1984 . . xtivreg n l2.n l(0/1).w l(0/2).(k ys) yr1977-yr1984 (l.n = l3.n), i(id) fd note: yr1977 dropped due to collinearity note: yr1984 dropped due to collinearity First-differenced IV regression Number of obs = 471 Group variable: id Number of groups = 140 R-sq: within = 0.0112 Obs per group: min = 3 between = 0.9182 avg = 3.4 overall = 0.9895 max = 5 chi2(14) = 122.53 corr(u_i, Xb) = 0.9280 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ d.n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | 1.422765 1.583053 0.90 0.369 -1.679962 4.525493 L2D | -.1645517 .1647179 -1.00 0.318 -.4873928 .1582894 w | D1 | -.7524675 .1765733 -4.26 0.000 -1.098545 -.4063902 LD | .9627611 1.086506 0.89 0.376 -1.166752 3.092275 k | D1 | .3221686 .1466086 2.20 0.028 .0348211 .6095161 LD | -.3248778 .5800599 -0.56 0.575 -1.461774 .8120187 L2D | -.0953947 .1960883 -0.49 0.627 -.4797207 .2889314 ys | D1 | .7660906 .369694 2.07 0.038 .0415037 1.490678 LD | -1.361881 1.156835 -1.18 0.239 -3.629237 .9054744 L2D | .3212993 .5440403 0.59 0.555 -.745 1.387599 yr1978 | D1 | (dropped) yr1979 | D1 | (dropped) yr1980 | D1 | .0234422 .030392 0.77 0.441 -.0361251 .0830094 yr1981 | D1 | -.0105354 .0394327 -0.27 0.789 -.0878221 .0667513 yr1982 | D1 | -.0179687 .0393765 -0.46 0.648 -.0951452 .0592078 yr1983 | D1 | -.0125467 .0341721 -0.37 0.713 -.0795227 .0544293 _cons | -.0073217 .0154928 -0.47 0.637 -.037687 .0230436 -------------+---------------------------------------------------------------- sigma_u | .29258962 sigma_e | .18855982 rho | .70655512 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Instrumented: L.n Instruments: L2.n w L.w k L.k L2.k ys L.ys L2.ys yr1978 yr1979 yr1980 yr1981 yr1982 yr1983 L3.n . ** FD model . . ** dep = n . ** ind = . ** l.n = n(t-1) ... endogenous and instrumented . ** l2.n = n(t-2) .. L2D . ** l(0/1).w = w(t), w(t-1) .. D1 (level), LD (lagged) . ** l(0.2).(k ys) = k(t), k(t-1), k(t-2); ys(t), ys(t-1), ys(t-2) .. D1, LD, L2D . ** iv = l3.n = n(t-3) & all other exogenous variables . . xtivreg n l2.n l(0/1).w l(0/2).(k ys) yr1977-yr1984 (l.n = l3.n), i(id) fd first small note: yr1977 dropped due to collinearity note: yr1984 dropped due to collinearity First-stage first-differenced regression Source | SS df MS Number of obs = 51 -------------+------------------------------ F( 11, 39) = 10.09 Model | 1.03715748 11 .094287044 Prob > F = 0.0000 Residual | .364453333 39 .009344957 R-squared = 0.7400 -------------+------------------------------ Adj R-squared = 0.6666 Total | 1.40161082 50 .028032216 Root MSE = .09667 ------------------------------------------------------------------------------ LD.n | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | L2D | .2473774 .1392755 1.78 0.084 -.0343338 .5290887 w | D1 | .5827452 .3289429 1.77 0.084 -.0826045 1.248095 LD | -1.124016 .1687218 -6.66 0.000 -1.465288 -.7827438 k | D1 | .0878886 .1459256 0.60 0.550 -.2072737 .3830509 LD | .5000448 .134523 3.72 0.001 .2279463 .7721432 L2D | .0997365 .0780229 1.28 0.209 -.0580798 .2575527 ys | D1 | -.9224115 .835549 -1.10 0.276 -2.612469 .7676459 LD | .1071333 .9179753 0.12 0.908 -1.749647 1.963914 L2D | -.5476357 .5501589 -1.00 0.326 -1.660437 .5651656 yr1978 | D1 | (dropped) yr1979 | D1 | (dropped) yr1980 | D1 | (dropped) yr1981 | D1 | (dropped) yr1982 | D1 | (dropped) yr1983 | D1 | -.0113289 .022019 -0.51 0.610 -.0558666 .0332088 n | L3D | -.2836938 .1098172 -2.58 0.014 -.50582 -.0615676 _cons | .0231091 .0356946 0.65 0.521 -.0490901 .0953084 ------------------------------------------------------------------------------ First-differenced IV regression Number of obs = 471 Group variable: id Number of groups = 140 R-sq: within = 0.0112 Obs per group: min = 3 between = 0.9182 avg = 3.4 overall = 0.9895 max = 5 F(14,456) = 8.75 corr(u_i, Xb) = 0.9280 Prob > F = 0.0000 ------------------------------------------------------------------------------ d.n | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | 1.422765 1.583053 0.90 0.369 -1.688219 4.53375 L2D | -.1645517 .1647179 -1.00 0.318 -.488252 .1591485 w | D1 | -.7524675 .1765733 -4.26 0.000 -1.099466 -.4054692 LD | .9627611 1.086506 0.89 0.376 -1.17242 3.097942 k | D1 | .3221686 .1466086 2.20 0.028 .0340564 .6102808 LD | -.3248778 .5800599 -0.56 0.576 -1.4648 .8150442 L2D | -.0953947 .1960883 -0.49 0.627 -.4807435 .2899542 ys | D1 | .7660906 .369694 2.07 0.039 .0395754 1.492606 LD | -1.361881 1.156835 -1.18 0.240 -3.635271 .9115083 L2D | .3212993 .5440403 0.59 0.555 -.7478377 1.390436 yr1978 | D1 | (dropped) yr1979 | D1 | (dropped) yr1980 | D1 | .0234422 .030392 0.77 0.441 -.0362836 .0831679 yr1981 | D1 | -.0105354 .0394327 -0.27 0.789 -.0880278 .0669569 yr1982 | D1 | -.0179687 .0393765 -0.46 0.648 -.0953506 .0594132 yr1983 | D1 | -.0125467 .0341721 -0.37 0.714 -.079701 .0546075 _cons | -.0073217 .0154928 -0.47 0.637 -.0377678 .0231244 -------------+---------------------------------------------------------------- sigma_u | .29258962 sigma_e | .18855982 rho | .70655512 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Instrumented: L.n Instruments: L2.n w L.w k L.k L2.k ys L.ys L2.ys yr1978 yr1979 yr1980 yr1981 yr1982 yr1983 L3.n . . xtivreg n w yr1977-yr1984 (k = ys), fe i(id) Fixed-effects (within) IV regression Number of obs = 1031 Group variable: id Number of groups = 140 R-sq: within = 0.5596 Obs per group: min = 7 between = 0.8460 avg = 7.4 overall = 0.8347 max = 9 Wald chi2(10) = 59708.78 corr(u_i, Xb) = -0.0563 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- k | .8343187 .0941279 8.86 0.000 .6498315 1.018806 w | -.295091 .0604452 -4.88 0.000 -.4135614 -.1766206 yr1977 | -.0319227 .0204864 -1.56 0.119 -.0720753 .00823 yr1978 | -.0705654 .0211752 -3.33 0.001 -.112068 -.0290629 yr1979 | -.0899977 .021785 -4.13 0.000 -.1326955 -.0472998 yr1980 | -.0996051 .0209567 -4.75 0.000 -.1406795 -.0585306 yr1981 | -.123798 .0210075 -5.89 0.000 -.164972 -.0826241 yr1982 | -.1092436 .0268044 -4.08 0.000 -.1617793 -.0567079 yr1983 | -.0973404 .0326918 -2.98 0.003 -.1614151 -.0332657 yr1984 | -.0435679 .0414598 -1.05 0.293 -.1248275 .0376917 _cons | 2.431976 .2018614 12.05 0.000 2.036335 2.827617 -------------+---------------------------------------------------------------- sigma_u | .52613977 sigma_e | .13962614 rho | .93420776 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(139,881) = 105.96 Prob > F = 0.0000 ------------------------------------------------------------------------------ Instrumented: k Instruments: w yr1977 yr1978 yr1979 yr1980 yr1981 yr1982 yr1983 yr1984 ys . ** Fixed-effects model . . xtivreg n w yr1977-yr1984 (k = ys), fe i(id) first First-stage within regression Fixed-effects (within) regression Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.2841 Obs per group: min = 7 between = 0.0077 avg = 7.4 overall = 0.0108 max = 9 F(10,881) = 34.96 corr(u_i, Xb) = 0.0234 Prob > F = 0.0000 ------------------------------------------------------------------------------ k | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.0062273 .0856414 -0.07 0.942 -.1743123 .1618577 yr1977 | -.0220045 .0289937 -0.76 0.448 -.0789092 .0349002 yr1978 | .0235714 .0294908 0.80 0.424 -.0343089 .0814518 yr1979 | .0535271 .0293347 1.82 0.068 -.0040469 .111101 yr1980 | .080943 .0296978 2.73 0.007 .0226564 .1392296 yr1981 | .0581101 .0326904 1.78 0.076 -.00605 .1222702 yr1982 | -.0493203 .0339083 -1.45 0.146 -.1158709 .0172302 yr1983 | -.1048502 .0379603 -2.76 0.006 -.1793533 -.0303471 yr1984 | -.2036908 .0444118 -4.59 0.000 -.2908562 -.1165255 ys | .9235124 .1230068 7.51 0.000 .6820918 1.164933 _cons | -4.710131 .604728 -7.79 0.000 -5.897007 -3.523255 -------------+---------------------------------------------------------------- sigma_u | 1.5061705 sigma_e | .19757636 rho | .98308344 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(139, 881) = 419.78 Prob > F = 0.0000 Fixed-effects (within) IV regression Number of obs = 1031 Group variable: id Number of groups = 140 R-sq: within = 0.5596 Obs per group: min = 7 between = 0.8460 avg = 7.4 overall = 0.8347 max = 9 Wald chi2(10) = 59708.78 corr(u_i, Xb) = -0.0563 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- k | .8343187 .0941279 8.86 0.000 .6498315 1.018806 w | -.295091 .0604452 -4.88 0.000 -.4135614 -.1766206 yr1977 | -.0319227 .0204864 -1.56 0.119 -.0720753 .00823 yr1978 | -.0705654 .0211752 -3.33 0.001 -.112068 -.0290629 yr1979 | -.0899977 .021785 -4.13 0.000 -.1326955 -.0472998 yr1980 | -.0996051 .0209567 -4.75 0.000 -.1406795 -.0585306 yr1981 | -.123798 .0210075 -5.89 0.000 -.164972 -.0826241 yr1982 | -.1092436 .0268044 -4.08 0.000 -.1617793 -.0567079 yr1983 | -.0973404 .0326918 -2.98 0.003 -.1614151 -.0332657 yr1984 | -.0435679 .0414598 -1.05 0.293 -.1248275 .0376917 _cons | 2.431976 .2018614 12.05 0.000 2.036335 2.827617 -------------+---------------------------------------------------------------- sigma_u | .52613977 sigma_e | .13962614 rho | .93420776 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(139,881) = 105.96 Prob > F = 0.0000 ------------------------------------------------------------------------------ Instrumented: k Instruments: w yr1977 yr1978 yr1979 yr1980 yr1981 yr1982 yr1983 yr1984 ys . ** Fixed-effects model, reporting the first stage result. . . xtivreg n w (k = ys), be i(id) first First-stage between regression Between regression (regression on group means) Number of obs = 1031 Group variable (i): id Number of groups = 140 R-sq: within = 0.1245 Obs per group: min = 7 between = 0.0048 avg = 7.4 overall = 0.0024 max = 9 F(2,137) = 0.33 sd(u_i + avg(e_i.))= 1.516617 Prob > F = 0.7217 ------------------------------------------------------------------------------ k | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | .4318455 .5366224 0.80 0.422 -.6292884 1.492979 ys | -.2381998 3.327185 -0.07 0.943 -6.817479 6.34108 _cons | -.669496 15.21023 -0.04 0.965 -30.74668 29.40769 ------------------------------------------------------------------------------ Between-effects IV regression: Number of obs = 1031 Group variable: id Number of groups = 140 R-sq: within = 0.5687 Obs per group: min = 7 between = . avg = 7.4 overall = 0.8345 max = 9 chi2(2) = 0.00 sd(u_i + avg(e_i.))= 10.11202 Prob > chi2 = 0.9979 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- k | -5.839915 93.13172 -0.06 0.950 -188.3747 176.6949 w | 2.420118 39.7088 0.06 0.951 -75.40771 80.24794 _cons | -8.954817 163.533 -0.05 0.956 -329.4737 311.564 -------------+---------------------------------------------------------------- Instrumented: k Instruments: w ys . ** Between-effects model . . xtivreg n w (k = ys), re nosa i(id) first theta First-stage G2SLS regression Number of obs = 1031 Wald chi(2) = 275 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ k | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- w | -.2687132 .0732208 -3.67 0.000 -.4122234 -.1252031 ys | 1.085991 .0712011 15.25 0.000 .9464392 1.225542 _cons | -4.605746 1.071506 -4.30 0.000 -6.705859 -2.505633 ------------------------------------------------------------------------------ G2SLS random-effects IV regression Number of obs = 1031 Group variable: id Number of groups = 140 R-sq: within = 0.5589 Obs per group: min = 7 between = 0.8444 avg = 7.4 overall = 0.8325 max = 9 Wald chi2(2) = 530.32 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------- theta -------------------- min 5% median 95% max 0.9937 0.9937 0.9937 0.9945 0.9945 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- k | 1.043442 .0524789 19.88 0.000 .9405856 1.146299 w | -.1777629 .0627195 -2.83 0.005 -.300691 -.0548349 _cons | 2.079125 .8062452 2.58 0.010 .4989138 3.659337 -------------+---------------------------------------------------------------- sigma_u | 9.9550715 sigma_e | .16515281 rho | .99972485 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Instrumented: k Instruments: w ys . ** GLS Random-effects model . . xtivreg n w (k = ys), re ec2sls i(id) first theta First-stage EC2SLS regression Number of obs = 1031 Wald chi(4) = 244 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ k | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ys_d | .927665 .0646593 14.35 0.000 .8009351 1.054395 ys_m | -.6670052 .0871169 -7.66 0.000 -.8377512 -.4962591 w_d | -.3958945 .0696169 -5.69 0.000 -.532341 -.2594479 w_m | .0118271 .0255644 0.46 0.644 -.0382782 .0619324 _cons | -.6942421 24.24316 -0.03 0.977 -48.20996 46.82148 ------------------------------------------------------------------------------ EC2SLS random-effects IV regression Number of obs = 1031 Group variable: id Number of groups = 140 R-sq: within = 0.5590 Obs per group: min = 7 between = 0.8444 avg = 7.4 overall = 0.8326 max = 9 Wald chi2(2) = 498.89 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------- theta -------------------- min 5% median 95% max 0.9938 0.9938 0.9938 0.9945 0.9945 ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- k | 1.041313 .0590769 17.63 0.000 .9255243 1.157101 w | -.1801911 .0699423 -2.58 0.010 -.3172756 -.0431067 _cons | 2.085889 .8171563 2.55 0.011 .4842922 3.687486 -------------+---------------------------------------------------------------- sigma_u | 10.066037 sigma_e | .16533848 rho | .99973028 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Instrumented: k Instruments: w ys . ** EC2SLS Random-effects model . . ***************************************** . * xtabond * . ***************************************** . . ** Arellano-Bond estimator . . use abdata.dta, clear . * use http://www.stata-press.com/data/r8/abdata, clear . . xtabond n l(0/1).w l(0/2).(k ys) yr1977-yr1984, lag(2) note: yr1977 dropped due to collinearity note: yr1978 dropped due to collinearity note: yr1984 dropped due to collinearity Arellano-Bond dynamic panel-data estimation Number of obs = 611 Group variable (i): id Number of groups = 140 Wald chi2(15) = 575.84 Time variable (t): year Obs per group: min = 4 avg = 4.364286 max = 6 One-step results ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | .6862262 .1486163 4.62 0.000 .3949435 .9775088 L2D | -.0853582 .0444365 -1.92 0.055 -.1724523 .0017358 w | D1 | -.6078208 .0657694 -9.24 0.000 -.7367265 -.4789151 LD | .3926237 .1092374 3.59 0.000 .1785222 .6067251 k | D1 | .3568456 .0370314 9.64 0.000 .2842653 .4294259 LD | -.0580012 .0583051 -0.99 0.320 -.172277 .0562747 L2D | -.0199475 .0416274 -0.48 0.632 -.1015357 .0616408 ys | D1 | .6085073 .1345412 4.52 0.000 .3448115 .8722031 LD | -.7111651 .1844599 -3.86 0.000 -1.0727 -.3496304 L2D | .1057969 .1428568 0.74 0.459 -.1741974 .3857912 yr1979 | D1 | .0108384 .013022 0.83 0.405 -.0146843 .0363611 yr1980 | D1 | .024583 .0166184 1.48 0.139 -.0079886 .0571545 yr1981 | D1 | -.0079226 .0215863 -0.37 0.714 -.050231 .0343857 yr1982 | D1 | -.0219233 .0202268 -1.08 0.278 -.0615671 .0177206 yr1983 | D1 | -.014901 .0194978 -0.76 0.445 -.0531159 .023314 _cons | -.0012839 .0051344 -0.25 0.803 -.0113472 .0087794 ------------------------------------------------------------------------------ Sargan test of over-identifying restrictions: chi2(25) = 65.82 Prob > chi2 = 0.0000 Arellano-Bond test that average autocovariance in residuals of order 1 is 0: H0: no autocorrelation z = -3.94 Pr > z = 0.0001 Arellano-Bond test that average autocovariance in residuals of order 2 is 0: H0: no autocorrelation z = -0.54 Pr > z = 0.5876 . ** One step estimator . ** Sargan's test of over-identification restriction test >> p-value < 0.001. . ** Sargan's test assumes homoskedasticity. . . xtabond n l(0/1).w l(0/2).(k ys) yr1977-yr1984, lag(1) robust note: yr1977 dropped due to collinearity note: yr1984 dropped due to collinearity Arellano-Bond dynamic panel-data estimation Number of obs = 611 Group variable (i): id Number of groups = 140 Wald chi2(14) = 597.71 Time variable (t): year Obs per group: min = 4 avg = 4.364286 max = 6 One-step results ------------------------------------------------------------------------------ | Robust n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | .6143239 .1235217 4.97 0.000 .3722258 .856422 w | D1 | -.6081707 .181777 -3.35 0.001 -.964447 -.2518943 LD | .341696 .1612161 2.12 0.034 .0257183 .6576737 k | D1 | .3553363 .0584546 6.08 0.000 .2407674 .4699052 LD | -.038231 .0671983 -0.57 0.569 -.1699372 .0934753 L2D | -.0443703 .0315976 -1.40 0.160 -.1063004 .0175598 ys | D1 | .5951627 .1752934 3.40 0.001 .2515939 .9387315 LD | -.6477716 .2339837 -2.77 0.006 -1.106371 -.189172 L2D | .0584687 .1477819 0.40 0.692 -.2311785 .3481159 yr1978 | D1 | (dropped) yr1979 | D1 | .0097498 .0095582 1.02 0.308 -.0089839 .0284835 yr1980 | D1 | .0231279 .0159656 1.45 0.147 -.0081642 .0544199 yr1981 | D1 | -.0080811 .0258151 -0.31 0.754 -.0586778 .0425156 yr1982 | D1 | -.022891 .0212459 -1.08 0.281 -.0645322 .0187501 yr1983 | D1 | -.0141936 .0164053 -0.87 0.387 -.0463475 .0179602 _cons | -.0011759 .0053837 -0.22 0.827 -.0117278 .009376 ------------------------------------------------------------------------------ Arellano-Bond test that average autocovariance in residuals of order 1 is 0: H0: no autocorrelation z = -3.55 Pr > z = 0.0004 Arellano-Bond test that average autocovariance in residuals of order 2 is 0: H0: no autocorrelation z = -1.49 Pr > z = 0.1350 . ** Still, one step estimator but reporting robust std error. . ** The absence of AR(1) error is rejected but no AR(2) error is not rejected. . ** The AR(1) error does not mean the one-step estimator is inconsistent. . ** But, if the null of no AR(2) error is not rejected, the one step estimator is inconsistent, which > is not the case here. . . xtabond n l(0/1).w l(0/2).(k ys) yr1977-yr1984, lag(2) small note: yr1977 dropped due to collinearity note: yr1978 dropped due to collinearity note: yr1984 dropped due to collinearity Arellano-Bond dynamic panel-data estimation Number of obs = 611 Group variable (i): id Number of groups = 140 F(15, 595) = 38.39 Time variable (t): year Obs per group: min = 4 avg = 4.364286 max = 6 One-step results ------------------------------------------------------------------------------ n | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | .6862262 .1486163 4.62 0.000 .3943498 .9781025 L2D | -.0853582 .0444365 -1.92 0.055 -.1726298 .0019133 w | D1 | -.6078208 .0657694 -9.24 0.000 -.7369893 -.4786524 LD | .3926237 .1092374 3.59 0.000 .1780858 .6071615 k | D1 | .3568456 .0370314 9.64 0.000 .2841174 .4295739 LD | -.0580012 .0583051 -0.99 0.320 -.1725099 .0565076 L2D | -.0199475 .0416274 -0.48 0.632 -.101702 .0618071 ys | D1 | .6085073 .1345412 4.52 0.000 .344274 .8727406 LD | -.7111651 .1844599 -3.86 0.000 -1.073437 -.3488935 L2D | .1057969 .1428568 0.74 0.459 -.1747681 .3863619 yr1979 | D1 | .0108384 .013022 0.83 0.406 -.0147364 .0364131 yr1980 | D1 | .024583 .0166184 1.48 0.140 -.008055 .0572209 yr1981 | D1 | -.0079226 .0215863 -0.37 0.714 -.0503172 .0344719 yr1982 | D1 | -.0219233 .0202268 -1.08 0.279 -.0616479 .0178014 yr1983 | D1 | -.014901 .0194978 -0.76 0.445 -.0531938 .0233919 _cons | -.0012839 .0051344 -0.25 0.803 -.0113677 .0088 ------------------------------------------------------------------------------ Sargan test of over-identifying restrictions: chi2(25) = 65.82 Prob > chi2 = 0.0000 Arellano-Bond test that average autocovariance in residuals of order 1 is 0: H0: no autocorrelation z = -3.94 Pr > z = 0.0001 Arellano-Bond test that average autocovariance in residuals of order 2 is 0: H0: no autocorrelation z = -0.54 Pr > z = 0.5876 . ** request t-stat and F-stat be reported instead of Z-stat and chi-square stat. . . xtabond n l(0/1).w l(0/2).(k ys) yr1977-yr1984, lag(2) twostep note: yr1977 dropped due to collinearity note: yr1978 dropped due to collinearity note: yr1984 dropped due to collinearity Arellano-Bond dynamic panel-data estimation Number of obs = 611 Group variable (i): id Number of groups = 140 Wald chi2(15) = 1035.56 Time variable (t): year Obs per group: min = 4 avg = 4.364286 max = 6 Two-step results ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | .6287089 .0904543 6.95 0.000 .4514216 .8059961 L2D | -.0651882 .0265009 -2.46 0.014 -.117129 -.0132474 w | D1 | -.5257597 .0537692 -9.78 0.000 -.6311453 -.420374 LD | .3112899 .0940116 3.31 0.001 .1270305 .4955492 k | D1 | .2783619 .0449083 6.20 0.000 .1903432 .3663807 LD | .0140994 .0528046 0.27 0.789 -.0893957 .1175946 L2D | -.0402484 .0258038 -1.56 0.119 -.0908229 .010326 ys | D1 | .5919243 .1162114 5.09 0.000 .3641542 .8196943 LD | -.5659863 .1396738 -4.05 0.000 -.8397419 -.2922306 L2D | .1005433 .1126749 0.89 0.372 -.1202955 .321382 yr1979 | D1 | .0151101 .0075654 2.00 0.046 .0002822 .029938 yr1980 | D1 | .030858 .0123298 2.50 0.012 .0066919 .055024 yr1981 | D1 | -.0096741 .0197077 -0.49 0.624 -.0483005 .0289522 yr1982 | D1 | -.0155376 .015798 -0.98 0.325 -.0465011 .015426 yr1983 | D1 | .0014798 .0117636 0.13 0.900 -.0215764 .024536 _cons | -.0038946 .0039242 -0.99 0.321 -.0115859 .0037967 ------------------------------------------------------------------------------ Warning: Arellano and Bond recommend using one-step results for inference on coefficients Sargan test of over-identifying restrictions: chi2(25) = 31.38 Prob > chi2 = 0.1767 Arellano-Bond test that average autocovariance in residuals of order 1 is 0: H0: no autocorrelation z = -3.00 Pr > z = 0.0027 Arellano-Bond test that average autocovariance in residuals of order 2 is 0: H0: no autocorrelation z = -0.42 Pr > z = 0.6776 . ** The std errors of the two-step estimator tend to be biased in small samples. . ** Thus, the one-step estimator is recommended for inference, and the Sargan test from the two step e > stimator is used for model specification. . . xtabond n l(0/1).w l(0/2).(k ys) yr1977-yr1984, lag(2) twostep pre(w, lag(1,.)) pre(k, lag(2,.)) note: L.k dropped due to collinearity note: yr1977 dropped due to collinearity note: yr1978 dropped due to collinearity note: yr1984 dropped due to collinearity note: w dropped due to collinearity note: L.w dropped due to collinearity note: k dropped due to collinearity note: L2.k dropped due to collinearity Arellano-Bond dynamic panel-data estimation Number of obs = 611 Group variable (i): id Number of groups = 140 Wald chi2(15) = 17421.86 Time variable (t): year Obs per group: min = 4 avg = 4.364286 max = 6 Two-step results ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | .6420116 .0114024 56.30 0.000 .6196633 .6643599 L2D | -.0980438 .0060972 -16.08 0.000 -.1099941 -.0860935 w | D1 | -.5896784 .0137894 -42.76 0.000 -.6167052 -.5626515 LD | .3346723 .0199696 16.76 0.000 .2955326 .373812 k | D1 | .3627966 .0171813 21.12 0.000 .3291218 .3964713 L2D | .0166455 .0149973 1.11 0.267 -.0127488 .0460397 LD | -.0475972 .0097917 -4.86 0.000 -.0667885 -.0284059 w | D1 | (dropped) LD | (dropped) k | D1 | (dropped) L2D | (dropped) ys | D1 | .5558055 .0427978 12.99 0.000 .4719233 .6396877 LD | -.6225086 .0598228 -10.41 0.000 -.7397591 -.5052581 L2D | .1550242 .0662188 2.34 0.019 .0252378 .2848107 yr1979 | D1 | .0087252 .0045441 1.92 0.055 -.0001811 .0176316 yr1980 | D1 | .0104344 .0064238 1.62 0.104 -.0021561 .0230249 yr1981 | D1 | -.0264269 .0094204 -2.81 0.005 -.0448905 -.0079633 yr1982 | D1 | -.0292746 .0076482 -3.83 0.000 -.0442648 -.0142844 yr1983 | D1 | -.0127913 .0044813 -2.85 0.004 -.0215744 -.0040082 k | LD | (dropped) _cons | .0044304 .0017681 2.51 0.012 .0009649 .0078958 ------------------------------------------------------------------------------ Warning: Arellano and Bond recommend using one-step results for inference on coefficients Sargan test of over-identifying restrictions: chi2(86) = 257.58 Prob > chi2 = 0.0000 Arellano-Bond test that average autocovariance in residuals of order 1 is 0: H0: no autocorrelation z = -3.84 Pr > z = 0.0001 Arellano-Bond test that average autocovariance in residuals of order 2 is 0: H0: no autocorrelation z = -0.08 Pr > z = 0.9377 . ** predetermined regressors . . xtabond n l(0/1).w l(0/2).(k ys) yr1977-yr1984, lag(2) twostep pre(w, lag(1,.) endog) pre(k, lag(2,.) > endog) note: L.k dropped due to collinearity note: yr1977 dropped due to collinearity note: yr1978 dropped due to collinearity note: yr1984 dropped due to collinearity note: w dropped due to collinearity note: L.w dropped due to collinearity note: k dropped due to collinearity note: L2.k dropped due to collinearity Arellano-Bond dynamic panel-data estimation Number of obs = 611 Group variable (i): id Number of groups = 140 Wald chi2(14) = 10312.80 Time variable (t): year Obs per group: min = 4 avg = 4.364286 max = 6 Two-step results ------------------------------------------------------------------------------ n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- n | LD | .776016 .0230331 33.69 0.000 .730872 .82116 L2D | -.07424 .0111451 -6.66 0.000 -.0960839 -.0523961 w | D1 | -.5984576 .016162 -37.03 0.000 -.6301346 -.5667807 LD | (dropped) k | D1 | .344988 .0191558 18.01 0.000 .3074433 .3825327 L2D | -.0303906 .0220894 -1.38 0.169 -.0736851 .0129039 LD | -.1004677 .01405 -7.15 0.000 -.1280052 -.0729301 w | D1 | (dropped) LD | .4128576 .0256273 16.11 0.000 .3626289 .4630863 k | D1 | (dropped) L2D | (dropped) ys | D1 | .6218756 .0578363 10.75 0.000 .5085186 .7352326 LD | -.7256912 .0697654 -10.40 0.000 -.8624288 -.5889536 L2D | .1406718 .0770882 1.82 0.068 -.0104183 .2917618 yr1979 | D1 | .0120152 .0049175 2.44 0.015 .0023771 .0216533 yr1980 | D1 | .0173417 .0064682 2.68 0.007 .0046643 .030019 yr1981 | D1 | -.0194725 .0103902 -1.87 0.061 -.039837 .000892 yr1982 | D1 | -.0249767 .0085142 -2.93 0.003 -.0416643 -.0082891 yr1983 | D1 | -.0115784 .0056689 -2.04 0.041 -.0226892 -.0004677 k | LD | (dropped) _cons | .0046326 .0019755 2.35 0.019 .0007607 .0085045 ------------------------------------------------------------------------------ Warning: Arellano and Bond recommend using one-step results for inference on coefficients Sargan test of over-identifying restrictions: chi2(74) = 151.67 Prob > chi2 = 0.0000 Arellano-Bond test that average autocovariance in residuals of order 1 is 0: H0: no autocorrelation z = -4.05 Pr > z = 0.0001 Arellano-Bond test that average autocovariance in residuals of order 2 is 0: H0: no autocorrelation z = -0.69 Pr > z = 0.4927 . ** predetermined plus contemporaneously correlated with error . . ***************************************** . * More examples by Jing * . ***************************************** . . **** Note: try xt series of commands on "invest2.dta" . . use invest2.dta,clear . * use http://www.stata-press.com/data/r8/invest2, clear . . iis company . tis time . . ** describe pattern of the panel-data . xtdes, patterns(20) company: 1, 2, ..., 5 n = 5 time: 1, 2, ..., 20 T = 20 Delta(time) = 1; (20-1)+1 = 20 (company*time uniquely identifies each observation) Distribution of T_i: min 5% 25% 50% 75% 95% max 20 20 20 20 20 20 20 Freq. Percent Cum. | Pattern ---------------------------+---------------------- 5 100.00 100.00 | 11111111111111111111 ---------------------------+---------------------- 5 100.00 | XXXXXXXXXXXXXXXXXXXX . . ** estimate the model using GLS . * Dep variable = invest . * Regressors = market stock . . xtgls invest market stock, nmk panels(iid) corr(independent) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: homoskedastic Correlation: no autocorrelation Estimated covariances = 1 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 341.63 Log likelihood = -624.9928 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .1050854 .0113778 9.24 0.000 .0827853 .1273855 stock | .3053655 .0435078 7.02 0.000 .2200918 .3906393 _cons | -48.02974 21.48016 -2.24 0.025 -90.13009 -5.929387 ------------------------------------------------------------------------------ . xtgls invest market stock, panels(hetero) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic Correlation: no autocorrelation Estimated covariances = 5 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 865.38 Log likelihood = -570.1305 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0949905 .007409 12.82 0.000 .0804692 .1095118 stock | .3378129 .0302254 11.18 0.000 .2785722 .3970535 _cons | -36.2537 6.124363 -5.92 0.000 -48.25723 -24.25017 ------------------------------------------------------------------------------ . xtgls invest market stock, panels(correlated) corr(ar1) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic with cross-sectional correlation Correlation: common AR(1) coefficient for all panels (0.8651) Estimated covariances = 15 Number of obs = 100 Estimated autocorrelations = 1 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 153.66 Log likelihood = -491.3974 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0745101 .0091391 8.15 0.000 .0565978 .0924225 stock | .3150971 .0447361 7.04 0.000 .2274158 .4027783 _cons | -2.770019 13.78308 -0.20 0.841 -29.78435 24.24431 ------------------------------------------------------------------------------ . xtgls invest market stock, panels(correlated) corr(psar1) Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: heteroskedastic with cross-sectional correlation Correlation: panel-specific AR(1) Estimated covariances = 15 Number of obs = 100 Estimated autocorrelations = 5 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 331.55 Log likelihood = -484.6178 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0820264 .0081381 10.08 0.000 .066076 .0979767 stock | .3800689 .0313874 12.11 0.000 .3185508 .441587 _cons | -11.51848 12.69055 -0.91 0.364 -36.39151 13.35455 ------------------------------------------------------------------------------ . xtgls invest market stock, igls Iteration 1: tolerance = 0 Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: homoskedastic Correlation: no autocorrelation Estimated covariances = 1 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 352.19 Log likelihood = -624.9928 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ invest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .1050854 .0112059 9.38 0.000 .0831223 .1270485 stock | .3053655 .0428502 7.13 0.000 .2213806 .3893504 _cons | -48.02974 21.15551 -2.27 0.023 -89.49377 -6.565701 ------------------------------------------------------------------------------ . gen lninvest = log(invest) /*try GLS with the log-level data*/ . xtgls lninvest market stock Cross-sectional time-series FGLS regression Coefficients: generalized least squares Panels: homoskedastic Correlation: no autocorrelation Estimated covariances = 1 Number of obs = 100 Estimated autocorrelations = 0 Number of groups = 5 Estimated coefficients = 3 Time periods = 20 Wald chi2(2) = 187.10 Log likelihood = -98.45099 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ lninvest | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- market | .0005245 .0000579 9.06 0.000 .0004111 .000638 stock | .0005687 .0002214 2.57 0.010 .0001348 .0010027 _cons | 3.772802 .1093154 34.51 0.000 3.558548 3.987057 ------------------------------------------------------------------------------ . . **** Note: try xt series of commands on "nlswork.dta" . . use nlswork.dta,clear (National Longitudinal Survey. Young Women 14-26 years of age in 1968) . * use http://www.stata-press.com/data/r8/nlswork, clear . . iis idcode . tis year . . ** describe the patterns of the data . xtdes, patterns(30) idcode: 1, 2, ..., 5159 n = 4711 year: 68, 69, ..., 88 T = 15 Delta(year) = 1; (88-68)+1 = 21 (idcode*year uniquely identifies each observation) Distribution of T_i: min 5% 25% 50% 75% 95% max 1 1 3 5 9 13 15 Freq. Percent Cum. | Pattern ---------------------------+----------------------- 136 2.89 2.89 | 1.................... 114 2.42 5.31 | ....................1 89 1.89 7.20 | .................1.11 87 1.85 9.04 | ...................11 86 1.83 10.87 | 111111.1.11.1.11.1.11 61 1.29 12.16 | ..............11.1.11 56 1.19 13.35 | 11................... 54 1.15 14.50 | ...............1.1.11 54 1.15 15.64 | .......1.11.1.11.1.11 49 1.04 16.68 | .........11.1.11.1.11 45 0.96 17.64 | ............1.11.1.11 43 0.91 18.55 | 1111................. 42 0.89 19.44 | ...1................. 40 0.85 20.29 | .....1.1.11.1.11.1.11 38 0.81 21.10 | ....11.1.11.1.11.1.11 38 0.81 21.91 | 111.................. 34 0.72 22.63 | ..1111.1.11.1.11.1.11 31 0.66 23.29 | .................1... 30 0.64 23.92 | ..........1.1.11.1.11 29 0.62 24.54 | ...111.1.11.1.11.1.11 26 0.55 25.09 | .....1............... 25 0.53 25.62 | .........1........... 25 0.53 26.15 | ....1................ 24 0.51 26.66 | .........11.......... 24 0.51 27.17 | .......1............. 24 0.51 27.68 | ..11................. 24 0.51 28.19 | 1.1111.1.11.1.11.1.11 23 0.49 28.68 | ..1.................. 23 0.49 29.17 | .1................... 22 0.47 29.63 | ...................1. 3315 70.37 100.00 | (other patterns) ---------------------------+----------------------- 4711 100.00 | XXXXXX.X.XX.X.XX.X.XX . . ** estimate the model using 'xtreg' . * Dep variable = ln_wage . * Regressors = grade race age ttl_exp tenure not_smsa south . * And the square terms of age ttl_exp tenure are also included . . gen age2 = age^2 (24 missing values generated) . gen ttl_exp2 = ttl_exp^2 . gen tenure2 = tenure^2 (433 missing values generated) . . * between-effects model . xtreg ln_wage grade race age age2 ttl_exp ttl_exp2 tenure tenure2 not_smsa south, be wls Between regression (regression on group means) Number of obs = 28091 Group variable (i): idcode Number of groups = 4697 R-sq: within = 0.1593 Obs per group: min = 1 between = 0.5018 avg = 6.0 overall = 0.3699 max = 15 F(10,4686) = 472.06 sd(u_i + avg(e_i.))= .267491 Prob > F = 0.0000 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- grade | .0615938 .0019066 32.31 0.000 .057856 .0653316 race | -.0579032 .0085327 -6.79 0.000 -.0746313 -.0411751 age | .033438 .0106812 3.13 0.002 .0124978 .0543781 age2 | -.0005933 .000175 -3.39 0.001 -.0009365 -.0002502 ttl_exp | .0134619 .0062239 2.16 0.031 .0012602 .0256637 ttl_exp2 | .0006313 .0003551 1.78 0.076 -.000065 .0013275 tenure | .0640852 .0061642 10.40 0.000 .0520005 .0761699 tenure2 | -.002507 .0004184 -5.99 0.000 -.0033272 -.0016867 not_smsa | -.1892149 .009844 -19.22 0.000 -.2085138 -.1699161 south | -.1090296 .0089459 -12.19 0.000 -.1265678 -.0914914 _cons | .3718248 .1483064 2.51 0.012 .0810744 .6625751 ------------------------------------------------------------------------------ . . * fixed-effects model . xtreg ln_wage grade race age age2 ttl_exp ttl_exp2 tenure tenure2 not_smsa south, fe Fixed-effects (within) regression Number of obs = 28091 Group variable (i): idcode Number of groups = 4697 R-sq: within = 0.1727 Obs per group: min = 1 between = 0.3505 avg = 6.0 overall = 0.2625 max = 15 F(8,23386) = 610.12 corr(u_i, Xb) = 0.1936 Prob > F = 0.0000 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- grade | (dropped) race | (dropped) age | .0359987 .0033864 10.63 0.000 .0293611 .0426362 age2 | -.000723 .0000533 -13.58 0.000 -.0008274 -.0006186 ttl_exp | .0334668 .0029653 11.29 0.000 .0276545 .039279 ttl_exp2 | .0002163 .0001277 1.69 0.090 -.0000341 .0004666 tenure | .0357539 .0018487 19.34 0.000 .0321303 .0393775 tenure2 | -.0019701 .000125 -15.76 0.000 -.0022151 -.0017251 not_smsa | -.0890108 .0095316 -9.34 0.000 -.1076933 -.0703282 south | -.0606309 .0109319 -5.55 0.000 -.0820582 -.0392036 _cons | 1.03732 .0485546 21.36 0.000 .9421497 1.13249 -------------+---------------------------------------------------------------- sigma_u | .35562203 sigma_e | .29068923 rho | .59946283 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(4696, 23386) = 5.15 Prob > F = 0.0000 . . * GLS Random-effects model . xtreg ln_wage grade race age age2 ttl_exp ttl_exp2 tenure tenure2 not_smsa south, re sa theta Random-effects GLS regression Number of obs = 28091 Group variable (i): idcode Number of groups = 4697 R-sq: within = 0.1713 Obs per group: min = 1 between = 0.4776 avg = 6.0 overall = 0.3701 max = 15 Random effects u_i ~ Gaussian Wald chi2(10) = 9547.33 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------- theta -------------------- min 5% median 95% max 0.2290 0.2290 0.5239 0.6817 0.7017 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- grade | .0650577 .001703 38.20 0.000 .0617199 .0683955 race | -.037019 .008768 -4.22 0.000 -.054204 -.0198339 age | .0367606 .0031268 11.76 0.000 .0306322 .042889 age2 | -.0007107 .0000502 -14.17 0.000 -.0008091 -.0006124 ttl_exp | .0286986 .0024081 11.92 0.000 .0239788 .0334184 ttl_exp2 | .0003107 .0001164 2.67 0.008 .0000825 .0005388 tenure | .0395321 .0017627 22.43 0.000 .0360773 .042987 tenure2 | -.0020066 .0001198 -16.75 0.000 -.0022415 -.0017718 not_smsa | -.1322792 .00706 -18.74 0.000 -.1461165 -.1184418 south | -.091354 .0070898 -12.89 0.000 -.1052496 -.0774583 _cons | .2692039 .0505052 5.33 0.000 .1702156 .3681922 -------------+---------------------------------------------------------------- sigma_u | .24012613 sigma_e | .29069544 rho | .4055907 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . estimates store est1 . xtreg ln_wage grade race age ttl_exp tenure not_smsa south, re sa theta Random-effects GLS regression Number of obs = 28091 Group variable (i): idcode Number of groups = 4697 R-sq: within = 0.1482 Obs per group: min = 1 between = 0.4715 avg = 6.0 overall = 0.3594 max = 15 Random effects u_i ~ Gaussian Wald chi2(7) = 8665.99 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------- theta -------------------- min 5% median 95% max 0.2259 0.2259 0.5202 0.6788 0.6989 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- grade | .0681351 .0017067 39.92 0.000 .06479 .0714802 race | -.033362 .0088176 -3.78 0.000 -.0506443 -.0160798 age | -.0038994 .0006448 -6.05 0.000 -.0051632 -.0026355 ttl_exp | .0301476 .0011071 27.23 0.000 .0279777 .0323175 tenure | .013766 .0008443 16.31 0.000 .0121112 .0154207 not_smsa | -.1336814 .0071318 -18.74 0.000 -.1476594 -.1197034 south | -.0901537 .0071553 -12.60 0.000 -.1041779 -.0761294 _cons | .8126875 .0299873 27.10 0.000 .7539135 .8714615 -------------+---------------------------------------------------------------- sigma_u | .24106687 sigma_e | .29478193 rho | .40075434 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . estimates store est2 . hausman est1 est2 ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-V_B)) | est1 est2 Difference S.E. -------------+---------------------------------------------------------------- grade | .0650577 .0681351 -.0030773 . race | -.037019 -.033362 -.0036569 . age | .0367606 -.0038994 .04066 .0030596 ttl_exp | .0286986 .0301476 -.001449 .0021385 tenure | .0395321 .013766 .0257661 .0015474 not_smsa | -.1322792 -.1336814 .0014023 . south | -.091354 -.0901537 -.0012003 . ------------------------------------------------------------------------------ b = consistent under Ho and Ha; obtained from xtreg B = inconsistent under Ha, efficient under Ho; obtained from xtreg Test: Ho: difference in coefficients not systematic chi2(7) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 712.08 Prob>chi2 = 0.0000 . . ** instrumental variable and 2SLS estimation of the data . * GLS Random-effects model . xtivreg ln_wage age* not_smsa race (tenure = union south race), re theta first First-stage G2SLS regression Number of obs = 19007 Wald chi(6) = 4981 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ tenure | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | .1269981 .0348799 3.64 0.000 .0586348 .1953615 age2 | .0023415 .0005575 4.20 0.000 .0012488 .0034343 not_smsa | -.0054901 .0736547 -0.07 0.941 -.1498508 .1388705 race | .2560249 .0761554 3.36 0.001 .1067631 .4052867 union | .9703605 .0647743 14.98 0.000 .8434051 1.097316 south | -.1895135 .0704899 -2.69 0.007 -.3276712 -.0513559 _cons | -3.284679 .5380918 -6.10 0.000 -4.33932 -2.230039 ------------------------------------------------------------------------------ G2SLS random-effects IV regression Number of obs = 19007 Group variable: idcode Number of groups = 4134 R-sq: within = 0.0600 Obs per group: min = 1 between = 0.1844 avg = 4.6 overall = 0.1276 max = 12 Wald chi2(5) = 920.45 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 ------------------- theta -------------------- min 5% median 95% max 0.1327 0.2236 0.4204 0.5349 0.5506 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- tenure | .1906625 .012372 15.41 0.000 .1664138 .2149111 age | .0205974 .0069346 2.97 0.003 .0070058 .034189 age2 | -.0009423 .0001115 -8.45 0.000 -.0011608 -.0007237 not_smsa | -.2179521 .0140743 -15.49 0.000 -.2455372 -.1903671 race | -.1775746 .0147251 -12.06 0.000 -.2064352 -.1487139 _cons | 1.665541 .1114716 14.94 0.000 1.447061 1.884021 -------------+---------------------------------------------------------------- sigma_u | .36174815 sigma_e | .63031479 rho | .24776981 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Instrumented: tenure Instruments: age age2 not_smsa race union south . xtivreg ln_wage age* not_smsa race (tenure = union south race), ec2sls theta small EC2SLS random-effects IV regression Number of obs = 19007 Group variable: idcode Number of groups = 4134 R-sq: within = 0.0906 Obs per group: min = 1 between = 0.2531 avg = 4.6 overall = 0.1864 max = 12 F(5,19002) = 526.05 corr(u_i, X) = 0 Prob > F = 0.0000 ------------------- theta -------------------- min 5% median 95% max 0.1327 0.2236 0.4204 0.5349 0.5506 ------------------------------------------------------------------------------ ln_wage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- tenure | .0635808 .0025507 24.93 0.000 .0585813 .0685804 age | .0377593 .0039602 9.53 0.000 .0299969 .0455218 age2 | -.0006573 .0000633 -10.39 0.000 -.0007813 -.0005333 not_smsa | -.2294651 .0082776 -27.72 0.000 -.2456898 -.2132403 race | -.1438764 .0084876 -16.95 0.000 -.1605129 -.1272399 _cons | 1.248406 .0614707 20.31 0.000 1.127918 1.368894 -------------+---------------------------------------------------------------- sigma_u | .36174815 sigma_e | .63031479 rho | .24776981 (fraction of variance due to u_i) ------------------------------------------------------------------------------ Instrumented: tenure Instruments: age age2 not_smsa race union south . . end of do-file . exit, clear