*log using OLS_examples.log use reg.dta, clear * Summary stats sum, d *Basic estimate reg ln_wage grade reg ln_wage grade, noconst *Robust Std Errors: reg ln_wage grade, robust reg ln_wage grade, vce(robust) reg ln_wage grade, vce(hc2) reg ln_wage grade, cluster(idcode) reg ln_wage grade, cluster(year) egen pippo=group(state black) reg ln_wage grade, cluster(pippo) reg ln_wage grade, vce(boot, rep(50)) * Predictions reg ln_wage grade tenure black, cluster(id) predict fitted_res, resid predict fitted_Y, xb * Adding dummies: xi: reg ln_wage grade i.year xi: reg ln_wage i.grade ******** Omitted variable bias pwcorr black grade tenure reg ln_wage black, cluster(idcode) reg ln_wage black grade, cluster(idcode) reg ln_wage black tenure, cluster(idcode) ******* IV regression via 2SLS **** Example with data on housing values: study effect of house value on rent webuse hsng2, clear des *** Compare OLS and IV (with IV given by family income) reg rent hsngval help ivregress ivregress 2sls rent (hsngval = faminc) *** Check that ivreg estimate corresponds to 2 separate OLS regressions (but notice SE are different): ivregress 2sls rent (hsngval = faminc) reg hsngval faminc predict X_hat, xb reg rent X_hat * Hausman test via hausman command in STATA reg rent hsngval est store OLS ivregress 2sls rent (hsngval = faminc) hausman . OLS * Hausman test via auxiliary regressions reg hsngval faminc, robust predict fittedX, xb predict fittedV, res reg rent hsngval fittedX, robust reg rent hsngval fittedV, robust ****** Other useful options and postestimation commands for ivregress: * use with more IVs: ivregress 2sls rent pcturban (hsngval = faminc i.region) *report first step results: significance is a first sign that IV are ok ivregress 2sls rent pcturban (hsngval = faminc i.region), first * help ivregress postestimation: ivregress 2sls rent pcturban (hsngval = faminc i.region) estat firststage estat endogenous estat overid *** NB: now available also the command ivreg2, with more options about standard errors and checking the IVs help ivreg2