Jul 20, 2017

IV regression using the -sem- command

// Read in data from Angrist and Krueger (1991)
// https://economics.mit.edu/faculty/angrist/data1/data/angkru1991
infile lwklywge educ yob qob pob using asciiqob.txt, clear

// Generate dummy variables as SEM command does not take factor variables
qui tabulate qob, gen(qobx)
qui tabulate yob, gen(yobx)
qui tabulate pob, gen(pobx)
drop qobx1 yobx1 pobx1      // Get rid of reference category

eststo clear

// Model 2 of Table 4.1.1 of Mostly Harmless Econometrics
eststo: regress lwklywge educ yobx* pobx*, robust                              

// Model 6 of Table 4.1.1 of Mostly Harmless Econometrics
eststo: ivregress 2sls lwklywge yobx* pobx* (educ = qobx*), robust

// Model 6 of Table 4.1.1 using the sem command
eststo: sem (lwklywge <- yobx* pobx* educ) (educ <- pobx* qobx*), cov(e.lwklywge*e.educ) 
esttab, b(3) se(3) nostar drop(_cons educ:) /// indicate("9 year-of-birth dummies = yobx*" /// "50 state-of-birth dummies = pobx*") /// title("OLS and 2SLS estimates of the economic returns to schooling") /// coeflabel(educ "Years of education") /// mtitles("OLS" "-ivregress-" "-sem-") nonumbers varwidth(30) /// eqlabels("", none) // Removes equation label