version 10.0 capture log close log using chap10, replace use ch10, clear summarize * Least squares estimation reg y x estimates store ls * IV estimation reg x z1 predict xhat reg y xhat * IV estimation using automatic command ivregress 2sls y (x=z1) ivregress 2sls y (x=z1), small ivregress 2sls y (x=z2), small ivregress 2sls y (x=z3), small * IV estimation with surplus instruments ivregress 2sls y (x=z1 z2), small estimates store iv * Hausman test regression based reg x z1 z2 predict vhat, residuals reg y x vhat * Hausman test automatic hausman iv ls, constant sigmamore * Testing for weak instruments reg x z1 reg x z2 reg x z1 z2 test z1 z2 * Testing for weak iv using estat ivregress 2sls y (x=z1 z2), first small estat firststage * Testing surplus moment conditions predict ehat, residuals reg ehat z1 z2 scalar nr2 = e(N)*e(r2) scalar chic = invchi2tail(1,.05) scalar pvalue = chi2tail(1,nr2) di "NR^2 test of overidentifying restriction = " nr2 di "Chi-square critical value 1 df, .05 level = " chic di "p value for overidentifying test 1 df, .05 level = " pvalue * Testing for weak iv using estat ivregress 2sls y (x=z1 z2), small estat overid * Testing surplus moment conditions ivregress 2sls y (x=z1 z2 z3), small predict ehat2, residuals reg ehat2 z1 z2 z3 scalar nr2 = e(N)*e(r2) scalar chic = invchi2tail(2,.05) scalar pvalue = chi2tail(2,nr2) di "NR^2 test of overidentifying restriction = " nr2 di "Chi-square critical value 2 df, .05 level = " chic di "p value for overidentifying test 2 df, .05 level = " pvalue * Testing surplus moments using estat ivregress 2sls y (x=z1 z2 z3) estat overid *--------------------------------- * Mroz data example *--------------------------------- use mroz, clear summarize drop if lfp==0 gen lwage = log(wage) gen exper2 = exper^2 * Least squares estimation reg lwage educ exper exper2 estimates store ls * IV estimation reg educ exper exper2 mothereduc predict educ_hat reg lwage educ_hat exper exper2 * IV estimation using automatic command ivregress 2sls lwage (educ=mothereduc) exper exper2 ivregress 2sls lwage (educ=mothereduc) exper exper2, small ivregress 2sls lwage (educ=mothereduc) exper exper2, vce(robust) small * IV estimation with surplus instruments ivregress 2sls lwage (educ=mothereduc fathereduc) exper exper2, small estimates store iv * Hausman test regression based reg educ exper exper2 mothereduc fathereduc predict vhat, residuals reg lwage educ exper exper2 vhat reg lwage educ exper exper2 vhat, vce(robust) * Hausman test automatic hausman iv ls, constant sigmamore * Testing for weak instruments reg educ exper exper2 mothereduc reg educ exper exper2 fathereduc reg educ exper exper2 mothereduc fathereduc test mothereduc fathereduc * Testing for weak instruments using estat ivregress 2sls lwage (educ=mothereduc fathereduc) exper exper2, small estat firststage * Robust tests reg educ exper exper2 mothereduc fathereduc, vce(robust) test mothereduc fathereduc * Robust tests using ivregress ivregress 2sls lwage (educ=mothereduc fathereduc) exper exper2, small vce(robust) estat firststage * Testing surplus moment conditions ivregress 2sls lwage (educ=mothereduc fathereduc) exper exper2, small predict ehat, residuals quietly reg ehat mothereduc fathereduc exper exper2 scalar nr2 = e(N)*e(r2) scalar chic = invchi2tail(1,.05) scalar pvalue = chi2tail(1,nr2) di "NR^2 test of overidentifying restriction = " nr2 di "Chi-square critical value 1 df, .05 level = " chic di "p value for overidentifying test 1 df, .05 level = " pvalue * Using estat quietly ivregress 2sls lwage (educ=mothereduc fathereduc) exper exper2, small estat overid log close translate chap10.smcl chap10.txt