INTRODUCTORY ECONOMETRICS – REPLICATING EXAMPLES
Chapter 4 – Examples
----------------------------------------------- name: SN log: Wooldridge\intro-econx\iexample4.smcl log type: smcl opened on: 6 Jan 2019, 17:17:19 . ********************************************** . * Solomon Negash - Replicating Examples . * Wooldridge (2016). Introductory Econometrics: A Modern Approach. 6ed. . * STATA Program, version 15.1. . * Chapter 4 - Multiple Regression Analysis: Inference . * Computer Exercises (Examples) . ******************** SETUP ********************* *example4.1. Wage equation . u wage1.dta, clear . reg lwage educ exper tenure Source | SS df MS Number of obs = 526 -------------+---------------------------------- F(3, 522) = 80.39 Model | 46.8741776 3 15.6247259 Prob > F = 0.0000 Residual | 101.455574 522 .194359337 R-squared = 0.3160 -------------+---------------------------------- Adj R-squared = 0.3121 Total | 148.329751 525 .28253286 Root MSE = .44086 ------------------------------------------------------------------------------ lwage | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- educ | .092029 .0073299 12.56 0.000 .0776292 .1064288 exper | .0041211 .0017233 2.39 0.017 .0007357 .0075065 tenure | .0220672 .0030936 7.13 0.000 .0159897 .0281448 _cons | .2843595 .1041904 2.73 0.007 .0796756 .4890435 ------------------------------------------------------------------------------ *example4.2. Student performance . u meap93.dta, clear . *Lin-lin model . eststo: reg math10 totcomp staff enroll Source | SS df MS Number of obs = 408 -------------+---------------------------------- F(3, 404) = 7.70 Model | 2422.93434 3 807.644779 Prob > F = 0.0001 Residual | 42394.2462 404 104.936253 R-squared = 0.0541 -------------+---------------------------------- Adj R-squared = 0.0470 Total | 44817.1805 407 110.115923 Root MSE = 10.244 ------------------------------------------------------------------------------ math10 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- totcomp | .0004586 .0001004 4.57 0.000 .0002613 .0006559 staff | .0479199 .039814 1.20 0.229 -.0303487 .1261884 enroll | -.0001976 .0002152 -0.92 0.359 -.0006207 .0002255 _cons | 2.274021 6.113794 0.37 0.710 -9.744801 14.29284 ------------------------------------------------------------------------------ (est1 stored) . *Lin-log model . eststo: reg math10 ltotcomp lstaff lenroll Source | SS df MS Number of obs = 408 -------------+---------------------------------- F(3, 404) = 9.42 Model | 2930.03493 3 976.678311 Prob > F = 0.0000 Residual | 41887.1456 404 103.681053 R-squared = 0.0654 -------------+---------------------------------- Adj R-squared = 0.0584 Total | 44817.1805 407 110.115923 Root MSE = 10.182 ------------------------------------------------------------------------------ math10 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- ltotcomp | 21.155 4.055549 5.22 0.000 13.18238 29.12761 lstaff | 3.980018 4.18966 0.95 0.343 -4.256239 12.21628 lenroll | -1.268046 .693204 -1.83 0.068 -2.630784 .0946912 _cons | -207.6648 48.70313 -4.26 0.000 -303.408 -111.9216 ------------------------------------------------------------------------------ (est2 stored) . estout *, cells(b(star fmt(3)) se(par fmt(2))) stats(r2_a N, fmt(%9.3f %9.0g) label > s(R-squared)) legend label collabels(none) varlabels(_cons Constant) ---------------------------------------------------- est1 est2 ---------------------------------------------------- salary + benefits 0.000*** (0.00) staff per 1000 stu~s 0.048 (0.04) school enrollment -0.000 (0.00) log(totcomp) 21.155*** (4.06) log(staff) 3.980 (4.19) log(enroll) -1.268 (0.69) Constant 2.274 -207.665*** (6.11) (48.70) ---------------------------------------------------- R-squared 0.047 0.058 N 408 408 ---------------------------------------------------- * p<0.05, ** p<0.01, *** p<0.001 . est clear *example4.3. Collage GPA . u gpa1.dta, clear . reg colGPA hsGPA ACT skipped Source | SS df MS Number of obs = 141 -------------+---------------------------------- F(3, 137) = 13.92 Model | 4.53313314 3 1.51104438 Prob > F = 0.0000 Residual | 14.8729663 137 .108561798 R-squared = 0.2336 -------------+---------------------------------- Adj R-squared = 0.2168 Total | 19.4060994 140 .138614996 Root MSE = .32949 ------------------------------------------------------------------------------ colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hsGPA | .4118162 .0936742 4.40 0.000 .2265819 .5970505 ACT | .0147202 .0105649 1.39 0.166 -.0061711 .0356115 skipped | -.0831131 .0259985 -3.20 0.002 -.1345234 -.0317028 _cons | 1.389554 .3315535 4.19 0.000 .7339295 2.045178 ------------------------------------------------------------------------------ *example4.4. Campus crime & enrollment . u campus.dta, clear . reg lcrime lenroll Source | SS df MS Number of obs = 97 -------------+---------------------------------- F(1, 95) = 133.79 Model | 107.083654 1 107.083654 Prob > F = 0.0000 Residual | 76.0358244 95 .800377098 R-squared = 0.5848 -------------+---------------------------------- Adj R-squared = 0.5804 Total | 183.119479 96 1.90749457 Root MSE = .89464 ------------------------------------------------------------------------------ lcrime | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lenroll | 1.26976 .109776 11.57 0.000 1.051827 1.487693 _cons | -6.63137 1.03354 -6.42 0.000 -8.683206 -4.579533 ------------------------------------------------------------------------------ *example4.5. Housing prices . u hprice2.dta, clear . g ldist=ln(dist) . reg lprice lnox ldist rooms stratio Source | SS df MS Number of obs = 506 -------------+---------------------------------- F(4, 501) = 175.86 Model | 49.3987586 4 12.3496897 Prob > F = 0.0000 Residual | 35.1834663 501 .07022648 R-squared = 0.5840 -------------+---------------------------------- Adj R-squared = 0.5807 Total | 84.582225 505 .167489554 Root MSE = .265 ------------------------------------------------------------------------------ lprice | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lnox | -.9535388 .1167417 -8.17 0.000 -1.182902 -.7241751 ldist | -.1343395 .0431032 -3.12 0.002 -.2190247 -.0496542 rooms | .2545271 .0185303 13.74 0.000 .2181203 .2909338 stratio | -.0524511 .0058971 -8.89 0.000 -.0640372 -.040865 _cons | 11.08386 .3181113 34.84 0.000 10.45887 11.70886 ------------------------------------------------------------------------------ *example4.6. Participation rates in 401k plans . u 401k.dta, clear . reg prate mrate age totemp Source | SS df MS Number of obs = 1,534 -------------+---------------------------------- F(3, 1530) = 56.38 Model | 42642.5383 3 14214.1794 Prob > F = 0.0000 Residual | 385743.001 1,530 252.119609 R-squared = 0.0995 -------------+---------------------------------- Adj R-squared = 0.0978 Total | 428385.539 1,533 279.442622 Root MSE = 15.878 ------------------------------------------------------------------------------ prate | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- mrate | 5.442221 .524419 10.38 0.000 4.413565 6.470878 age | .2691979 .0451449 5.96 0.000 .1806455 .3577503 totemp | -.0001291 .0000367 -3.52 0.000 -.000201 -.0000572 _cons | 80.29405 .7777274 103.24 0.000 78.76853 81.81958 ------------------------------------------------------------------------------ *example4.7. Job training (only for the year 1987 and for nonunionized firms) . u jtrain.dta, clear . d year union storage display value variable name type format label variable label ------------------------------------------------------------------------------------- year int %9.0g 1987, 1988, or 1989 union byte %9.0g =1 if unionized . reg lscrap hrsemp lsales lemploy if year==1987 & union==0 Source | SS df MS Number of obs = 29 -------------+---------------------------------- F(3, 25) = 2.97 Model | 16.8426986 3 5.61423287 Prob > F = 0.0513 Residual | 47.3369125 25 1.8934765 R-squared = 0.2624 -------------+---------------------------------- Adj R-squared = 0.1739 Total | 64.1796111 28 2.29212897 Root MSE = 1.376 ------------------------------------------------------------------------------ lscrap | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hrsemp | -.0292689 .0228048 -1.28 0.211 -.0762364 .0176985 lsales | -.9620269 .4525181 -2.13 0.044 -1.894005 -.0300484 lemploy | .7614704 .4074328 1.87 0.073 -.0776532 1.600594 _cons | 12.45837 5.68677 2.19 0.038 .746249 24.17049 ------------------------------------------------------------------------------ *example4.8. . u rdchem.dta, clear . reg lrd lsales profmarg Source | SS df MS Number of obs = 32 -------------+---------------------------------- F(2, 29) = 162.23 Model | 85.5967531 2 42.7983766 Prob > F = 0.0000 Residual | 7.65051127 29 .263810733 R-squared = 0.9180 -------------+---------------------------------- Adj R-squared = 0.9123 Total | 93.2472644 31 3.00797627 Root MSE = .51363 ------------------------------------------------------------------------------ lrd | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lsales | 1.08422 .060195 18.01 0.000 .9611073 1.207333 profmarg | .0216557 .0127826 1.69 0.101 -.0044877 .0477991 _cons | -4.378273 .4680185 -9.35 0.000 -5.335479 -3.421068 ------------------------------------------------------------------------------ *example4.9. Parent's education on birth weight . u bwght.dta, clear . reg bwght cigs parity faminc motheduc fatheduc Source | SS df MS Number of obs = 1,191 -------------+---------------------------------- F(5, 1185) = 9.55 Model | 18705.5567 5 3741.11135 Prob > F = 0.0000 Residual | 464041.135 1,185 391.595895 R-squared = 0.0387 -------------+---------------------------------- Adj R-squared = 0.0347 Total | 482746.692 1,190 405.669489 Root MSE = 19.789 ------------------------------------------------------------------------------ bwght | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.5959362 .1103479 -5.40 0.000 -.8124352 -.3794373 parity | 1.787603 .6594055 2.71 0.007 .4938709 3.081336 faminc | .0560414 .0365616 1.53 0.126 -.0156913 .1277742 motheduc | -.3704503 .3198551 -1.16 0.247 -.9979957 .2570951 fatheduc | .4723944 .2826433 1.67 0.095 -.0821426 1.026931 _cons | 114.5243 3.728453 30.72 0.000 107.2092 121.8394 ------------------------------------------------------------------------------ . test motheduc fatheduc ( 1) motheduc = 0 ( 2) fatheduc = 0 F( 2, 1185) = 1.44 Prob > F = 0.2380 . reg bwght cigs parity faminc Source | SS df MS Number of obs = 1,388 -------------+---------------------------------- F(3, 1384) = 16.63 Model | 19996.5211 3 6665.50703 Prob > F = 0.0000 Residual | 554615.199 1,384 400.733525 R-squared = 0.0348 -------------+---------------------------------- Adj R-squared = 0.0327 Total | 574611.72 1,387 414.283864 Root MSE = 20.018 ------------------------------------------------------------------------------ bwght | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- cigs | -.4771537 .091518 -5.21 0.000 -.6566827 -.2976247 parity | 1.616372 .603955 2.68 0.008 .4316058 2.801138 faminc | .0979201 .0291868 3.35 0.001 .040665 .1551752 _cons | 114.2143 1.4693 77.73 0.000 111.3321 117.0966 ------------------------------------------------------------------------------ *Exaploring further 4.5. . u attend, clear . eststo: reg atndrte priGPA Source | SS df MS Number of obs = 680 -------------+---------------------------------- F(1, 678) = 151.35 Model | 36008.3571 1 36008.3571 Prob > F = 0.0000 Residual | 161308.968 678 237.918832 R-squared = 0.1825 -------------+---------------------------------- Adj R-squared = 0.1813 Total | 197317.325 679 290.59989 Root MSE = 15.425 ------------------------------------------------------------------------------ atndrte | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- priGPA | 13.36898 1.086703 12.30 0.000 11.23527 15.50268 _cons | 47.12702 2.872615 16.41 0.000 41.48673 52.76732 ------------------------------------------------------------------------------ (est1 stored) . eststo: reg atndrte priGPA ACT Source | SS df MS Number of obs = 680 -------------+---------------------------------- F(2, 677) = 138.65 Model | 57336.7612 2 28668.3806 Prob > F = 0.0000 Residual | 139980.564 677 206.765974 R-squared = 0.2906 -------------+---------------------------------- Adj R-squared = 0.2885 Total | 197317.325 679 290.59989 Root MSE = 14.379 ------------------------------------------------------------------------------ atndrte | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- priGPA | 17.26059 1.083103 15.94 0.000 15.13395 19.38724 ACT | -1.716553 .169012 -10.16 0.000 -2.048404 -1.384702 _cons | 75.7004 3.884108 19.49 0.000 68.07406 83.32675 ------------------------------------------------------------------------------ (est2 stored) . estout *, cells(b(star fmt(3)) se(par fmt(2))) stats(r2_a N, fmt(%9.3f %9.0g) label > s(R-squared)) legend label collabels(none) varlabels(_cons Constant) ---------------------------------------------------- est1 est2 ---------------------------------------------------- cumulative GPA pri~m 13.369*** 17.261*** (1.09) (1.08) ACT score -1.717*** (0.17) Constant 47.127*** 75.700*** (2.87) (3.88) ---------------------------------------------------- R-squared 0.181 0.288 N 680 680 ---------------------------------------------------- * p<0.05, ** p<0.01, *** p<0.001 . est clear *example4.10. Salary-pension tradeoff for teachers . u meap93.dta, clear . d bensal storage display value variable name type format label variable label ------------------------------------------------------------------------------------- bensal float %9.0g benefits/salary . eststo: qui reg lsalary bensal (est1 stored) . eststo: qui reg lsalary bensal lenrol lstaff (est2 stored) . eststo: qui reg lsalary bensal lenrol lstaff droprate gradrate (est3 stored) . estout *, cells(b(star fmt(3)) se(par fmt(2))) stats(r2_a N, fmt(%9.3f %9.0g) label > s(R-squared)) varlabels(_cons Constant) ti("Compare to Table 4.1 on the textbook > ") Compare to Table 4.1 in the textbook ------------------------------------------------------------ est1 est2 est3 b/se b/se b/se ------------------------------------------------------------ bensal -0.825*** -0.605*** -0.589*** (0.20) (0.17) (0.16) lenroll 0.087*** 0.088*** (0.01) (0.01) lstaff -0.222*** -0.218*** (0.05) (0.05) droprate -0.000 (0.00) gradrate 0.001 (0.00) Constant 10.523*** 10.844*** 10.738*** (0.04) (0.25) (0.26) ------------------------------------------------------------ R-squared 0.038 0.348 0.353 N 408 408 408 ------------------------------------------------------------ . est clear . log close name: SN log: Wooldridge\intro-econx\iexample4.smcl log type: smcl closed on: 6 Jan 2019, 17:17:20 -----------------------------------------------------
Hello Solomon. I am new to Econometrics but trying to learn new areas everyday. I am teaching R Programming (Data Science) at the moment and the application seems helpful to what I am learning. Is there any way you could share the notes you are using, please?
Thank you,
Hi Henock. You can download the data from cengage.com to your desktop and set the folder as your working directory in stata. The output file that I posted here includes all the necessary info (comments, commands and results) to replicate the examples. Once you download the data and set your working directory, you can simply copy and paste the commands (the simple texts without asterisk) and execute it from the command line. You will get the same result. If you have no access to the 6th edition, you may find previous versions online.
There is also an alternative resource for people like you who are familiar with R and wishes to learn Econometrics using R. The book (Using R for Introductory Econometrics) has an online version which is available for free and has extra material with examples and replication exercises.
Best,
Hi Solomon,
I appreciate your effort and I found it very interesting. I will find a way to explore the material further and I will also try to use Python for the analysis. Anyways, I will let you know my findings.
Melkam Gena
Best
Thank you Elu! Would be glad to hear your findings. Feel free to share.
Melkam Gena lantem!