## INTRODUCTORY ECONOMETRICS – REPLICATING EXAMPLES

### Chapter 9 – Examples

```------------------------------------------------------------------------------------------
name:  SN
log:  ~Wooldridge\intro-econx\iexample9.smcl
log type:  smcl
opened on:  10 Jan 2019, 14:06:45
. **********************************************
. * Solomon Negash - Replicating Examples
. * Wooldridge (2016). Introductory Econometrics: A Modern Approach. 6th ed.
. * STATA Program, version 15.1.

. * Chapter 9  - More on Specification and Data Issues
. * Computer Exercises (Examples)
. ******************** SETUP *********************

. *Example 9.1. Economic Model of Crime
. u crime1, clear
. g avgsensq = avgsen^2
. local x "pcnv avgsen tottime ptime86 qemp86 inc86 black hispan"
. local x2 "pcnvsq pt86sq inc86sq"
. eststo hetrosked: qui reg narr86 `x'
. eststo robust: qui reg narr86 `x' `x2', r
. estout , cells(b(nostar fmt(4)) se(par fmt(4))) stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))
> varlabels(_cons intercept) varwidth(20) ti(Dependent Variables: narr86)

Dependent Variables: narr86
----------------------------------------------
hetrosked       robust
b/se         b/se
----------------------------------------------
pcnv                      -0.1332       0.5525
(0.0404)     (0.1702)
avgsen                    -0.0113      -0.0170
(0.0122)     (0.0142)
tottime                    0.0120       0.0120
(0.0094)     (0.0129)
ptime86                   -0.0408       0.2874
(0.0088)     (0.0694)
qemp86                    -0.0505      -0.0141
(0.0144)     (0.0168)
inc86                     -0.0015      -0.0034
(0.0003)     (0.0006)
black                      0.3265       0.2923
(0.0454)     (0.0581)
hispan                     0.1939       0.1636
(0.0397)     (0.0397)
pcnvsq                                 -0.7302
(0.1723)
pt86sq                                 -0.0296
(0.0058)
inc86sq                                 0.0000
(0.0000)
intercept                  0.5687       0.5046
(0.0360)     (0.0389)
----------------------------------------------
R-squared                   0.072        0.103
N               2725         2725
----------------------------------------------
. est clear

. *Example 9.2. Housing Price Equation
. 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
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 prhat, xb
. g prhat2=prhat^2
. g prhat3 = prhat^3
. reg price lotsize sqrft bdrms prhat2 prhat3

Source |       SS           df       MS      Number of obs   =        88
-------------+----------------------------------   F(5, 82)        =     39.35
Model |  647870.679         5  129574.136   Prob > F        =    0.0000
Residual |  269983.827        82  3292.48569   R-squared       =    0.7059
Total |  917854.506        87  10550.0518   Root MSE        =     57.38

------------------------------------------------------------------------------
price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lotsize |   .0001538    .005203     0.03   0.976    -.0101967    .0105043
sqrft |    .017602   .2992508     0.06   0.953    -.5777031    .6129071
bdrms |   2.175252    33.8881     0.06   0.949    -65.23897    69.58948
prhat2 |   .0003534   .0070989     0.05   0.960    -.0137687    .0144754
prhat3 |   1.55e-06   6.55e-06     0.24   0.814    -.0000115    .0000146
_cons |   166.0939   317.4324     0.52   0.602    -465.3803    797.5682
------------------------------------------------------------------------------
. test prhat2 prhat3
( 1)  prhat2 = 0
( 2)  prhat3 = 0
F(  2,    82) =    4.67
Prob > F =    0.0120

. 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
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 lprhat, xb
. g lprhat2=lprhat^2
. g lprhat3 = lprhat^3
. reg lprice llotsize lsqrft bdrms lprhat2 lprhat3

Source |       SS           df       MS      Number of obs   =        88
-------------+----------------------------------   F(5, 82)        =     32.41
Model |  5.32360036         5  1.06472007   Prob > F        =    0.0000
Residual |  2.69400316        82  .032853697   R-squared       =    0.6640
Total |  8.01760352        87  .092156362   Root MSE        =    .18126

