WOOLDRIDGE CROSS-SECTION & PANEL DATA ECONOMETRICS– EXAMPLES

CHAPTER 6  – Additional Single-Equation Topics

------------------------------------------------------------------------------------------
      name:  SN
       log:  myReplications\iiexample6
  log type:  smcl
 opened on:   6 Jun 2019, 00:53:26
. **********************************************

. * Solomon Negash - Examples
. * Wooldridge (2016). Economic Analysis of Cross-Section and Panel Data. 2nd ed.  
. * STATA Program, version 15.1. 

. * Chapter 6  - Additional Single-Equation Topics
. * Computer Exercises (Problems)
. * Nov 21, 2018
. ******************** SETUP *********************

. //Example 6.1  Testing for endogenity of educ in wage equation 
. bcuse mroz, clear nodesc
. reg educ exper* mothed fathed husedu

      Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(5, 747)       =    130.16
       Model |  1820.49038         5  364.098077   Prob > F        =    0.0000
    Residual |  2089.54946       747  2.79725496   R-squared       =    0.4656
-------------+----------------------------------   Adj R-squared   =    0.4620
       Total |  3910.03984       752  5.19952106   Root MSE        =    1.6725

------------------------------------------------------------------------------
        educ |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |   .0532406   .0218443     2.44   0.015     .0103571    .0961241
     expersq |  -.0007403    .000708    -1.05   0.296    -.0021303    .0006497
    motheduc |    .130004   .0223789     5.81   0.000      .086071    .1739371
    fatheduc |   .1013613   .0214423     4.73   0.000      .059267    .1434556
     huseduc |   .3715645   .0220465    16.85   0.000     .3282839     .414845
       _cons |   5.115778    .298017    17.17   0.000     4.530727    5.700828
------------------------------------------------------------------------------

. predict v2, residual
. reg lwage exper* educ v2

      Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(4, 423)       =     20.52
       Model |   36.285365         4  9.07134126   Prob > F        =    0.0000
    Residual |  187.042086       423  .442179873   R-squared       =    0.1625
-------------+----------------------------------   Adj R-squared   =    0.1546
       Total |  223.327451       427  .523015108   Root MSE        =    .66497

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |   .0438739   .0132172     3.32   0.001     .0178945    .0698534
     expersq |  -.0008708    .000394    -2.21   0.028    -.0016452   -.0000964
        educ |   .0801296   .0214782     3.73   0.000     .0379123     .122347
          v2 |   .0478873    .028334     1.69   0.092    -.0078056    .1035803
       _cons |  -.2008037   .2746073    -0.73   0.465    -.7405684    .3389611
------------------------------------------------------------------------------

. //Example 6.2
. bcuse card, clear nodesc
. gen b_edu=black*edu
. reg lwage educ black b_edu exper* smsa smsa66 south reg661-reg668

      Source |       SS           df       MS      Number of obs   =     3,010
-------------+----------------------------------   F(16, 2993)     =     80.83
       Model |  178.817017        16  11.1760636   Prob > F        =    0.0000
    Residual |  413.824594     2,993  .138264148   R-squared       =    0.3017
-------------+----------------------------------   Adj R-squared   =    0.2980
       Total |  592.641611     3,009  .196956335   Root MSE        =    .37184

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .0707788   .0037548    18.85   0.000     .0634165    .0781411
       black |  -.4191076   .0794021    -5.28   0.000    -.5747958   -.2634194
       b_edu |   .0178595    .006271     2.85   0.004     .0055636    .0301554
       exper |   .0821556   .0066828    12.29   0.000     .0690522    .0952589
     expersq |  -.0021349   .0003207    -6.66   0.000    -.0027638    -.001506
        smsa |   .1340695   .0200931     6.67   0.000     .0946718    .1734671
      smsa66 |   .0249824   .0194297     1.29   0.199    -.0131144    .0630793
       south |  -.1441927   .0259827    -5.55   0.000    -.1951384    -.093247
      reg661 |  -.1221745   .0388047    -3.15   0.002    -.1982611    -.046088
      reg662 |  -.0232881   .0282266    -0.83   0.409    -.0786336    .0320574
      reg663 |   .0230953   .0273506     0.84   0.399    -.0305325    .0767231
      reg664 |  -.0666851   .0356556    -1.87   0.062    -.1365971    .0032269
      reg665 |   .0032644     .03614     0.09   0.928    -.0675974    .0741261
      reg666 |   .0151249   .0401224     0.38   0.706    -.0635454    .0937952
      reg667 |  -.0074966   .0394073    -0.19   0.849    -.0847648    .0697716
      reg668 |  -.1757195   .0462851    -3.80   0.000    -.2664733   -.0849657
       _cons |    4.80677   .0752604    63.87   0.000     4.659202    4.954337
