------------------------------------------------------------------------------- log: /afs/uncg.edu/html/bae/people/rosenbaum/643/lab4.log log type: text opened on: 20 Sep 2006, 12:10:15 . . /*********************************************************** > 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 (807 observations read) . sum Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- educ | 807 12.47088 3.057161 6 18 cigpric | 807 60.30041 4.738469 44.004 70.129 white | 807 .8785626 .3268375 0 1 age | 807 41.23792 17.02729 17 88 income | 807 19304.83 9142.958 500 30000 -------------+-------------------------------------------------------- cigs | 807 8.686493 13.72152 0 80 restaurn | 807 .2465923 .4312946 0 1 lincome | 807 9.687315 .7126952 6.214608 10.30895 agesq | 807 1990.135 1577.166 289 7744 lcigpric | 807 4.096032 .0829194 3.784281 4.250336 . . /*********************************************************** > 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 Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 4, 802) = 39.61 Model | 67.5411673 4 16.8852918 Prob > F = 0.0000 Residual | 341.854008 802 .42625188 R-squared = 0.1650 -------------+------------------------------ Adj R-squared = 0.1608 Total | 409.395175 806 .50793446 Root MSE = .65288 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | .0017306 .0017137 1.01 0.313 -.0016333 .0050945 educ | .0603605 .0078983 7.64 0.000 .0448567 .0758644 age | .0576908 .0076436 7.55 0.000 .0426869 .0726946 agesq | -.0006306 .0000834 -7.56 0.000 -.0007943 -.0004669 _cons | 7.795445 .170427 45.74 0.000 7.460909 8.12998 ------------------------------------------------------------------------------ . est store ols1 . reg cigs lincome educ age agesq lcigpric restaurn Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 6, 800) = 7.42 Model | 8003.02506 6 1333.83751 Prob > F = 0.0000 Residual | 143750.658 800 179.688322 R-squared = 0.0527 -------------+------------------------------ Adj R-squared = 0.0456 Total | 151753.683 806 188.280003 Root MSE = 13.405 ------------------------------------------------------------------------------ cigs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lincome | .8802689 .7277838 1.21 0.227 -.5483223 2.30886 educ | -.5014982 .1670772 -3.00 0.003 -.8294597 -.1735368 age | .7706936 .1601223 4.81 0.000 .456384 1.085003 agesq | -.0090228 .001743 -5.18 0.000 -.0124443 -.0056013 lcigpric | -.7508498 5.773343 -0.13 0.897 -12.08354 10.58184 restaurn | -2.825085 1.111794 -2.54 0.011 -5.007462 -.642708 _cons | -3.639884 24.07866 -0.15 0.880 -50.9047 43.62493 ------------------------------------------------------------------------------ . . /*********************************************************** > Here I run reduced form regressions, which I could use > to calculate indirect least squares estimates. > ***********************************************************/ . . reg lincome educ age agesq lcigpric restaurn Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 5, 801) = 33.13 Model | 70.148858 5 14.0297716 Prob > F = 0.0000 Residual | 339.246317 801 .423528486 R-squared = 0.1713 -------------+------------------------------ Adj R-squared = 0.1662 Total | 409.395175 806 .50793446 Root MSE = .65079 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .0583363 .0078452 7.44 0.000 .0429367 .0737359 age | .0588995 .0074901 7.86 0.000 .0441971 .073602 agesq | -.0006447 .0000815 -7.91 0.000 -.0008047 -.0004847 lcigpric | .4538876 .2798316 1.62 0.105 -.0954022 1.003177 restaurn | .1007595 .0538591 1.87 0.062 -.0049621 .2064811 _cons | 5.929957 1.150068 5.16 0.000 3.672455 8.187459 ------------------------------------------------------------------------------ . reg cigs educ age agesq lcigpric restaurn Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 5, 801) = 8.61 Model | 7740.15211 5 1548.03042 Prob > F = 0.0000 Residual | 144013.531 801 179.792173 R-squared = 0.0510 -------------+------------------------------ Adj R-squared = 0.0451 Total | 151753.683 806 188.280003 Root MSE = 13.409 ------------------------------------------------------------------------------ cigs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | -.4501466 .1616396 -2.78 0.005 -.7674338 -.1328594 age | .822541 .1543224 5.33 0.000 .5196168 1.125465 agesq | -.0095903 .0016792 -5.71 0.000 -.0128864 -.0062942 lcigpric | -.3513066 5.765551 -0.06 0.951 -11.66868 10.96607 restaurn | -2.73639 1.109693 -2.47 0.014 -4.914639 -.5581397 _cons | 1.580073 23.69559 0.07 0.947 -44.9327 48.09285 ------------------------------------------------------------------------------ . predict cigshat (option xb assumed; fitted values) . 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) Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 4, 802) = 1.89 Model | -6862.17194 4 -1715.54298 Prob > F = 0.1096 Residual | 7271.56711 802 9.06679191 R-squared = . -------------+------------------------------ Adj R-squared = . Total | 409.395175 806 .50793446 Root MSE = 3.0111 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.2167758 .5225962 -0.41 0.678 -1.242594 .8090421 educ | -.0427038 .2491456 -0.17 0.864 -.5317583 .4463507 age | .2376892 .4318897 0.55 0.582 -.6100785 1.085457 agesq | -.0027244 .0050218 -0.54 0.588 -.0125818 .0071331 _cons | 7.722951 .804908 9.59 0.000 6.142976 9.302926 ------------------------------------------------------------------------------ . . /*********************************************************** > Here I compute 2SLS estimates. > ***********************************************************/ . . reg lincome cigs educ age agesq (educ age agesq cigshat) Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 4, 802) = 22.31 Model | -211.616437 4 -52.9041093 Prob > F = 0.0000 Residual | 621.011612 802 .774328693 R-squared = . -------------+------------------------------ Adj R-squared = . Total | 409.395175 806 .50793446 Root MSE = .87996 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.0421256 .0262184 -1.61 0.109 -.0935904 .0093392 educ | .0396746 .016281 2.44 0.015 .0077161 .0716331 age | .0938181 .0238533 3.93 0.000 .0469957 .1406404 agesq | -.0010508 .0002743 -3.83 0.000 -.0015893 -.0005123 _cons | 7.780894 .229867 33.85 0.000 7.329682 8.232106 ------------------------------------------------------------------------------ . . /*********************************************************** > 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) Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 4, 802) = 22.31 Model | -211.616436 4 -52.904109 Prob > F = 0.0000 Residual | 621.011611 802 .774328692 R-squared = . -------------+------------------------------ Adj R-squared = . Total | 409.395175 806 .50793446 Root MSE = .87996 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.0421256 .0262184 -1.61 0.109 -.0935904 .0093392 educ | .0396746 .016281 2.44 0.015 .0077161 .0716331 age | .0938181 .0238533 3.93 0.000 .0469957 .1406404 agesq | -.0010508 .0002743 -3.83 0.000 -.0015893 -.0005123 _cons | 7.780894 .229867 33.85 0.000 7.329682 8.232106 ------------------------------------------------------------------------------ . est store iv1 . ivreg lincome educ age agesq (cigs=educ age agesq lcigpric restaurn), first First-stage regressions ----------------------- Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 5, 801) = 8.61 Model | 7740.15211 5 1548.03042 Prob > F = 0.0000 Residual | 144013.531 801 179.792173 R-squared = 0.0510 -------------+------------------------------ Adj R-squared = 0.0451 Total | 151753.683 806 188.280003 Root MSE = 13.409 ------------------------------------------------------------------------------ cigs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | -.4501466 .1616396 -2.78 0.005 -.7674338 -.1328594 age | .822541 .1543224 5.33 0.000 .5196168 1.125465 agesq | -.0095903 .0016792 -5.71 0.000 -.0128864 -.0062942 lcigpric | -.3513066 5.765551 -0.06 0.951 -11.66868 10.96607 restaurn | -2.73639 1.109693 -2.47 0.014 -4.914639 -.5581397 _cons | 1.580073 23.69559 0.07 0.947 -44.9327 48.09285 ------------------------------------------------------------------------------ Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 4, 802) = 22.31 Model | -211.616436 4 -52.904109 Prob > F = 0.0000 Residual | 621.011611 802 .774328692 R-squared = . -------------+------------------------------ Adj R-squared = . Total | 409.395175 806 .50793446 Root MSE = .87996 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.0421256 .0262184 -1.61 0.109 -.0935904 .0093392 educ | .0396746 .016281 2.44 0.015 .0077161 .0716331 age | .0938181 .0238533 3.93 0.000 .0469957 .1406404 agesq | -.0010508 .0002743 -3.83 0.000 -.0015893 -.0005123 _cons | 7.780894 .229867 33.85 0.000 7.329682 8.232106 ------------------------------------------------------------------------------ Instrumented: cigs Instruments: educ age agesq lcigpric restaurn ------------------------------------------------------------------------------ . . /*********************************************************** > Here I test whether the instrumental variables are jointly > significant in the first stage equation. > ***********************************************************/ . . reg cigs educ age agesq lcigpric restaurn Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 5, 801) = 8.61 Model | 7740.15211 5 1548.03042 Prob > F = 0.0000 Residual | 144013.531 801 179.792173 R-squared = 0.0510 -------------+------------------------------ Adj R-squared = 0.0451 Total | 151753.683 806 188.280003 Root MSE = 13.409 ------------------------------------------------------------------------------ cigs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | -.4501466 .1616396 -2.78 0.005 -.7674338 -.1328594 age | .822541 .1543224 5.33 0.000 .5196168 1.125465 agesq | -.0095903 .0016792 -5.71 0.000 -.0128864 -.0062942 lcigpric | -.3513066 5.765551 -0.06 0.951 -11.66868 10.96607 restaurn | -2.73639 1.109693 -2.47 0.014 -4.914639 -.5581397 _cons | 1.580073 23.69559 0.07 0.947 -44.9327 48.09285 ------------------------------------------------------------------------------ . test lcigpric restaurn ( 1) lcigpric = 0 ( 2) restaurn = 0 F( 2, 801) = 3.13 Prob > F = 0.0441 . . /*********************************************************** > 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) Instrumental variables (2SLS) regression Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 4, 802) = 22.31 Model | -211.616436 4 -52.904109 Prob > F = 0.0000 Residual | 621.011611 802 .774328692 R-squared = . -------------+------------------------------ Adj R-squared = . Total | 409.395175 806 .50793446 Root MSE = .87996 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.0421256 .0262184 -1.61 0.109 -.0935904 .0093392 educ | .0396746 .016281 2.44 0.015 .0077161 .0716331 age | .0938181 .0238533 3.93 0.000 .0469957 .1406404 agesq | -.0010508 .0002743 -3.83 0.000 -.0015893 -.0005123 _cons | 7.780894 .229867 33.85 0.000 7.329682 8.232106 ------------------------------------------------------------------------------ . predict ehat, resid . reg ehat educ age agesq lcigpric restaurn, noc Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 5, 802) = 0.01 Model | .023850411 5 .004770082 Prob > F = 1.0000 Residual | 620.98776 802 .774298952 R-squared = 0.0000 -------------+------------------------------ Adj R-squared = -0.0062 Total | 621.01161 807 .769531115 Root MSE = .87994 ------------------------------------------------------------------------------ ehat | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | -.0007805 .0105994 -0.07 0.941 -.0215863 .0200252 age | -.0013256 .0100854 -0.13 0.895 -.0211225 .0184713 agesq | .0000131 .0001098 0.12 0.905 -.0002024 .0002286 lcigpric | .0096962 .0559748 0.17 0.863 -.1001782 .1195705 restaurn | -.0029854 .0721273 -0.04 0.967 -.144566 .1385953 ------------------------------------------------------------------------------ . disp e(N)*e(r2) .03099343 . disp chiprob(1,e(N)*e(r2)) .86025504 . . /*********************************************************** > 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 ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-V_B)) | iv1 ols1 Difference S.E. -------------+---------------------------------------------------------------- cigs | -.0421256 .0017306 -.0438562 .0193769 educ | .0396746 .0603605 -.0206859 .0091396 age | .0938181 .0576908 .0361273 .0159621 agesq | -.0010508 -.0006306 -.0004202 .0001857 _cons | 7.780894 7.795445 -.0145501 .0064286 ------------------------------------------------------------------------------ b = consistent under Ho and Ha; obtained from regress B = inconsistent under Ha, efficient under Ho; obtained from regress Test: Ho: difference in coefficients not systematic chi2(1) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 5.12 Prob>chi2 = 0.0236 . reg lincome cigs educ age agesq vhat Source | SS df MS Number of obs = 807 -------------+------------------------------ F( 5, 801) = 32.88 Model | 69.7246963 5 13.9449393 Prob > F = 0.0000 Residual | 339.670479 801 .424058026 R-squared = 0.1703 -------------+------------------------------ Adj R-squared = 0.1651 Total | 409.395175 806 .50793446 Root MSE = .6512 ------------------------------------------------------------------------------ lincome | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.0421256 .0194024 -2.17 0.030 -.0802113 -.00404 educ | .0396746 .0120485 3.29 0.001 .0160243 .0633249 age | .0938181 .0176522 5.31 0.000 .059168 .1284681 agesq | -.0010508 .000203 -5.18 0.000 -.0014493 -.0006523 vhat | .0441993 .0194782 2.27 0.024 .005965 .0824335 _cons | 7.780894 .1701087 45.74 0.000 7.446983 8.114806 ------------------------------------------------------------------------------ . . /*********************************************************** > Here I run 3SLS. Any idea why it doesn't work? > ***********************************************************/ . . reg3 (lincome cigs educ age agesq) /// > (cigs lincome educ age agesq lcigpric restaurn) Equation is not identified -- does not meet order conditions Equation cigs: cigs lincome educ age agesq lcigpric restaurn Exogenous variables: educ age agesq lcigpric restaurn r(481); end of do-file r(481);