------------------------------------------------------------------------------
lprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
llotsize |  -4.190767   12.59521    -0.33   0.740    -29.24665    20.86512
lsqrft |  -17.38995   52.48991    -0.33   0.741    -121.8091     87.0292
bdrms |   -.927485   2.769755    -0.33   0.739    -6.437411    4.582441
lprhat2 |   3.920341   13.01424     0.30   0.764    -21.96914    29.80982
lprhat3 |  -.1933459   .7520741    -0.26   0.798    -1.689461    1.302769
_cons |   88.07241   240.9744     0.37   0.716    -391.3024    567.4472
------------------------------------------------------------------------------
. test lprhat2 lprhat3
( 1)  lprhat2 = 0
( 2)  lprhat3 = 0
F(  2,    82) =    2.57
Prob > F =    0.0831

. *Example 9.3. IQ as a Proxy for Ability
. u wage2, clear
. eststo A: qui reg lwage educ exper tenur married south urban black
. eststo B: qui reg lwage educ exper tenur married south urban black IQ
. eststo C: qui reg lwage educ exper tenur married south urban black IQ c.educ#c.IQ
. estout , cells(b(nostar fmt(3)) se(par fmt(3))) stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))
> varlabels(_cons intercept) varwidth(20)  ti(Dependent Variables: log(wage))

Dependent Variables: log(wage)
-----------------------------------------------------------
A            B            C
b/se         b/se         b/se
-----------------------------------------------------------
educ                        0.065        0.054        0.018
(0.006)      (0.007)      (0.041)
exper                       0.014        0.014        0.014
(0.003)      (0.003)      (0.003)
tenure                      0.012        0.011        0.011
(0.002)      (0.002)      (0.002)
married                     0.199        0.200        0.201
(0.039)      (0.039)      (0.039)
south                      -0.091       -0.080       -0.080
(0.026)      (0.026)      (0.026)
urban                       0.184        0.182        0.184
(0.027)      (0.027)      (0.027)
black                      -0.188       -0.143       -0.147
(0.038)      (0.039)      (0.040)
IQ                                       0.004       -0.001
(0.001)      (0.005)
c.educ#c.IQ                                           0.000
(0.000)
intercept                   5.395        5.176        5.648
(0.113)      (0.128)      (0.546)
-----------------------------------------------------------
R-squared                   0.253        0.263        0.263
N                935          935          935
-----------------------------------------------------------
. est clear

. *Example 9.4. City Crime Rates
. u crime2, clear
. eststo A: qui reg lcrmrte unem llawexp if year==87
. eststo B: qui reg lcrmrte unem llawexp lcrmrt_1 if year==87
. estout , cells(b(nostar fmt(3)) se(par fmt(3))) stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))
>  varlabels(_cons intercept) varwidth(20) ti("Table 9.3 Dependent Variable: log(crmrte_87)")

Table 9.3 Dependent Variable: log(crmrte_87)
----------------------------------------------
A            B
b/se         b/se
----------------------------------------------
unem                       -0.029        0.009
(0.032)      (0.020)
llawexpc                    0.203       -0.140
(0.173)      (0.109)
lcrmrt_1                                 1.194
(0.132)
intercept                   3.343        0.076
(1.251)      (0.821)
----------------------------------------------
R-squared                   0.057        0.680
N                  46           46
----------------------------------------------
. est clear

. *Example 9.5. Savings Function with Measurement Error
. **NA

. *Example 9.6. Measurement Error in Scrap Rates
. **NA

. *Example 9.7. GPA Equation with Measurement Error
. **NA

. *Example 9.8. R&D Intensity and Firm Size
. u rdchem, clear
. reg rdintens sales profmarg

Source |       SS           df       MS      Number of obs   =        32
-------------+----------------------------------   F(2, 29)        =      1.19
Model |  8.28423732         2  4.14211866   Prob > F        =    0.3173
Residual |  100.549233        29  3.46721493   R-squared       =    0.0761
Total |   108.83347        31  3.51075711   Root MSE        =     1.862