------------------------------------------------------------------------------
. //
. gen b_nearc4=black*nearc4
. qui reg educ black exper* smsa smsa66 south reg661-reg668 nearc4 b_nearc4
. predict v21, residual
. qui reg b_edu black exper* smsa smsa66 south reg661-reg668 nearc4 b_nearc4
. predict v22, residual
. reg lwage educ b_edu black exper* smsa smsa66 south reg661-reg668 v2*

      Source |       SS           df       MS      Number of obs   =     3,010
-------------+----------------------------------   F(18, 2991)     =     71.89
       Model |  178.967071        18  9.94261507   Prob > F        =    0.0000
    Residual |   413.67454     2,991  .138306433   R-squared       =    0.3020
-------------+----------------------------------   Adj R-squared   =    0.2978
       Total |  592.641611     3,009  .196956335   Root MSE        =     .3719

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .1273556   .0547317     2.33   0.020       .02004    .2346712
       b_edu |   .0109036   .0387795     0.28   0.779    -.0651337    .0869408
       black |   -.282765   .4866263    -0.58   0.561    -1.236921    .6713912
       exper |   .1059116   .0241963     4.38   0.000     .0584685    .1533547
     expersq |  -.0022406   .0004635    -4.83   0.000    -.0031493   -.0013318
        smsa |   .1111556   .0304028     3.66   0.000     .0515431    .1707681
      smsa66 |   .0180009   .0207769     0.87   0.386    -.0227375    .0587393
       south |  -.1424762   .0272675    -5.23   0.000    -.1959412   -.0890112
      reg661 |  -.1103479   .0410557    -2.69   0.007    -.1908481   -.0298477
      reg662 |  -.0081783   .0317789    -0.26   0.797     -.070489    .0541325
      reg663 |   .0382414   .0314436     1.22   0.224    -.0234119    .0998946
      reg664 |  -.0600379   .0368007    -1.63   0.103    -.1321951    .0121194
      reg665 |   .0337805   .0479745     0.70   0.481     -.060286    .1278469
      reg666 |   .0498975   .0537534     0.93   0.353    -.0554998    .1552948
      reg667 |   .0216942   .0501526     0.43   0.665    -.0766428    .1200312
      reg668 |  -.1908353   .0485659    -3.93   0.000    -.2860613   -.0956092
         v21 |  -.0568274   .0548612    -1.04   0.300    -.1643969    .0507422
         v22 |   .0070106   .0392971     0.18   0.858    -.0700415    .0840627
       _cons |    3.84499   .9314527     4.13   0.000     2.018638    5.671343
------------------------------------------------------------------------------

. test v21 v22

 ( 1)  v21 = 0
 ( 2)  v22 = 0

       F(  2,  2991) =    0.54
            Prob > F =    0.5814

. ivreg lwage (educ  b_edu = nearc4 b_nearc4) black exper* smsa smsa66 south reg661-reg668

Instrumental variables (2SLS) regression

      Source |       SS           df       MS      Number of obs   =     3,010
-------------+----------------------------------   F(16, 2993)     =     48.15
       Model |  144.325574        16  9.02034836   Prob > F        =    0.0000
    Residual |  448.316037     2,993  .149788185   R-squared       =    0.2435
