INTRODUCTORY ECONOMETRICS – REPLICATING EXAMPLES
Chapter 8 – Examples
------------------------------------------------------------------------------------- name: SN log: ~Wooldridge\intro-econx\iexample8.smcl log type: smcl opened on: 9 Jan 2019, 21:10:27 . ********************************************** . * Solomon Negash - Replicating Examples . * Wooldridge (2016). Introductory Econometrics: A Modern Approach. 6th ed. . * STATA Program, version 15.1. . * Chapter 8 - Heteroskedasticity . * Computer Exercises (Examples) . ******************** SETUP ********************* . *Example 8.1. Log wage equation with Heteroskedasticity- Robust Standard Errors . u wage1, clear . g marrmale = (female==0 & married==1) . g marrfem = (female==1 & married==1) . g singfem = (female==1 & married==0) . g singmen = (female==0 & married==0) . eststo hetroskedastic: qui reg lwage marrmale marrfem singfem educ exper* tenur* . eststo robust: qui reg lwage marrmale marrfem singfem educ exper* tenur*, robust . estout , cells(b(nostar fmt(3)) se(par fmt(3))) stats(r2 r2_a N, fmt(%9.3f %9.3f %9.0g) /// labels(R-squared Adj-R-squared)) varlabels(_cons Constant) varwidth(20) ---------------------------------------------- hetroskeda~c robust b/se b/se ---------------------------------------------- marrmale 0.213 0.213 (0.055) (0.057) marrfem -0.198 -0.198 (0.058) (0.059) singfem -0.110 -0.110 (0.056) (0.057) educ 0.079 0.079 (0.007) (0.007) exper 0.027 0.027 (0.005) (0.005) expersq -0.001 -0.001 (0.000) (0.000) tenure 0.029 0.029 (0.007) (0.007) tenursq -0.001 -0.001 (0.000) (0.000) Constant 0.321 0.321 (0.100) (0.109) ---------------------------------------------- R-squared 0.461 0.461 Adj-R-squared 0.453 0.453 N 526 526 ---------------------------------------------- . est clear . *Example 8.2. Heteroskedasticity-Robust F Statistic . u gpa3, clear . eststo hetrosked: qui reg cumgpa sat hsperc tothrs female black white if spring==1 . eststo robust: qui reg cumgpa sat hsperc tothrs female black white if spring==1, robust . estout , cells(b(nostar fmt(5)) se(par fmt(5))) stats(r2 r2_a N, fmt(%9.3f %9.3f %9.0g) /// labels(R-squared Adj-R-squared)) varlabels(_cons Constant) varwidth(20) ---------------------------------------------- hetrosked robust b/se b/se ---------------------------------------------- sat 0.00114 0.00114 (0.00018) (0.00019) hsperc -0.00857 -0.00857 (0.00124) (0.00142) tothrs 0.00250 0.00250 (0.00073) (0.00074) female 0.30343 0.30343 (0.05902) (0.05914) black -0.12828 -0.12828 (0.14737) (0.11924) white -0.05872 -0.05872 (0.14099) (0.11139) Constant 1.47006 1.47006 (0.22980) (0.22068) ---------------------------------------------- R-squared 0.401 0.401 Adj-R-squared 0.391 0.391 N 366 366 ---------------------------------------------- . est clear . *Example 8.3. Heteroskedasticity-Robust LM Statistic . u crime1, clear . g avgsensq = avgsen^2 . eststo hetrosked: qui reg narr86 pcnv avgsen avgsensq ptime86 qemp86 inc86 black hispan . eststo robust: qui reg narr86 pcnv avgsen avgsensq ptime86 qemp86 inc86 black hispan, r . estout , cells(b(nostar fmt(5)) se(par fmt(5))) stats(r2 r2_a N, fmt(%9.3f %9.3f %9.0g) /// labels(R-squared Adj-R-squared)) varlabels(_cons Constant) varwidth(20) ---------------------------------------------- hetrosked robust b/se b/se ---------------------------------------------- pcnv -0.13560 -0.13560 (0.04037) (0.03362) avgsen 0.01784 0.01784 (0.00970) (0.01012) avgsensq -0.00052 -0.00052 (0.00030) (0.00021) ptime86 -0.03936 -0.03936 (0.00869) (0.00622) qemp86 -0.05051 -0.05051 (0.01443) (0.01420) inc86 -0.00148 -0.00148 (0.00034) (0.00023) black 0.32460 0.32460 (0.04542) (0.05851) hispan 0.19338 0.19338 (0.03970) (0.04030) Constant 0.56701 0.56701 (0.03606) (0.04028) ---------------------------------------------- R-squared 0.073 0.073 Adj-R-squared 0.070 0.070 N 2725 2725 ---------------------------------------------- . est clear . *LM Statistic - not-robust (See Section 5-2) . qui reg narr86 pcnv ptime86 qemp86 inc86 black hispan . predict u, res . reg u pcnv avgsen avgsensq ptime86 qemp86 inc86 black hispan Source | SS df MS Number of obs = 2,725 -------------+---------------------------------- F(8, 2716) = 0.43 Model | 2.37155739 8 .296444674 Prob > F = 0.9025 Residual | 1863.99804 2,716 .686302664 R-squared = 0.0013 -------------+---------------------------------- Adj R-squared = -0.0017 Total | 1866.36959 2,724 .685157707 Root MSE = .82843 ------------------------------------------------------------------------------ u | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- pcnv | -.003317 .0403699 -0.08 0.935 -.0824758 .0758418 avgsen | .0178411 .009696 1.84 0.066 -.0011713 .0368534 avgsensq | -.0005163 .000297 -1.74 0.082 -.0010987 .0000661 ptime86 | -.0015647 .0086935 -0.18 0.857 -.0186112 .0154819 qemp86 | .0004742 .0144345 0.03 0.974 -.0278295 .0287779 inc86 | .0000103 .0003405 0.03 0.976 -.0006574 .000678 black | -.0050861 .0454188 -0.11 0.911 -.094145 .0839729 hispan | -.0020709 .0397035 -0.05 0.958 -.0799229 .0757812 _cons | -.0033216 .0360573 -0.09 0.927 -.0740242 .0673809 ------------------------------------------------------------------------------ . display as text "N*Rsq = " 2725*.0013 N*Rsq = 3.5425 . *LM Statistic - robust . foreach x of var avgsen avgsensq { . qui reg `x' pcnv ptime86 qemp86 inc86 black hispan . predict r_`x', residual . gen ures`x'= u*r_`x' . } . gen one=1 . reg one ures*, noc Source | SS df MS Number of obs = 2,725 -------------+---------------------------------- F(2, 2723) = 2.00 Model | 3.99708536 2 1.99854268 Prob > F = 0.1355 Residual | 2721.00291 2,723 .999266586 R-squared = 0.0015 -------------+---------------------------------- Adj R-squared = 0.0007 Total | 2725 2,725 1 Root MSE = .99963 ------------------------------------------------------------------------------ one | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- uresavgsen | .0277846 .0140598 1.98 0.048 .0002156 .0553537 uresavgsensq | -.0010447 .0005479 -1.91 0.057 -.002119 .0000296 ------------------------------------------------------------------------------ . display as text "N - SSR = " 2725 - 2721.0029 N - SSR = 3.9971 . *Example 8.4. Heteroskedasticity in Housing Price Equations . u hprice1, clear . reg price lotsize sqrft bdrms Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(3, 84) = 57.46 Model | 617130.701 3 205710.234 Prob > F = 0.0000 Residual | 300723.805 84 3580.0453 R-squared = 0.6724 -------------+---------------------------------- Adj R-squared = 0.6607 Total | 917854.506 87 10550.0518 Root MSE = 59.833 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lotsize | .0020677 .0006421 3.22 0.002 .0007908 .0033446 sqrft | .1227782 .0132374 9.28 0.000 .0964541 .1491022 bdrms | 13.85252 9.010145 1.54 0.128 -4.065141 31.77018 _cons | -21.77031 29.47504 -0.74 0.462 -80.38466 36.84405 ------------------------------------------------------------------------------ . predict u, res . g u2=u^2 . reg u2 lotsize sqrft bdrms Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(3, 84) = 5.34 Model | 701213780 3 233737927 Prob > F = 0.0020 Residual | 3.6775e+09 84 43780003.5 R-squared = 0.1601 -------------+---------------------------------- Adj R-squared = 0.1301 Total | 4.3787e+09 87 50330276.7 Root MSE = 6616.6 ------------------------------------------------------------------------------ u2 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lotsize | .2015209 .0710091 2.84 0.006 .0603116 .3427302 sqrft | 1.691037 1.46385 1.16 0.251 -1.219989 4.602063 bdrms | 1041.76 996.381 1.05 0.299 -939.6526 3023.173 _cons | -5522.795 3259.478 -1.69 0.094 -12004.62 959.0348 ------------------------------------------------------------------------------ . display as text "LM = N*Rsq =" 88 * .1601 LM = N*Rsq =14.0888 . display chi2tail(3, 88*.1601) .00278674 . reg lprice llotsize lsqrft bdrms Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(3, 84) = 50.42 Model | 5.15504028 3 1.71834676 Prob > F = 0.0000 Residual | 2.86256324 84 .034078134 R-squared = 0.6430 -------------+---------------------------------- Adj R-squared = 0.6302 Total | 8.01760352 87 .092156362 Root MSE = .1846 ------------------------------------------------------------------------------ lprice | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- llotsize | .1679667 .0382812 4.39 0.000 .0918404 .244093 lsqrft | .7002324 .0928652 7.54 0.000 .5155597 .8849051 bdrms | .0369584 .0275313 1.34 0.183 -.0177906 .0917074 _cons | -1.297042 .6512836 -1.99 0.050 -2.592191 -.001893 ------------------------------------------------------------------------------ . predict lu, res . g lu2=lu^2 . reg lu2 llotsize lsqrft bdrms Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(3, 84) = 1.41 Model | .022620168 3 .007540056 Prob > F = 0.2451 Residual | .448717194 84 .005341871 R-squared = 0.0480 -------------+---------------------------------- Adj R-squared = 0.0140 Total | .471337362 87 .005417671 Root MSE = .07309 ------------------------------------------------------------------------------ lu2 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- llotsize | -.0070156 .0151563 -0.46 0.645 -.0371556 .0231244 lsqrft | -.0627368 .0367673 -1.71 0.092 -.1358526 .0103791 bdrms | .0168407 .0109002 1.54 0.126 -.0048356 .038517 _cons | .509994 .257857 1.98 0.051 -.0027829 1.022771 ------------------------------------------------------------------------------ . display as text "LM = N*Rsq =" 88 * .048 LM = N*Rsq =4.224 . display chi2tail(3, 88*.048) .23826999 . *Example 8.5. Special Form of the White Test . u hprice1, clear . reg lprice llotsize lsqrft bdrms Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(3, 84) = 50.42 Model | 5.15504028 3 1.71834676 Prob > F = 0.0000 Residual | 2.86256324 84 .034078134 R-squared = 0.6430 -------------+---------------------------------- Adj R-squared = 0.6302 Total | 8.01760352 87 .092156362 Root MSE = .1846 ------------------------------------------------------------------------------ lprice | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- llotsize | .1679667 .0382812 4.39 0.000 .0918404 .244093 lsqrft | .7002324 .0928652 7.54 0.000 .5155597 .8849051 bdrms | .0369584 .0275313 1.34 0.183 -.0177906 .0917074 _cons | -1.297042 .6512836 -1.99 0.050 -2.592191 -.001893 ------------------------------------------------------------------------------ . predict u, res . g u2=u^2 . predict y, xb . gen y2 = y^2 . reg u2 y y2 Source | SS df MS Number of obs = 88 -------------+---------------------------------- F(2, 85) = 1.73 Model | .018463986 2 .009231993 Prob > F = 0.1830 Residual | .452873375 85 .005327922 R-squared = 0.0392 -------------+---------------------------------- Adj R-squared = 0.0166 Total | .471337362 87 .005417671 Root MSE = .07299 ------------------------------------------------------------------------------ u2 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- y | -1.709221 1.163334 -1.47 0.145 -4.022241 .6037986 y2 | .1451354 .1009925 1.44 0.154 -.0556647 .3459354 _cons | 5.046839 3.345002 1.51 0.135 -1.603921 11.6976 ------------------------------------------------------------------------------ . display as text "LM = N*Rsq =" 88 * .0392 LM = N*Rsq =3.4496 . display chi2tail(2, 88*.0392) .17820869 .*Example 8.6. Financial Wealth Equation . u 401ksubs, clear . keep if fsize==1 (7,258 observations deleted) . g age25sq=(age-25)^2 . eststo OLS1: qui reg nettfa inc, r . eststo WLS1: qui reg nettfa inc [aw=1/inc] . eststo OLS2: qui reg nettfa inc age25sq male e401k, r . eststo WLS2: qui reg nettfa inc age25sq male e401k [aw=1/inc] . estout , cells(b(nostar fmt(5)) se(par fmt(5))) stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared /// Adj-R-squared)) varlabels(_cons Constant) varwidth(20) ti(Table 8.1 Dependent Variable: nettfa) Table 8.1 Dependent Variable: nettfa ------------------------------------------------------------------------ OLS1 WLS1 OLS2 WLS2 b/se b/se b/se b/se ------------------------------------------------------------------------ inc 0.82068 0.78705 0.77058 0.74038 (0.10359) (0.06348) (0.09957) (0.06430) age25sq 0.02513 0.01754 (0.00434) (0.00193) male 2.47793 1.84053 (2.05836) (1.56359) e401k 6.88622 5.18828 (2.28658) (1.70343) Constant -10.57095 -9.58070 -20.98499 -16.70252 (2.53027) (1.65328) (3.49519) (1.95799) ------------------------------------------------------------------------ R-squared 0.083 0.071 0.128 0.112 Adj-R-squared 2017 2017 2017 2017 ------------------------------------------------------------------------ . est clear . *Example 8.7. Demand for Cigarettes . u smoke, clear . local x "lincome lcigpric educ age agesq restaurn" . eststo OLS: reg cigs `x' 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 | .8802682 .7277832 1.21 0.227 -.548322 2.308858 lcigpric | -.7508586 5.773343 -0.13 0.897 -12.08355 10.58183 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 restaurn | -2.825085 1.111794 -2.54 0.011 -5.007462 -.6427078 _cons | -3.639841 24.07866 -0.15 0.880 -50.90466 43.62497 ------------------------------------------------------------------------------ . predict u, res . gen lu2=ln(u^2) . qui reg lu2 `x' . predict lu2h, xb . g e_lu2h=exp(lu2h) . eststo GLS: reg cigs `x' [aw=1/e_lu2h] (sum of wgt is 19.97738570454038) Source | SS df MS Number of obs = 807 -------------+---------------------------------- F(6, 800) = 17.06 Model | 10302.646 6 1717.10767 Prob > F = 0.0000 Residual | 80542.159 800 100.677699 R-squared = 0.1134 -------------+---------------------------------- Adj R-squared = 0.1068 Total | 90844.805 806 112.710676 Root MSE = 10.034 ------------------------------------------------------------------------------ cigs | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lincome | 1.29524 .4370118 2.96 0.003 .4374148 2.153065 lcigpric | -2.940312 4.460144 -0.66 0.510 -11.69528 5.814656 educ | -.4634463 .1201587 -3.86 0.000 -.6993099 -.2275828 age | .4819479 .0968082 4.98 0.000 .2919197 .671976 agesq | -.0056272 .0009395 -5.99 0.000 -.0074713 -.0037831 restaurn | -3.461064 .795505 -4.35 0.000 -5.022588 -1.899541 _cons | 5.635463 17.80314 0.32 0.752 -29.31092 40.58184 ------------------------------------------------------------------------------ . estout , cells(b(nostar fmt(5)) se(par fmt(5))) stats(r2 r2_a N, fmt(%9.3f %9.3f %9.0g) > labels(R-squared Adj-R-squared)) varlabels(_cons Constant) varwidth(20) ---------------------------------------------- OLS GLS b/se b/se ---------------------------------------------- lincome 0.88027 1.29524 (0.72778) (0.43701) lcigpric -0.75086 -2.94031 (5.77334) (4.46014) educ -0.50150 -0.46345 (0.16708) (0.12016) age 0.77069 0.48195 (0.16012) (0.09681) agesq -0.00902 -0.00563 (0.00174) (0.00094) restaurn -2.82508 -3.46106 (1.11179) (0.79550) Constant -3.63984 5.63546 (24.07866) (17.80314) ---------------------------------------------- R-squared 0.053 0.113 Adj-R-squared 0.046 0.107 N 807 807 ---------------------------------------------- . est clear . *Example 8.8. Labor Force Participation of Married Women . u mroz, clear . local x "nwifeinc educ exper* age kidslt6 kidsge6" . eststo heterosked: qui reg inlf `x' . eststo Robust: qui reg inlf `x', r . estout , cells(b(nostar fmt(5)) se(par fmt(5))) stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared /// Adj-R-squared)) varlabels(_cons Constant) varwidth(20) ---------------------------------------------- heterosked Robust b/se b/se ---------------------------------------------- nwifeinc -0.00341 -0.00341 (0.00145) (0.00152) educ 0.03800 0.03800 (0.00738) (0.00727) exper 0.03949 0.03949 (0.00567) (0.00581) expersq -0.00060 -0.00060 (0.00018) (0.00019) age -0.01609 -0.01609 (0.00248) (0.00240) kidslt6 -0.26181 -0.26181 (0.03351) (0.03178) kidsge6 0.01301 0.01301 (0.01320) (0.01353) Constant 0.58552 0.58552 (0.15418) (0.15226) ---------------------------------------------- R-squared 0.264 0.264 Adj-R-squared 753 753 ---------------------------------------------- . est clear . *Example 8.9. Determinants of Personal Computer Ownership . u gpa1, clear . g parcoll = ( fathcoll==1 | mothcoll==1) . eststo heterosked: qui reg PC hsGPA ACT parcoll . eststo Robust: qui reg PC hsGPA ACT parcoll, r . estout, cells(b(nostar fmt(5)) se(par fmt(5))) stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared /// Adj-R-squared)) varlabels(_cons Constant) varwidth(20) ---------------------------------------------- heterosked Robust b/se b/se ---------------------------------------------- hsGPA 0.06539 0.06539 (0.13726) (0.14149) ACT 0.00056 0.00056 (0.01550) (0.01607) parcoll 0.22105 0.22105 (0.09296) (0.08804) Constant -0.00043 -0.00043 (0.49054) (0.49588) ---------------------------------------------- R-squared 0.042 0.042 Adj-R-squared 141 141 ---------------------------------------------- . est clear . qui reg PC hsGPA ACT parcoll . predict yhat, xb . gen hhat = yhat*(1-yhat) . reg PC hsGPA ACT parcoll [aw=1/hhat] (sum of wgt is 628.1830743667747) Source | SS df MS Number of obs = 141 -------------+---------------------------------- F(3, 137) = 2.22 Model | 1.54663033 3 .515543445 Prob > F = 0.0882 Residual | 31.7573194 137 .231805251 R-squared = 0.0464 -------------+---------------------------------- Adj R-squared = 0.0256 Total | 33.3039497 140 .237885355 Root MSE = .48146 ------------------------------------------------------------------------------ PC | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hsGPA | .0327029 .1298817 0.25 0.802 -.2241292 .289535 ACT | .004272 .0154527 0.28 0.783 -.0262847 .0348286 parcoll | .2151862 .0862918 2.49 0.014 .04455 .3858224 _cons | .0262099 .4766498 0.05 0.956 -.9163323 .9687521 ------------------------------------------------------------------------------ . log close name: SN log: ~Wooldridge\intro-econx\iexample8.smcl log type: smcl closed on: 9 Jan 2019, 21:10:28 ------------------------------------------------------------------------------------------
Leave a Reply
Want to join the discussion?Feel free to contribute!