Вы находитесь на странице: 1из 5

name: <unnamed>

log: S:\ECO311\IV_Endogeneity_MrozData.smcl
log type: smcl
opened on: 17 Feb 2014, 16:53:04

. *// Using MROZ.DTA, IV regression and Testing for Exogeneity of Instruments

. reg lwage educ exper expersq

Source SS df MS Number of obs = 428


F( 3, 424) = 26.29
Model 35.0222967 3 11.6740989 Prob > F = 0.0000
Residual 188.305144 424 .444115906 R-squared = 0.1568
Adj R-squared = 0.1509
Total 223.327441 427 .523015084 Root MSE = .66642

lwage Coef. Std. Err. t P>|t| [95% Conf. Interval]

educ .1074896 .0141465 7.60 0.000 .0796837 .1352956


exper .0415665 .0131752 3.15 0.002 .0156697 .0674633
expersq -.0008112 .0003932 -2.06 0.040 -.0015841 -.0000382
_cons -.5220406 .1986321 -2.63 0.009 -.9124667 -.1316144

. ivregress 2sls lwage exper expersq (educ= motheduc fatheduc)

Instrumental variables (2SLS) regression Number of obs = 428


Wald chi2(3) = 24.65
Prob > chi2 = 0.0000
R-squared = 0.1357
Root MSE = .67155

lwage Coef. Std. Err. z P>|z| [95% Conf. Interval]

educ .0613966 .0312895 1.96 0.050 .0000704 .1227228


exper .0441704 .0133696 3.30 0.001 .0179665 .0703742
expersq -.000899 .0003998 -2.25 0.025 -.0016826 -.0001154
_cons .0481003 .398453 0.12 0.904 -.7328532 .8290538

Instrumented: educ
Instruments: exper expersq motheduc fatheduc

. *// Conducting the exogeneity test on instruments manually


. predict uhat, res
(325 missing values generated)

. reg uhat motheduc fatheduc exper expersq

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

uhat Coef. Std. Err. t P>|t| [95% Conf. Interval]

motheduc -.0066065 .0118864 -0.56 0.579 -.0299704 .0167573


fatheduc .0057823 .0111786 0.52 0.605 -.0161902 .0277547
exper -.0000183 .0133291 -0.00 0.999 -.0262179 .0261813
expersq 7.34e-07 .0003985 0.00 0.999 -.0007825 .000784
_cons .0109641 .1412571 0.08 0.938 -.2666892 .2886173

. gen rsq=e(r2)

. su rsq

Variable Obs Mean Std. Dev. Min Max

rsq 753 .0008833 0 .0008833 .0008833

. *// su for summarize!

. *// Compute N*Rsq for this auxillary regression (as in LM test)

. gen n_rsq=428* rsq

. su n_rsq

Variable Obs Mean Std. Dev. Min Max

n_rsq 753 .3780714 0 .3780714 .3780714

. *// This is so-called "Sargan Statistic" and the degree of freedom is 1 (the extra instrument: we have two for 1 educ variable so extra 1 instrument is u
> sed
. *// The 5% critical chi-square for 1 df is 3.84

. *// Hence, we fail (do not reject) to reject the null hypothesis that instruments are valid (Null hypothesis is confirmed) as 0.378<3.84

. *// Hence, cov(motheduc, u) and Cov(fathereduc, u) are zero!

. *// Our instruments have ‘passed’ the test of overidentifying restrictions!

. *// Now, let us conduct the test of overidentifying restriction automatically!

. ivregress 2sls lwage exper expersq (educ= motheduc fatheduc)

Instrumental variables (2SLS) regression Number of obs = 428


Wald chi2(3) = 24.65
Prob > chi2 = 0.0000
R-squared = 0.1357
Root MSE = .67155

lwage Coef. Std. Err. z P>|z| [95% Conf. Interval]

educ .0613966 .0312895 1.96 0.050 .0000704 .1227228


exper .0441704 .0133696 3.30 0.001 .0179665 .0703742
expersq -.000899 .0003998 -2.25 0.025 -.0016826 -.0001154
_cons .0481003 .398453 0.12 0.904 -.7328532 .8290538

Instrumented: educ
Instruments: exper expersq motheduc fatheduc

. estat overid

Tests of overidentifying restrictions:

Sargan (score) chi2(1) = .378071 (p = 0.5386)


Basmann chi2(1) = .373985 (p = 0.5408)

. *// This command works only if there are extra instruments! If only 1 instrument for 1 endo variable, then it does not work!

. *// As you can see the Sargan statistic is also given with a p-value of 0.5386, clearly, we fail to reject the null and hence, conclude the instruments a
> re valid (exogenous)

. *// This test has a heteroscedasticity-robust option, called the "Hansen's J statistic"..