-------------+----------------------------------   Adj R-squared   =    0.2395
       Total |  592.641611     3,009  .196956335   Root MSE        =    .38702

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .1273556   .0569582     2.24   0.025     .0156743    .2390369
       b_edu |   .0109036   .0403571     0.27   0.787    -.0682269    .0900341
       black |   -.282765   .5064227    -0.56   0.577    -1.275737    .7102069
       exper |   .1059116   .0251806     4.21   0.000     .0565385    .1552847
     expersq |  -.0022406   .0004823    -4.65   0.000    -.0031863   -.0012949
        smsa |   .1111556   .0316396     3.51   0.000      .049118    .1731932
      smsa66 |   .0180009   .0216221     0.83   0.405    -.0243947    .0603966
       south |  -.1424762   .0283768    -5.02   0.000    -.1981161   -.0868362
      reg661 |  -.1103479   .0427258    -2.58   0.010    -.1941229   -.0265729
      reg662 |  -.0081783   .0330717    -0.25   0.805    -.0730239    .0566673
      reg663 |   .0382414   .0327227     1.17   0.243      -.02592    .1024027
      reg664 |  -.0600379   .0382978    -1.57   0.117    -.1351305    .0150548
      reg665 |   .0337805   .0499262     0.68   0.499    -.0641127    .1316736
      reg666 |   .0498975   .0559401     0.89   0.372    -.0597874    .1595825
      reg667 |   .0216942   .0521928     0.42   0.678    -.0806432    .1240317
      reg668 |  -.1908353   .0505417    -3.78   0.000    -.2899352   -.0917354
       _cons |   3.844991    .969345     3.97   0.000     1.944341    5.745641
------------------------------------------------------------------------------
Instrumented:  educ b_edu
Instruments:   black exper expersq smsa smsa66 south reg661 reg662 reg663
               reg664 reg665 reg666 reg667 reg668 nearc4 b_nearc4
------------------------------------------------------------------------------


. //Example 6.3 Overidentifying restriction in the wage equation
. bcuse mroz, clear nodesc
. ivreg lwage exper* (educ=mothed fathed hused)

Instrumental variables (2SLS) regression

      Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(3, 424)       =     11.52
       Model |  33.3927427         3  11.1309142   Prob > F        =    0.0000
    Residual |  189.934709       424  .447959218   R-squared       =    0.1495
-------------+----------------------------------   Adj R-squared   =    0.1435
       Total |  223.327451       427  .523015108   Root MSE        =     .6693

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .0803918    .021774     3.69   0.000     .0375934    .1231901
       exper |   .0430973   .0132649     3.25   0.001     .0170242    .0691704
     expersq |  -.0008628   .0003962    -2.18   0.030    -.0016415   -.0000841
       _cons |  -.1868574   .2853959    -0.65   0.513    -.7478243    .3741096
------------------------------------------------------------------------------
Instrumented:  educ
Instruments:   exper expersq motheduc fatheduc huseduc
------------------------------------------------------------------------------

. predict u, residual
(325 missing values generated)

. reg u exper* mothed fathed hused

      Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(5, 422)       =      0.22
       Model |  .494825844         5  .098965169   Prob > F        =    0.9537
    Residual |  189.439884       422  .448909678   R-squared       =    0.0026
-------------+----------------------------------   Adj R-squared   =   -0.0092
       Total |   189.93471       427  .444811967   Root MSE        =    .67001

------------------------------------------------------------------------------
           u |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |    .000056   .0132285     0.00   0.997     -.025946     .026058
     expersq |  -8.88e-06   .0003956    -0.02   0.982    -.0007865    .0007687
    motheduc |  -.0103852   .0118688    -0.87   0.382    -.0337145    .0129442
    fatheduc |   .0006734   .0113798     0.06   0.953    -.0216948    .0230417
     huseduc |   .0067811   .0114259     0.59   0.553    -.0156776    .0292398
       _cons |   .0086063   .1772724     0.05   0.961    -.3398405    .3570532
------------------------------------------------------------------------------

. display "LM = " e(N)* e(r2) " & p = " chi2tail(2, e(r2)*e(N))
LM = 1.1150435 & p = .57262642


. //Hetroskedasticity Robust
. ivreg lwage exper* (educ=mothed fathed hused), r

Instrumental variables (2SLS) regression        Number of obs     =        428
                                                F(3, 424)         =       9.19
                                                Prob > F          =     0.0000
                                                R-squared         =     0.1495
                                                Root MSE          =      .6693

