The data files used for the examples in this text can be downloaded in a zip file from the Stata Web site. You can then use a program such as zip to unzip the data files.
Example 6.1 on page 120 using mroz.dta.
use mroz, clear reg educ exper expersq motheduc fatheduc huseduc if lwage ~=. Source | SS df MS Number of obs = 428 -------------+------------------------------ F( 5, 422) = 63.30 Model | 955.830608 5 191.166122 Prob > F = 0.0000 Residual | 1274.36565 422 3.01982382 R-squared = 0.4286 -------------+------------------------------ Adj R-squared = 0.4218 Total | 2230.19626 427 5.22294206 Root MSE = 1.7378 ------------------------------------------------------------------------------ educ | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exper | .0374977 .0343102 1.09 0.275 -.0299424 .1049379 expersq | -.0006002 .0010261 -0.58 0.559 -.0026171 .0014167 motheduc | .1141532 .0307835 3.71 0.000 .0536452 .1746613 fatheduc | .1060801 .0295153 3.59 0.000 .0480648 .1640955 huseduc | .3752548 .0296347 12.66 0.000 .3170049 .4335048 _cons | 5.538311 .4597824 12.05 0.000 4.634562 6.44206 ------------------------------------------------------------------------------ predict resids, res reg lwage exper expersq educ resids Source | SS df MS Number of obs = 428 -------------+------------------------------ F( 4, 423) = 20.48 Model | 36.2304984 4 9.05762461 Prob > F = 0.0000 Residual | 187.096942 423 .442309557 R-squared = 0.1622 -------------+------------------------------ Adj R-squared = 0.1543 Total | 223.327441 427 .523015084 Root MSE = .66506 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exper | .0430973 .013181 3.27 0.001 .017189 .0690057 expersq | -.0008628 .0003937 -2.19 0.029 -.0016366 -.000089 educ | .0803918 .0216362 3.72 0.000 .0378638 .1229197 resids | .047189 .0285519 1.65 0.099 -.0089322 .1033102 _cons | -.1868572 .2835905 -0.66 0.510 -.7442792 .3705648 ------------------------------------------------------------------------------
Example 6.2 on page 121 using card.dta.
use card, clear gen black_educ=black*educ reg lwage educ black_educ black exper expersq smsa smsa66 south reg661 reg662 reg663 reg664 reg665 /// reg666 reg667 reg668 Source | SS df MS Number of obs = 3010 -------------+------------------------------ F( 16, 2993) = 80.83 Model | 178.817032 16 11.1760645 Prob > F = 0.0000 Residual | 413.824613 2993 .138264154 R-squared = 0.3017 -------------+------------------------------ Adj R-squared = 0.2980 Total | 592.641645 3009 .196956346 Root MSE = .37184 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .0707788 .0037548 18.85 0.000 .0634165 .0781411 black_educ | .0178595 .006271 2.85 0.004 .0055636 .0301554 black | -.4191076 .0794021 -5.28 0.000 -.5747958 -.2634194 exper | .0821556 .0066828 12.29 0.000 .0690522 .0952589 expersq | -.0021349 .0003207 -6.66 0.000 -.0027638 -.001506 smsa | .1340694 .0200931 6.67 0.000 .0946718 .1734671 smsa66 | .0249824 .0194297 1.29 0.199 -.0131144 .0630793 south | -.1441927 .0259827 -5.55 0.000 -.1951384 -.093247 reg661 | -.1221746 .0388047 -3.15 0.002 -.1982611 -.046088 reg662 | -.0232881 .0282266 -0.83 0.409 -.0786336 .0320574 reg663 | .0230953 .0273506 0.84 0.399 -.0305325 .0767231 reg664 | -.0666851 .0356556 -1.87 0.062 -.1365971 .0032268 reg665 | .0032644 .03614 0.09 0.928 -.0675974 .0741261 reg666 | .0151248 .0401224 0.38 0.706 -.0635455 .0937951 reg667 | -.0074966 .0394073 -0.19 0.849 -.0847648 .0697716 reg668 | -.1757195 .0462851 -3.80 0.000 -.2664733 -.0849657 _cons | 4.806769 .0752604 63.87 0.000 4.659202 4.954337 ------------------------------------------------------------------------------ gen black_nearc4 = black*nearc4 reg educ exper expersq black smsa smsa66 south reg661 reg662 reg663 reg664 reg665 reg666 reg667 /// reg668 nearc4 black_nearc4 Source | SS df MS Number of obs = 3010 -------------+------------------------------ F( 16, 2993) = 170.69 Model | 10287.619 16 642.976186 Prob > F = 0.0000 Residual | 11274.4611 2993 3.76694323 R-squared = 0.4771 -------------+------------------------------ Adj R-squared = 0.4743 Total | 21562.0801 3009 7.16586243 Root MSE = 1.9409 ------------------------------------------------------------------------------ educ | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exper | -.4125542 .033728 -12.23 0.000 -.4786866 -.3464218 expersq | .0008699 .0016525 0.53 0.599 -.0023703 .0041101 black | -.9374537 .147931 -6.34 0.000 -1.22751 -.6473969 smsa | .4021227 .104889 3.83 0.000 .1964609 .6077845 smsa66 | .0254418 .1058119 0.24 0.810 -.1820295 .2329132 south | -.0517208 .1356037 -0.38 0.703 -.3176067 .2141651 reg661 | -.2102379 .2025002 -1.04 0.299 -.6072915 .1868158 reg662 | -.2888672 .1473834 -1.96 0.050 -.5778502 .0001158 reg663 | -.2382962 .1427517 -1.67 0.095 -.5181975 .0416051 reg664 | -.0932447 .1862439 -0.50 0.617 -.4584237 .2719343 reg665 | -.4828321 .1882474 -2.56 0.010 -.8519394 -.1137248 reg666 | -.5129027 .2099523 -2.44 0.015 -.924568 -.1012373 reg667 | -.427108 .2056584 -2.08 0.038 -.8303541 -.023862 reg668 | .3135707 .2417323 1.30 0.195 -.1604075 .787549 nearc4 | .3191761 .0978211 3.26 0.001 .1273727 .5109796 black_nearc4 | .0029741 .1767953 0.02 0.987 -.3436786 .3496267 _cons | 16.8492 .2149486 78.39 0.000 16.42774 17.27066 ------------------------------------------------------------------------------ predict er, res reg black_educ exper expersq black smsa smsa66 south reg661 reg662 reg663 reg664 reg665 reg666 reg667 /// reg668 nearc4 black_nearc4 Source | SS df MS Number of obs = 3010 -------------+------------------------------ F( 16, 2993) = 3680.14 Model | 77916.1435 16 4869.75897 Prob > F = 0.0000 Residual | 3960.4957 2993 1.32325282 R-squared = 0.9516 -------------+------------------------------ Adj R-squared = 0.9514 Total | 81876.6392 3009 27.2105813 Root MSE = 1.1503 ------------------------------------------------------------------------------ black_educ | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exper | .0533248 .0199902 2.67 0.008 .0141289 .0925207 expersq | -.007937 .0009794 -8.10 0.000 -.0098574 -.0060166 black | 11.5499 .0876771 131.73 0.000 11.37799 11.72182 smsa | .1952868 .0621665 3.14 0.002 .0733934 .3171803 smsa66 | .0469365 .0627135 0.75 0.454 -.0760295 .1699024 south | -.252799 .0803708 -3.15 0.002 -.4103867 -.0952114 reg661 | .162124 .1200196 1.35 0.177 -.0732053 .3974534 reg662 | .0056958 .0873525 0.07 0.948 -.1655812 .1769729 reg663 | .0860648 .0846073 1.02 0.309 -.0798296 .2519592 reg664 | .113297 .1103847 1.03 0.305 -.1031406 .3297345 reg665 | .2615297 .1115721 2.34 0.019 .0427639 .4802955 reg666 | .3347247 .1244364 2.69 0.007 .0907352 .5787143 reg667 | .2962538 .1218915 2.43 0.015 .0572543 .5352533 reg668 | .0995837 .1432721 0.70 0.487 -.181338 .3805054 nearc4 | -.0908895 .0579775 -1.57 0.117 -.2045693 .0227903 black_nearc4 | .874705 .1047846 8.35 0.000 .6692478 1.080162 _cons | .0948535 .1273977 0.74 0.457 -.1549425 .3446494 ------------------------------------------------------------------------------ predict br, res reg lwage educ black_educ black exper expersq smsa smsa66 south reg661 reg662 reg663 reg664 reg665 /// reg666 reg667 reg668 er br Source | SS df MS Number of obs = 3010 -------------+------------------------------ F( 18, 2991) = 71.89 Model | 178.967086 18 9.94261591 Prob > F = 0.0000 Residual | 413.674558 2991 .138306439 R-squared = 0.3020 -------------+------------------------------ Adj R-squared = 0.2978 Total | 592.641645 3009 .196956346 Root MSE = .3719 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .1273557 .0547317 2.33 0.020 .0200401 .2346713 black_educ | .0109036 .0387795 0.28 0.779 -.0651337 .0869408 black | -.282765 .4866264 -0.58 0.561 -1.236921 .6713913 exper | .1059116 .0241963 4.38 0.000 .0584685 .1533547 expersq | -.0022406 .0004635 -4.83 0.000 -.0031493 -.0013318 smsa | .1111555 .0304028 3.66 0.000 .051543 .170768 smsa66 | .0180009 .0207769 0.87 0.386 -.0227374 .0587393 south | -.1424762 .0272675 -5.23 0.000 -.1959412 -.0890112 reg661 | -.1103479 .0410557 -2.69 0.007 -.1908481 -.0298477 reg662 | -.0081783 .0317789 -0.26 0.797 -.070489 .0541325 reg663 | .0382414 .0314436 1.22 0.224 -.0234119 .0998946 reg664 | -.0600379 .0368007 -1.63 0.103 -.1321951 .0121193 reg665 | .0337805 .0479745 0.70 0.481 -.060286 .1278469 reg666 | .0498975 .0537534 0.93 0.353 -.0554998 .1552948 reg667 | .0216942 .0501526 0.43 0.665 -.0766428 .1200312 reg668 | -.1908353 .0485659 -3.93 0.000 -.2860613 -.0956093 er | -.0568274 .0548612 -1.04 0.300 -.164397 .0507422 br | .0070106 .0392971 0.18 0.858 -.0700415 .0840627 _cons | 3.84499 .9314527 4.13 0.000 2.018637 5.671342 ------------------------------------------------------------------------------ test er br ( 1) er = 0 ( 2) br = 0 F( 2, 2991) = 0.54 Prob > F = 0.5814 ivreg lwage (educ black_educ = nearc4 black_nearc4 ) black exper expersq smsa smsa66 south reg661 /// reg662 reg663 reg664 reg665 reg666 reg667 reg668 Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 3010 -------------+------------------------------ F( 16, 2993) = 48.15 Model | 144.325528 16 9.02034548 Prob > F = 0.0000 Residual | 448.316117 2993 .149788212 R-squared = 0.2435 -------------+------------------------------ Adj R-squared = 0.2395 Total | 592.641645 3009 .196956346 Root MSE = .38702 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .1273557 .0569582 2.24 0.025 .0156744 .2390369 black_educ | .0109036 .0403571 0.27 0.787 -.0682269 .0900341 black | -.282765 .5064228 -0.56 0.577 -1.275737 .710207 exper | .1059116 .0251806 4.21 0.000 .0565385 .1552847 expersq | -.0022406 .0004823 -4.65 0.000 -.0031863 -.0012949 smsa | .1111555 .0316396 3.51 0.000 .049118 .1731931 smsa66 | .0180009 .0216221 0.83 0.405 -.0243947 .0603966 south | -.1424762 .0283768 -5.02 0.000 -.1981162 -.0868362 reg661 | -.1103479 .0427259 -2.58 0.010 -.1941229 -.0265729 reg662 | -.0081783 .0330717 -0.25 0.805 -.0730239 .0566673 reg663 | .0382413 .0327227 1.17 0.243 -.02592 .1024027 reg664 | -.0600379 .0382978 -1.57 0.117 -.1351305 .0150547 reg665 | .0337805 .0499262 0.68 0.499 -.0641126 .1316736 reg666 | .0498975 .0559401 0.89 0.372 -.0597874 .1595825 reg667 | .0216942 .0521928 0.42 0.678 -.0806432 .1240317 reg668 | -.1908353 .0505417 -3.78 0.000 -.2899352 -.0917354 _cons | 3.84499 .9693451 3.97 0.000 1.94434 5.74564 ------------------------------------------------------------------------------ Instrumented: educ black_educ Instruments: black exper expersq smsa smsa66 south reg661 reg662 reg663 reg664 reg665 reg666 reg667 reg668 nearc4 black_nearc4 ------------------------------------------------------------------------------
Example 6.3 on page 123 using mroz.dta.
use mroz, clear ivreg2 lwage exper expersq (educ= motheduc fatheduc huseduc) Instrumental variables (2SLS) regression ---------------------------------------- Number of obs = 428 F( 3, 424) = 11.52 Prob > F = 0.0000 Total (centered) SS = 223.3274409 Centered R2 = 0.1495 Total (uncentered) SS = 829.5947861 Uncentered R2 = 0.7711 Residual SS = 189.9347041 Root MSE = .67 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .0803918 .021672 3.71 0.000 .0379155 .1228681 exper | .0430973 .0132027 3.26 0.001 .0172204 .0689742 expersq | -.0008628 .0003943 -2.19 0.029 -.0016357 -.0000899 _cons | -.1868572 .2840591 -0.66 0.511 -.7436029 .3698885 ------------------------------------------------------------------------------ Sargan statistic (overidentification test of all instruments): 1.115 Chi-sq(2) P-val = 0.57263 ------------------------------------------------------------------------------ Instrumented: educ Instruments: motheduc fatheduc huseduc exper expersq ------------------------------------------------------------------------------ ivreg2 lwage exper expersq (educ= motheduc fatheduc huseduc) , robust IV (2SLS) regression with robust standard errors ------------------------------------------------ Number of obs = 428 F( 3, 424) = 9.19 Prob > F = 0.0000 Total (centered) SS = 223.3274409 Centered R2 = 0.1495 Total (uncentered) SS = 829.5947861 Uncentered R2 = 0.7711 Residual SS = 189.9347041 Root MSE = .67 ------------------------------------------------------------------------------ | Robust lwage | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .0803918 .0216016 3.72 0.000 .0380533 .1227302 exper | .0430973 .0152347 2.83 0.005 .0132378 .0729568 expersq | -.0008628 .0004197 -2.06 0.040 -.0016854 -.0000402 _cons | -.1868572 .2998514 -0.62 0.533 -.7745552 .4008408 ------------------------------------------------------------------------------ Hansen J statistic (overidentification test of all instruments): 1.042 Chi-sq(2) P-val = 0.59389 ------------------------------------------------------------------------------ Instrumented: educ Instruments: motheduc fatheduc huseduc exper expersq ------------------------------------------------------------------------------
Example 6.4 on page 125 using nls80.dta.
use nls80, clear reg lwage exper tenure married south urban black educ Source | SS df MS Number of obs = 935 -------------+------------------------------ F( 7, 927) = 44.75 Model | 41.8377619 7 5.97682312 Prob > F = 0.0000 Residual | 123.818521 927 .133569063 R-squared = 0.2526 -------------+------------------------------ Adj R-squared = 0.2469 Total | 165.656283 934 .177362188 Root MSE = .36547 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exper | .014043 .0031852 4.41 0.000 .007792 .020294 tenure | .0117473 .002453 4.79 0.000 .0069333 .0165613 married | .1994171 .0390502 5.11 0.000 .1227801 .276054 south | -.0909036 .0262485 -3.46 0.001 -.142417 -.0393903 urban | .1839121 .0269583 6.82 0.000 .1310056 .2368185 black | -.1883499 .0376666 -5.00 0.000 -.2622717 -.1144281 educ | .0654307 .0062504 10.47 0.000 .0531642 .0776973 _cons | 5.395497 .113225 47.65 0.000 5.17329 5.617704 ------------------------------------------------------------------------------ predict resid, res predict yhat (option xb assumed; fitted values) gen y2=yhat^2 gen y3=yhat^3 gen y4=yhat^4 reg resid exper tenure married south urban black educ y2 y3 Source | SS df MS Number of obs = 935 -------------+------------------------------ F( 9, 925) = 0.04 Model | .043635869 9 .00484843 Prob > F = 1.0000 Residual | 123.774885 925 .133810687 R-squared = 0.0004 -------------+------------------------------ Adj R-squared = -0.0094 Total | 123.818521 934 .13256801 Root MSE = .3658 ------------------------------------------------------------------------------ resid | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exper | -.7632267 1.397385 -0.55 0.585 -3.50564 1.979186 tenure | -.6384821 1.169016 -0.55 0.585 -2.932712 1.655748 married | -10.83869 19.8426 -0.55 0.585 -49.78042 28.10305 south | 4.941136 9.046332 0.55 0.585 -12.81258 22.69485 urban | -9.997095 18.30255 -0.55 0.585 -45.91644 25.92225 black | 10.23873 18.74209 0.55 0.585 -26.54323 47.02068 educ | -3.555951 6.510939 -0.55 0.585 -16.33388 9.221973 y2 | 8.092523 14.74836 0.55 0.583 -20.85161 37.03666 y3 | -.4012701 .7281559 -0.55 0.582 -1.830299 1.027759 _cons | -171.6899 313.2923 -0.55 0.584 -786.5359 443.1561 ------------------------------------------------------------------------------ di 935*.0004 .374 di chi2tail(2, .374) .82944374
Example 6.5 on page 131 using injury.dta.
use injury, clear gen afchnge_highearn = afchnge*highearn reg ldurat afchnge highearn afchnge_highearn if ky==1 Source | SS df MS Number of obs = 5626 -------------+------------------------------ F( 3, 5622) = 39.54 Model | 191.071442 3 63.6904807 Prob > F = 0.0000 Residual | 9055.9345 5622 1.61080301 R-squared = 0.0207 -------------+------------------------------ Adj R-squared = 0.0201 Total | 9247.00594 5625 1.64391217 Root MSE = 1.2692 ------------------------------------------------------------------------------ ldurat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- afchnge | .0076573 .0447173 0.17 0.864 -.0800058 .0953204 highearn | .2564785 .0474464 5.41 0.000 .1634652 .3494918 afchnge_hi~n | .1906012 .0685089 2.78 0.005 .0562973 .3249051 _cons | 1.125615 .0307368 36.62 0.000 1.065359 1.185871 ------------------------------------------------------------------------------