clear capture log close log using lab4.log, replace /*********************************************************** LAB4.DO is a STATA do-file that estimates a simultaneous equations system on individual-level data on smoking and income. - written by Dan Rosenbaum, 2006 Located at my website course (http://www.uncg.edu/bae/people/rosenbaum) is a space-delimited file (smoke.raw) containing individual-level data on U.S. on smoking behavior and demographic information. The variables are as follows. 1. educ years of schooling 2. cigpric state cigarette price, cents per pack 3. white =1 if white 4. age in years 5. income annual income, $ 6. cigs cigs. smoked per day 7. restaurn =1 if state restaurant smoking restrictions 8. lincome log(income) 9. agesq age^2 10. lcigpric log(cigprice) ***********************************************************/ /*********************************************************** I start by inputting the data using an INFILE statement, since the data is space-delimited rather than tab-delimited. I also calculate summary statistics for the sample. ***********************************************************/ infile educ cigpric white age income cigs restaurn lincome /// agesq lcigpric using smoke sum /*********************************************************** Here I regress the structural equations using OLS. Notice that I am saving the results from the first equation for a later Hausman test. ***********************************************************/ reg lincome cigs educ age agesq est store ols1 reg cigs lincome educ age agesq lcigpric restaurn /*********************************************************** Here I run reduced form regressions, which I could use to calculate indirect least squares estimates. ***********************************************************/ reg lincome educ age agesq lcigpric restaurn reg cigs educ age agesq lcigpric restaurn predict cigshat predict vhat,resid /*********************************************************** Here I compute IV estimates for the first equation, ignoring the restaurant variable as an instrumental variable. ***********************************************************/ reg lincome cigs educ age agesq (educ age agesq lcigpric) /*********************************************************** Here I compute 2SLS estimates. ***********************************************************/ reg lincome cigs educ age agesq (educ age agesq cigshat) /*********************************************************** Here I compute 2SLS estimates without having to first calculate cigshat. I do this two ways with the second giving me the option of printing out the first stage equation results. Notice that I store the results for a later Hausman test. ***********************************************************/ reg lincome cigs educ age agesq (educ age agesq lcigpric restaurn) est store iv1 ivreg lincome educ age agesq (cigs=educ age agesq lcigpric restaurn), first /*********************************************************** Here I test whether the instrumental variables are jointly significant in the first stage equation. ***********************************************************/ reg cigs educ age agesq lcigpric restaurn test lcigpric restaurn /*********************************************************** Here I test whether the instrumental variables in the log income equation are valid using the Davidson-MacKinnon test. ***********************************************************/ reg lincome cigs educ age agesq (educ age agesq lcigpric restaurn) predict ehat, resid reg ehat educ age agesq lcigpric restaurn, noc disp e(N)*e(r2) disp chiprob(1,e(N)*e(r2)) /*********************************************************** Here I test whether the OLS estimates are consistent in the log income equation using first the Hausman test and second an OLS regression of the structural equation including the residuals from the reduced form equation for CIGS. ***********************************************************/ hausman iv1 ols1, constant sigmamore reg lincome cigs educ age agesq vhat /*********************************************************** Here I run 3SLS. Any idea why it doesn't work? ***********************************************************/ reg3 (lincome cigs educ age agesq) /// (cigs lincome educ age agesq lcigpric restaurn)