------------------------------------------------------------------------------
             |               Robust
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .0803918   .0217033     3.70   0.000     .0377323    .1230512
       exper |   .0430973   .0153064     2.82   0.005     .0130114    .0731832
     expersq |  -.0008628   .0004217    -2.05   0.041    -.0016916    -.000034
       _cons |  -.1868574   .3012625    -0.62   0.535    -.7790113    .4052966
------------------------------------------------------------------------------
Instrumented:  educ
Instruments:   exper expersq motheduc fatheduc huseduc
------------------------------------------------------------------------------


. //Hetroskedasticity using LM statistic page137
. reg edu exper* mothed fathed hused

      Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(5, 747)       =    130.16
       Model |  1820.49038         5  364.098077   Prob > F        =    0.0000
    Residual |  2089.54946       747  2.79725496   R-squared       =    0.4656
-------------+----------------------------------   Adj R-squared   =    0.4620
       Total |  3910.03984       752  5.19952106   Root MSE        =    1.6725

------------------------------------------------------------------------------
        educ |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |   .0532406   .0218443     2.44   0.015     .0103571    .0961241
     expersq |  -.0007403    .000708    -1.05   0.296    -.0021303    .0006497
    motheduc |    .130004   .0223789     5.81   0.000      .086071    .1739371
    fatheduc |   .1013613   .0214423     4.73   0.000      .059267    .1434556
     huseduc |   .3715645   .0220465    16.85   0.000     .3282839     .414845
       _cons |   5.115778    .298017    17.17   0.000     4.530727    5.700828
------------------------------------------------------------------------------

. predict eduhat, xb
. reg mothed exper* eduhat

      Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(3, 749)       =    187.97
       Model |  3662.73307         3  1220.91102   Prob > F        =    0.0000
    Residual |  4864.82868       749  6.49509837   R-squared       =    0.4295
-------------+----------------------------------   Adj R-squared   =    0.4272
       Total |  8527.56175       752  11.3398428   Root MSE        =    2.5485

------------------------------------------------------------------------------
    motheduc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |  -.1051582   .0337061    -3.12   0.002    -.1713279   -.0389885
     expersq |   .0015231   .0010851     1.40   0.161     -.000607    .0036532
      eduhat |   1.425138   .0608066    23.44   0.000     1.305767     1.54451
       _cons |  -7.412718   .7419038    -9.99   0.000    -8.869176    -5.95626
------------------------------------------------------------------------------

. predict r1, residual
. reg fathed exper* eduhat

      Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(3, 749)       =    197.80
       Model |  4242.00753         3  1414.00251   Prob > F        =    0.0000
    Residual |  5354.45462       749  7.14880456   R-squared       =    0.4420
-------------+----------------------------------   Adj R-squared   =    0.4398
       Total |  9596.46215       752  12.7612529   Root MSE        =    2.6737

------------------------------------------------------------------------------
    fatheduc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |  -.1068543   .0353617    -3.02   0.003    -.1762741   -.0374346
     expersq |   .0014908   .0011384     1.31   0.191    -.0007439    .0037256
      eduhat |   1.534126   .0637932    24.05   0.000     1.408891     1.65936
       _cons |  -9.170285   .7783437   -11.78   0.000    -10.69828    -7.64229
------------------------------------------------------------------------------

. predict r2, residual
. gen one=1
. reg one c.u#c.r1 c.u#c.r2, noc

      Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(2, 426)       =      0.51
       Model |  1.01874532         2  .509372658   Prob > F        =    0.6019
    Residual |  426.981255       426  1.00230341   R-squared       =    0.0024
-------------+----------------------------------   Adj R-squared   =   -0.0023
       Total |         428       428           1   Root MSE        =    1.0012

------------------------------------------------------------------------------
         one |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    c.u#c.r1 |  -.0270098    .028959    -0.93   0.352    -.0839302    .0299106
             |
    c.u#c.r2 |  -.0004977   .0307894    -0.02   0.987    -.0610157    .0600203
------------------------------------------------------------------------------

. display "LM = " e(N) - e(rss) " & p = " chi2tail(2, e(r2)*e(N))
LM = 1.0187453 & p = .60087241

. //Example 6.4 Testing for neglected nonlinearities in a wage equation
. bcuse nls80, clear nodesc
. reg lwage exper tenure married south urban black educ

      Source |       SS           df       MS      Number of obs   =       935