------------------------------------------------------------------------------
rdintens |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
sales |   .0000534   .0000441     1.21   0.236    -.0000368    .0001435
profmarg |   .0446166   .0461805     0.97   0.342    -.0498332    .1390664
_cons |   2.625261   .5855328     4.48   0.000     1.427712     3.82281
------------------------------------------------------------------------------

. reg rdintens sales profmarg if sales<30000

Source |       SS           df       MS      Number of obs   =        31
-------------+----------------------------------   F(2, 28)        =      2.92
Model |  18.7880289         2  9.39401445   Prob > F        =    0.0702
Residual |  89.9330615        28  3.21189505   R-squared       =    0.1728
Total |   108.72109        30  3.62403635   Root MSE        =    1.7922

------------------------------------------------------------------------------
rdintens |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
sales |   .0001856   .0000842     2.20   0.036     .0000131    .0003581
profmarg |   .0478411   .0444831     1.08   0.291    -.0432784    .1389605
_cons |   2.296851   .5918045     3.88   0.001     1.084594    3.509107
------------------------------------------------------------------------------

. *Example 9.9. R&D Intensity
. u rdchem, 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
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
------------------------------------------------------------------------------

. reg lrd lsales profmarg if sales<30000

Source |       SS           df       MS      Number of obs   =        31
-------------+----------------------------------   F(2, 28)        =    131.42
Model |  71.7652353         2  35.8826176   Prob > F        =    0.0000
Residual |  7.64520626        28  .273043081   R-squared       =    0.9037
Total |  79.4104415        30  2.64701472   Root MSE        =    .52254

------------------------------------------------------------------------------
lrd |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lsales |   1.088047   .0671137    16.21   0.000     .9505712    1.225524
profmarg |   .0217552    .013024     1.67   0.106    -.0049232    .0484335
_cons |   -4.40414   .5110218    -8.62   0.000    -5.450921   -3.357359
------------------------------------------------------------------------------

. *Example 9.10. State Infant Mortality Rates
. u infmrt, clear
. reg infmort lpcinc lphysic lpopul if year==1990

Source |       SS           df       MS      Number of obs   =        51
-------------+----------------------------------   F(3, 47)        =      2.53
Model |   32.162998         3  10.7209993   Prob > F        =    0.0684
Residual |  199.084471        47  4.23583981   R-squared       =    0.1391
Total |  231.247469        50  4.62494938   Root MSE        =    2.0581

------------------------------------------------------------------------------
infmort |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lpcinc |  -4.684662   2.604124    -1.80   0.078    -9.923484    .5541607
lphysic |   4.153261   1.512659     2.75   0.009     1.110185    7.196338
lpopul |  -.0878224     .28725    -0.31   0.761    -.6656948    .4900499
_cons |   33.85931   20.42785     1.66   0.104    -7.236219    74.95484
------------------------------------------------------------------------------

. reg infmort lpcinc lphysic lpopul if year==1990 & DC==0

Source |       SS           df       MS      Number of obs   =        50
-------------+----------------------------------   F(3, 46)        =      5.76
Model |  26.8600265         3  8.95334216   Prob > F        =    0.0020
Residual |  71.4631754        46  1.55354729   R-squared       =    0.2732
Total |  98.3232019        49  2.00659596   Root MSE        =    1.2464

------------------------------------------------------------------------------
infmort |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lpcinc |  -.5669275   1.641216    -0.35   0.731    -3.870524    2.736669
lphysic |  -2.741837   1.190773    -2.30   0.026    -5.138739   -.3449347
lpopul |   .6292349   .1911062     3.29   0.002     .2445581    1.013912
_cons |   23.95479   12.41946     1.93   0.060    -1.044288    48.95388
------------------------------------------------------------------------------

. log close
name:  SN
log:  ~Wooldridge\intro-econx\iexample9.smcl
log type:  smcl
closed on:  10 Jan 2019, 14:06:46
------------------------------------------------------------------------------------------
```
0 replies