Chapter 15 Instrumental Variable - Examples
-------------------------------------------------------------------------------------
name: SN
log: ~Wooldridge\intro-econx\iexample15.smcl
log type: smcl
opened on: 17 Jan 2019, 16:10:54
. **********************************************
. * Solomon Negash - Replicating Examples
. * Wooldridge (2016). Introductory Econometrics: A Modern Approach. 6th ed.
. * STATA Program, version 15.1.
. * CHAPTER 15 Instrumental Variables Estimation and Two Stage Least Squares
. * Computer Exercises (Examples)
. ******************** SETUP *********************
. *Example 15.1. Estimating the Return to Education for Married Women
. u mroz, clear
. reg lwage educ
Source | SS df MS Number of obs = 428
-------------+---------------------------------- F(1, 426) = 56.93
Model | 26.3264193 1 26.3264193 Prob > F = 0.0000
Residual | 197.001022 426 .462443713 R-squared = 0.1179
-------------+---------------------------------- Adj R-squared = 0.1158
Total | 223.327441 427 .523015084 Root MSE = .68003
------------------------------------------------------------------------------
lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | .1086487 .0143998 7.55 0.000 .0803451 .1369523
_cons | -.1851968 .1852259 -1.00 0.318 -.5492673 .1788736
------------------------------------------------------------------------------
. reg educ fathedu
Source | SS df MS Number of obs = 753
-------------+---------------------------------- F(1, 751) = 182.81
Model | 765.465719 1 765.465719 Prob > F = 0.0000
Residual | 3144.57412 751 4.18718259 R-squared = 0.1958
-------------+---------------------------------- Adj R-squared = 0.1947
Total | 3910.03984 752 5.19952106 Root MSE = 2.0463
------------------------------------------------------------------------------
educ | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
fatheduc | .2824277 .0208884 13.52 0.000 .2414211 .3234343
_cons | 9.799013 .1985373 49.36 0.000 9.409259 10.18877
------------------------------------------------------------------------------
. ivreg lwage (educ=fathedu)
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 428
-------------+---------------------------------- F(1, 426) = 2.84
Model | 20.8673606 1 20.8673606 Prob > F = 0.0929
Residual | 202.46008 426 .475258404 R-squared = 0.0934
-------------+---------------------------------- Adj R-squared = 0.0913
Total | 223.327441 427 .523015084 Root MSE = .68939
------------------------------------------------------------------------------
lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | .0591735 .0351418 1.68 0.093 -.0098994 .1282463
_cons | .4411034 .4461018 0.99 0.323 -.4357312 1.317938
------------------------------------------------------------------------------
Instrumented: educ
Instruments: fatheduc
------------------------------------------------------------------------------
. *Example 15.2. Estimating the Return to Education for Men
. u wage2, clear
. reg educ sibs
Source | SS df MS Number of obs = 935
-------------+---------------------------------- F(1, 933) = 56.67
Model | 258.055048 1 258.055048 Prob > F = 0.0000
Residual | 4248.7642 933 4.55387374 R-squared = 0.0573
-------------+---------------------------------- Adj R-squared = 0.0562
Total | 4506.81925 934 4.82528828 Root MSE = 2.134
------------------------------------------------------------------------------
educ | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
sibs | -.2279164 .0302768 -7.53 0.000 -.287335 -.1684979
_cons | 14.13879 .1131382 124.97 0.000 13.91676 14.36083
------------------------------------------------------------------------------
. ivreg lwage (educ=sibs)
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 935
-------------+---------------------------------- F(1, 933) = 21.59
Model | -1.51973315 1 -1.51973315 Prob > F = 0.0000
Residual | 167.176016 933 .179181154 R-squared = .
-------------+---------------------------------- Adj R-squared = .
Total | 165.656283 934 .177362188 Root MSE = .4233
------------------------------------------------------------------------------
lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | .1224326 .0263506 4.65 0.000 .0707194 .1741459
_cons | 5.130026 .3551712 14.44 0.000 4.432999 5.827053
------------------------------------------------------------------------------
Instrumented: educ
Instruments: sibs
------------------------------------------------------------------------------
. reg lwage edu, nohead
------------------------------------------------------------------------------
lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | .0598392 .0059631 10.03 0.000 .0481366 .0715418
_cons | 5.973063 .0813737 73.40 0.000 5.813366 6.132759
------------------------------------------------------------------------------
. *Example 15.3. Estimating the Effect of Smoking on Birth Weight
. u bwght, clear
. reg packs cigprice
Source | SS df MS Number of obs = 1,388
-------------+---------------------------------- F(1, 1386) = 0.13
Model | .011648626 1 .011648626 Prob > F = 0.7179
Residual | 123.684481 1,386 .089238442 R-squared = 0.0001
-------------+---------------------------------- Adj R-squared = -0.0006
Total | 123.696129 1,387 .089182501 Root MSE = .29873
------------------------------------------------------------------------------
packs | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cigprice | .0002829 .000783 0.36 0.718 -.0012531 .0018188
_cons | .0674257 .1025384 0.66 0.511 -.1337215 .2685728
------------------------------------------------------------------------------
. ivreg lbwght (packs=cigprice)
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 1,388
-------------+---------------------------------- F(1, 1386) = 0.12
Model | -1171.28207 1 -1171.28207 Prob > F = 0.7312
Residual | 1221.70241 1,386 .881459168 R-squared = .
-------------+---------------------------------- Adj R-squared = .
Total | 50.4203336 1,387 .036352079 Root MSE = .93886
------------------------------------------------------------------------------
lbwght | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
packs | 2.988676 8.698888 0.34 0.731 -14.07573 20.05309
_cons | 4.448136 .9081552 4.90 0.000 2.666629 6.229644
------------------------------------------------------------------------------
Instrumented: packs
Instruments: cigprice
------------------------------------------------------------------------------
. *Example 15.4. Using College Proximity as an IV for Education
. u card, clear
. qui reg educ nearc4 exper expersq black smsa south smsa66 reg6*
. display "Constant = " _[_cons] ", b1 = " _b[nearc4] ", b2 = " _b[exper]
Constant = 1, b1 = .31989894, b2 = -.41253338
. eststo OLS: qui reg lwage educ exper* black smsa south smsa66 reg6*
. eststo IV: qui ivreg lwage (educ=nearc4) exper* black smsa south smsa66 reg6*
. estout, cells(b(nostar fmt(3)) se(par fmt(3))) stats(r2 N, fmt(%9.3f %9.0g) labels(
> R-squared Observations)) varlabels(_cons constant) varwidth(20) ti("Table 15.1 Depe
> ndent Variable: (lwage)")
Table 15.1 Dependent Variable: (lwage)
----------------------------------------------
OLS IV
b/se b/se
----------------------------------------------
educ 0.075 0.132
(0.003) (0.055)
exper 0.085 0.108
(0.007) (0.024)
expersq -0.002 -0.002
(0.000) (0.000)
black -0.199 -0.147
(0.018) (0.054)
smsa 0.136 0.112
(0.020) (0.032)
south -0.148 -0.145
(0.026) (0.027)
smsa66 0.026 0.019
(0.019) (0.022)
reg661 0.056 0.083
(0.051) (0.059)
reg662 0.153 0.184
(0.044) (0.055)
reg663 0.201 0.231
(0.043) (0.054)
reg664 0.112 0.133
(0.049) (0.055)
reg665 0.184 0.229
(0.049) (0.067)
reg666 0.197 0.246
(0.052) (0.072)
reg667 0.174 0.218
(0.052) (0.068)
reg668 0.000 0.000
(.) (.)
reg669 0.175 0.191
(0.046) (0.051)
constant 4.564 3.583
(0.079) (0.951)
----------------------------------------------
R-squared 0.300 0.238
Observations 3010 3010
----------------------------------------------
. est clear
. *Example 15.5. Return to Education for Working Women
. u mroz, clear
. qui reg educ exper* fatheduc motheduc
. test fatheduc motheduc
( 1) fatheduc = 0
( 2) motheduc = 0
F( 2, 748) = 124.76
Prob > F = 0.0000
. ivreg lwage (educ=fatheduc motheduc) exper*
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 428
-------------+---------------------------------- F(3, 424) = 8.14
Model | 30.3074256 3 10.1024752 Prob > F = 0.0000
Residual | 193.020015 424 .455235885 R-squared = 0.1357
-------------+---------------------------------- Adj R-squared = 0.1296
Total | 223.327441 427 .523015084 Root MSE = .67471
------------------------------------------------------------------------------
lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | .0613966 .0314367 1.95 0.051 -.0003945 .1231878
exper | .0441704 .0134325 3.29 0.001 .0177679 .0705729
expersq | -.000899 .0004017 -2.24 0.026 -.0016885 -.0001094
_cons | .0481003 .4003281 0.12 0.904 -.7387744 .834975
------------------------------------------------------------------------------
Instrumented: educ
Instruments: exper expersq fatheduc motheduc
------------------------------------------------------------------------------
. qui reg lwage educ exper*
. display "b1 = " _b[educ]
b1 = .10748964
. *Example 15.6. Using Two Test Scores as Indicators of Ability
. u wage2, clear
. ivreg lwage educ exper tenure married south urban black (IQ=KWW)
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 935
-------------+---------------------------------- F(8, 926) = 36.96
Model | 31.4665121 8 3.93331401 Prob > F = 0.0000
Residual | 134.189771 926 .14491336 R-squared = 0.1900
-------------+---------------------------------- Adj R-squared = 0.1830
Total | 165.656283 934 .177362188 Root MSE = .38067
------------------------------------------------------------------------------
lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
IQ | .0130473 .0049341 2.64 0.008 .0033641 .0227305
educ | .0250321 .0166068 1.51 0.132 -.0075591 .0576234
exper | .01442 .0033208 4.34 0.000 .0079029 .0209371
tenure | .0104562 .0026012 4.02 0.000 .0053512 .0155612
married | .2006903 .0406775 4.93 0.000 .1208595 .2805211
south | -.0515532 .0311279 -1.66 0.098 -.1126426 .0095361
urban | .1767058 .0282117 6.26 0.000 .1213394 .2320722
black | -.0225612 .0739597 -0.31 0.760 -.1677093 .1225869
_cons | 4.592453 .3257807 14.10 0.000 3.953099 5.231807
------------------------------------------------------------------------------
Instrumented: IQ
Instruments: educ exper tenure married south urban black KWW
------------------------------------------------------------------------------
. *Example 15.7. Return to Education for Working Women
. u mroz, clear
. qui reg educ exper* fatheduc motheduc if inlf==1
. predict v2, res
. ivreg lwage (educ=fatheduc motheduc) exper* v2
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 428
-------------+---------------------------------- F(4, 423) = 20.50
Model | 36.2573098 4 9.06432745 Prob > F = 0.0000
Residual | 187.070131 423 .442246173 R-squared = 0.1624
-------------+---------------------------------- Adj R-squared = 0.1544
Total | 223.327441 427 .523015084 Root MSE = .66502
------------------------------------------------------------------------------
lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | .0613966 .0309849 1.98 0.048 .000493 .1223003
exper | .0441704 .0132394 3.34 0.001 .0181471 .0701937
expersq | -.000899 .0003959 -2.27 0.024 -.0016772 -.0001208
v2 | .0581666 .0348073 1.67 0.095 -.0102502 .1265834
_cons | .0481003 .3945753 0.12 0.903 -.7274721 .8236727
------------------------------------------------------------------------------
Instrumented: educ
Instruments: exper expersq v2 fatheduc motheduc
------------------------------------------------------------------------------
. qui reg lwage educ exper*
. display "The OLS estimate is " _b[educ] " (" _se[educ] ")"
The OLS estimate is .10748964 (.01414648)
. *Example 15.8. Return to Education for Working Women
. u mroz, clear
. qui ivreg lwage (educ=fatheduc motheduc) exper*
. predict u1, res
(325 missing values generated)
. reg u1 exper* fatheduc motheduc
Source | SS df MS Number of obs = 428
-------------+---------------------------------- F(4, 423) = 0.09
Model | .170503136 4 .042625784 Prob > F = 0.9845
Residual | 192.84951 423 .455909007 R-squared = 0.0009
-------------+---------------------------------- Adj R-squared = -0.0086
Total | 193.020013 427 .452037502 Root MSE = .67521
------------------------------------------------------------------------------
u1 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper | -.0000183 .0133291 -0.00 0.999 -.0262179 .0261813
expersq | 7.34e-07 .0003985 0.00 0.999 -.0007825 .000784
fatheduc | .0057823 .0111786 0.52 0.605 -.0161902 .0277547
motheduc | -.0066065 .0118864 -0.56 0.579 -.0299704 .0167573
_cons | .0109641 .1412571 0.08 0.938 -.2666892 .2886173
------------------------------------------------------------------------------
. display "N*Rsquared =" e(r2)*e(N)
N*Rsquared =.37807138
. qui ivreg lwage (educ=fatheduc motheduc huseduc) exper*
. predict u1_h, res
(325 missing values generated)
. qui reg u1_h exper* fatheduc motheduc huseduc
. display "N*Rsquared =" e(r2)*e(N)
N*Rsquared =1.115043
. qui ivreg lwage (educ=fatheduc motheduc huseduc) exper*
. display "The IV estimate using all three instruments is " _b[educ] " (" _se[educ] ")"
The IV estimate using all three instruments is .08039176 (.02177397)
. qui ivreg lwage (educ=fatheduc motheduc) exper*
. display "The IV estimate using two instruments is " _b[educ] " (" _se[educ] ")"
The IV estimate using two instruments is .06139663 (.0314367)
. *Example 15.9. Effect of Education on Fertility
. u fertil1, clear
. ivreg kids (educ=meduc feduc) age agesq black-y84
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 1,129
-------------+---------------------------------- F(17, 1111) = 7.72
Model | 395.36632 17 23.2568424 Prob > F = 0.0000
Residual | 2690.14298 1,111 2.42137082 R-squared = 0.1281
-------------+---------------------------------- Adj R-squared = 0.1148
Total | 3085.5093 1,128 2.73538059 Root MSE = 1.5561
------------------------------------------------------------------------------
kids | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | -.1527395 .0392232 -3.89 0.000 -.2296993 -.0757796
age | .5235536 .1390348 3.77 0.000 .2507532 .796354
agesq | -.005716 .0015705 -3.64 0.000 -.0087976 -.0026345
black | 1.072952 .1737155 6.18 0.000 .732105 1.4138
east | .2285554 .1338537 1.71 0.088 -.0340792 .4911901
northcen | .3744188 .122061 3.07 0.002 .1349228 .6139148
west | .2076398 .1676568 1.24 0.216 -.1213199 .5365995
farm | -.0770015 .1513718 -0.51 0.611 -.3740083 .2200053
othrural | -.1952451 .181551 -1.08 0.282 -.5514666 .1609764
town | .08181 .1246821 0.66 0.512 -.162829 .3264489
smcity | .2124996 .160425 1.32 0.186 -.1022706 .5272698
y74 | .2721292 .172944 1.57 0.116 -.0672045 .6114629
y76 | -.0945483 .1792324 -0.53 0.598 -.4462205 .2571239
y78 | -.0572543 .1825536 -0.31 0.754 -.415443 .3009343
y80 | -.053248 .1847175 -0.29 0.773 -.4156825 .3091865
y82 | -.4962149 .1765888 -2.81 0.005 -.8427 -.1497297
y84 | -.5213604 .1779205 -2.93 0.003 -.8704586 -.1722623
_cons | -7.241244 3.136642 -2.31 0.021 -13.39565 -1.086834
------------------------------------------------------------------------------
Instrumented: educ
Instruments: age agesq black east northcen west farm othrural town smcity
y74 y76 y78 y80 y82 y84 meduc feduc
------------------------------------------------------------------------------
. qui reg kids educ age agesq black-y84
. display "The OLS estimate is " _b[educ] " (" _se[educ] ")"
The OLS estimate is -.12842683 (.0183486)
. //Endogeneity
. reg educ meduc feduc
Source | SS df MS Number of obs = 1,129
-------------+---------------------------------- F(2, 1126) = 207.06
Model | 2114.27432 2 1057.13716 Prob > F = 0.0000
Residual | 5748.84171 1,126 5.10554326 R-squared = 0.2689
-------------+---------------------------------- Adj R-squared = 0.2676
Total | 7863.11603 1,128 6.97084755 Root MSE = 2.2595
------------------------------------------------------------------------------
educ | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
meduc | .1844065 .021749 8.48 0.000 .1417333 .2270796
feduc | .2208784 .024996 8.84 0.000 .1718344 .2699225
_cons | 8.860898 .2034806 43.55 0.000 8.461654 9.260142
------------------------------------------------------------------------------
. predict v2, res
. ivreg kids (educ=meduc feduc) age agesq black-y84 v2
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 1,129
-------------+---------------------------------- F(18, 1110) = 9.21
Model | 400.801638 18 22.2667576 Prob > F = 0.0000
Residual | 2684.70766 1,110 2.41865555 R-squared = 0.1299
-------------+---------------------------------- Adj R-squared = 0.1158
Total | 3085.5093 1,128 2.73538059 Root MSE = 1.5552
------------------------------------------------------------------------------
kids | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ | -.1507639 .0367462 -4.10 0.000 -.2228636 -.0786641
age | .5305436 .1384365 3.83 0.000 .2589168 .8021704
agesq | -.005796 .0015647 -3.70 0.000 -.0088661 -.0027259
black | 1.061535 .1747383 6.07 0.000 .7186803 1.40439
east | .2208112 .1329111 1.66 0.097 -.0399742 .4815965
northcen | .3715649 .1215229 3.06 0.002 .1331244 .6100054
west | .2044791 .1672389 1.22 0.222 -.1236609 .532619
farm | -.0651969 .1483216 -0.44 0.660 -.3562192 .2258255
othrural | -.1777856 .1767678 -1.01 0.315 -.5246223 .1690511
town | .0798824 .1247224 0.64 0.522 -.1648358 .3246006
smcity | .2099867 .1603553 1.31 0.191 -.104647 .5246204
y74 | .2719416 .1728386 1.57 0.116 -.0671855 .6110688
y76 | -.0984073 .1790925 -0.55 0.583 -.4498053 .2529906
y78 | -.0637286 .1818614 -0.35 0.726 -.4205596 .2931023
y80 | -.0651716 .1830214 -0.36 0.722 -.4242785 .2939352
y82 | -.5143435 .1728653 -2.98 0.003 -.8535231 -.1751638
y84 | -.534601 .1752043 -3.05 0.002 -.87837 -.190832
v2 | .0291597 .0415585 0.70 0.483 -.0523823 .1107017
_cons | -7.407479 3.089573 -2.40 0.017 -13.46954 -1.345417
------------------------------------------------------------------------------
Instrumented: educ
Instruments: age agesq black east northcen west farm othrural town smcity
y74 y76 y78 y80 y82 y84 v2 meduc feduc
------------------------------------------------------------------------------
. display "The OLS estimate is " _b[v2] " (" _b[v2]/_se[v2] ")"
The OLS estimate is .02915968 (.70165427)
. *Example 15.10. Job Training and Worker Productivity
. u jtrain, clear
. reg chrsemp cgrant if year==1988
Source | SS df MS Number of obs = 125
-------------+---------------------------------- F(1, 123) = 79.37
Model | 18117.5987 1 18117.5987 Prob > F = 0.0000
Residual | 28077.3319 123 228.270991 R-squared = 0.3922
-------------+---------------------------------- Adj R-squared = 0.3873
Total | 46194.9306 124 372.539763 Root MSE = 15.109
------------------------------------------------------------------------------
chrsemp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cgrant | 27.87793 3.129216 8.91 0.000 21.68384 34.07202
_cons | .5093234 1.558337 0.33 0.744 -2.57531 3.593956
------------------------------------------------------------------------------
. ivreg clscrap (chrsemp = cgrant) if year==1988
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 45
-------------+---------------------------------- F(1, 43) = 3.20
Model | .274951237 1 .274951237 Prob > F = 0.0808
Residual | 17.0148885 43 .395695081 R-squared = 0.0159
-------------+---------------------------------- Adj R-squared = -0.0070
Total | 17.2898397 44 .392950903 Root MSE = .62904
------------------------------------------------------------------------------
clscrap | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
chrsemp | -.0141532 .0079147 -1.79 0.081 -.0301148 .0018084
_cons | -.0326684 .1269512 -0.26 0.798 -.2886898 .223353
------------------------------------------------------------------------------
Instrumented: chrsemp
Instruments: cgrant
------------------------------------------------------------------------------
. ivreg clscrap chrsemp if year==1988
Instrumental variables (2SLS) regression
Source | SS df MS Number of obs = 45
-------------+---------------------------------- F(1, 43) = 2.84
Model | 1.07071245 1 1.07071245 Prob > F = 0.0993
Residual | 16.2191273 43 .377189007 R-squared = 0.0619
-------------+---------------------------------- Adj R-squared = 0.0401
Total | 17.2898397 44 .392950903 Root MSE = .61416
------------------------------------------------------------------------------
clscrap | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
chrsemp | -.0076007 .0045112 -1.68 0.099 -.0166984 .0014971
_cons | -.1035161 .103736 -1.00 0.324 -.3127197 .1056875
------------------------------------------------------------------------------
(no endogenous regressors)
------------------------------------------------------------------------------
. log close
name: SN
log: ~Wooldridge\intro-econx\iexample15.smcl
log type: smcl
closed on: 17 Jan 2019, 16:10:56
-------------------------------------------------------------------------------------