-------------+----------------------------------   F(7, 927)       =     44.75
       Model |  41.8377619         7  5.97682312   Prob > F        =    0.0000
    Residual |  123.818521       927  .133569063   R-squared       =    0.2526
-------------+----------------------------------   Adj R-squared   =    0.2469
       Total |  165.656283       934  .177362188   Root MSE        =    .36547

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |    .014043   .0031852     4.41   0.000      .007792     .020294
      tenure |   .0117473    .002453     4.79   0.000     .0069333    .0165613
     married |   .1994171   .0390502     5.11   0.000     .1227801     .276054
       south |  -.0909036   .0262485    -3.46   0.001     -.142417   -.0393903
       urban |   .1839121   .0269583     6.82   0.000     .1310056    .2368185
       black |  -.1883499   .0376666    -5.00   0.000    -.2622717   -.1144281
        educ |   .0654307   .0062504    10.47   0.000     .0531642    .0776973
       _cons |   5.395497    .113225    47.65   0.000      5.17329    5.617704
------------------------------------------------------------------------------

. predict u, residual
. predict lwageh, xb
. gen lwage2 = lwageh^2
. gen lwage3 = lwageh^3
. reg u exper tenure married south urban black educ lwage2 lwage3 

      Source |       SS           df       MS      Number of obs   =       935
-------------+----------------------------------   F(9, 925)       =      0.04
       Model |  .043635869         9   .00484843   Prob > F        =    1.0000
    Residual |  123.774885       925  .133810687   R-squared       =    0.0004
-------------+----------------------------------   Adj R-squared   =   -0.0094
       Total |  123.818521       934   .13256801   Root MSE        =     .3658

------------------------------------------------------------------------------
           u |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       exper |  -.7632267   1.397385    -0.55   0.585     -3.50564    1.979186
      tenure |  -.6384821   1.169016    -0.55   0.585    -2.932713    1.655748
     married |  -10.83869    19.8426    -0.55   0.585    -49.78043    28.10305
       south |   4.941136   9.046332     0.55   0.585    -12.81258    22.69485
       urban |  -9.997095   18.30255    -0.55   0.585    -45.91644    25.92225
       black |   10.23873   18.74209     0.55   0.585    -26.54323    47.02068
        educ |  -3.555951   6.510939    -0.55   0.585    -16.33388    9.221974
      lwage2 |   8.092523   14.74836     0.55   0.583    -20.85161    37.03666
      lwage3 |  -.4012701   .7281559    -0.55   0.582    -1.830299    1.027759
       _cons |  -171.6899   313.2923    -0.55   0.584    -786.5359    443.1562
------------------------------------------------------------------------------

. display "LM = " e(N)* e(r2) " & p = " chi2tail(2, e(r2)*e(N))
LM = .32951078 & p = .84810113

. //Example 6.5 Length of Time on Workers Compensation
. bcuse injury, clear nodesc
. reg ldurat afchnge highearn c.afchnge#c.highearn if ky==1

      Source |       SS           df       MS      Number of obs   =     5,626
-------------+----------------------------------   F(3, 5622)      =     39.54
       Model |  191.071427         3  63.6904757   Prob > F        =    0.0000
    Residual |  9055.93393     5,622   1.6108029   R-squared       =    0.0207
-------------+----------------------------------   Adj R-squared   =    0.0201
       Total |  9247.00536     5,625  1.64391206   Root MSE        =    1.2692

--------------------------------------------------------------------------------------
              ldurat |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
---------------------+----------------------------------------------------------------
             afchnge |   .0076573   .0447173     0.17   0.864    -.0800058    .0953204
            highearn |   .2564785   .0474464     5.41   0.000     .1634652    .3494918
                     |
c.afchnge#c.highearn |   .1906012   .0685089     2.78   0.005     .0562973    .3249051
                     |
               _cons |   1.125615   .0307368    36.62   0.000     1.065359    1.185871
--------------------------------------------------------------------------------------

. log close 
      name:  SN
       log:  myReplications\iiexample6
  log type:  smcl
 closed on:   6 Jun 2019, 00:53:31
------------------------------------------------------------------------------------------
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.