. ivregress 2sls lwage exper expersq (educ= motheduc fatheduc), robust

Instrumental variables (2SLS) regression Number of obs = 428


Wald chi2(3) = 18.61
Prob > chi2 = 0.0003
R-squared = 0.1357
Root MSE = .67155

Robust
lwage Coef. Std. Err. z P>|z| [95% Conf. Interval]

educ .0613966 .0331824 1.85 0.064 -.0036397 .126433


exper .0441704 .0154736 2.85 0.004 .0138428 .074498
expersq -.000899 .0004281 -2.10 0.036 -.001738 -.00006
_cons .0481003 .4277846 0.11 0.910 -.7903421 .8865427

Instrumented: educ
Instruments: exper expersq motheduc fatheduc

. estat overid
Test of overidentifying restrictions:

Score chi2(1) = .443461 (p = 0.5055)

. *// with robust option, Hansen's J statistic is 0.443461 and the p-value is in paranthesis

. *// Important note: Even if you fail to reject the null hypothesis in the test, there is a possibility that your instruments are still invalid! Provide a
> plausible story for why they should be exogenous..

. *// Testing the endogeneity of a Variable (with valid instruments)

. *// That is to say: If instruments pass the overidentifying test, then conduct the test of endogeneity on that variable (educ, e.g.)

. ivregress 2sls lwage exper expersq (educ= motheduc fatheduc)

Instrumental variables (2SLS) regression Number of obs = 428


Wald chi2(3) = 24.65
Prob > chi2 = 0.0000
R-squared = 0.1357
Root MSE = .67155

lwage Coef. Std. Err. z P>|z| [95% Conf. Interval]

educ .0613966 .0312895 1.96 0.050 .0000704 .1227228


exper .0441704 .0133696 3.30 0.001 .0179665 .0703742
expersq -.000899 .0003998 -2.25 0.025 -.0016826 -.0001154
_cons .0481003 .398453 0.12 0.904 -.7328532 .8290538

Instrumented: educ
Instruments: exper expersq motheduc fatheduc

. estat endog

Tests of endogeneity
Ho: variables are exogenous

Durbin (score) chi2(1) = 2.80707 (p = 0.0938)


Wu-Hausman F(1,423) = 2.79259 (p = 0.0954)

. *// The well-known "Durbin-Wu-Hausman test for endogeneity": Reject the null that educ is exogenous at 10% level of significance..

. *// with robust option, Hansen's J statistic is 0.443461 and the p-value is in paranthesis

. *// Manual version of this test

. ivregress 2sls lwage exper expersq (educ= motheduc fatheduc)

Instrumental variables (2SLS) regression Number of obs = 428


Wald chi2(3) = 24.65
Prob > chi2 = 0.0000
R-squared = 0.1357
Root MSE = .67155

lwage Coef. Std. Err. z P>|z| [95% Conf. Interval]

educ .0613966 .0312895 1.96 0.050 .0000704 .1227228


exper .0441704 .0133696 3.30 0.001 .0179665 .0703742
expersq -.000899 .0003998 -2.25 0.025 -.0016826 -.0001154
_cons .0481003 .398453 0.12 0.904 -.7328532 .8290538

Instrumented: educ
Instruments: exper expersq motheduc fatheduc
. gen fullsample=e(sample)

. regress educ exper expersq motheduc fatheduc if fullsample==1

Source SS df MS Number of obs = 428


F( 4, 423) = 28.36
Model 471.620998 4 117.90525 Prob > F = 0.0000
Residual 1758.57526 423 4.15738833 R-squared = 0.2115
Adj R-squared = 0.2040
Total 2230.19626 427 5.22294206 Root MSE = 2.039

educ Coef. Std. Err. t P>|t| [95% Conf. Interval]

exper .0452254 .0402507 1.12 0.262 -.0338909 .1243417


expersq -.0010091 .0012033 -0.84 0.402 -.0033744 .0013562
motheduc .157597 .0358941 4.39 0.000 .087044 .2281501
fatheduc .1895484 .0337565 5.62 0.000 .1231971 .2558997
_cons 9.10264 .4265614 21.34 0.000 8.264196 9.941084

. predict uhat_reduced, res

. regress lwage educ exper expersq uhat_reduced

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
uhat_reduced .0581666 .0348073 1.67 0.095 -.0102501 .1265834
_cons .0481003 .3945753 0.12 0.903 -.7274721 .8236727

. *// Note that uhat_reduced has a coefficient which is significant at 10% so reject the null that educ is exogenous!

. log close
name: <unnamed>
log: S:\ECO311\IV_Endogeneity_MrozData.smcl
log type: smcl
closed on: 17 Feb 2014, 17:40:10

Вам также может понравиться