Stata Textbook Examples
Econometric Analysis of Cross Section and Panel Data by Jeffrey M. Wooldridge
Chapter 17: Sample Selection, Attrition, and Stratified Sampling

The data files used for the examples in this text can be downloaded in a zip file from the Stata Web site. You can then use a program such as zip to unzip the data files.
Example 17.6 on page 565 using mroz.dta.
use mroz, clear

reg lwage educ exper expersq 

      Source |       SS       df       MS              Number of obs =     428
-------------+------------------------------           F(  3,   424) =   26.29
       Model |  35.0222967     3  11.6740989           Prob > F      =  0.0000
    Residual |  188.305144   424  .444115906           R-squared     =  0.1568
-------------+------------------------------           Adj R-squared =  0.1509
       Total |  223.327441   427  .523015084           Root MSE      =  .66642

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .1074896   .0141465     7.60   0.000     .0796837    .1352956
       exper |   .0415665   .0131752     3.15   0.002     .0156697    .0674633
     expersq |  -.0008112   .0003932    -2.06   0.040    -.0015841   -.0000382
       _cons |  -.5220406   .1986321    -2.63   0.009    -.9124667   -.1316144
------------------------------------------------------------------------------

heckman lwage educ exper expersq, select(inlf=nwifeinc educ exper expersq age kidslt6 kidsge6) twostep

Heckman selection model -- two-step estimates   Number of obs      =       753
(regression model with sample selection)        Censored obs       =       325
                                                Uncensored obs     =       428

                                                Wald chi2(6)       =    180.10
                                                Prob > chi2        =    0.0000

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lwage        |
        educ |   .1090655    .015523     7.03   0.000     .0786411      .13949
       exper |   .0438873   .0162611     2.70   0.007     .0120163    .0757584
     expersq |  -.0008591   .0004389    -1.96   0.050    -.0017194    1.15e-06
       _cons |  -.5781032   .3050062    -1.90   0.058    -1.175904     .019698
-------------+----------------------------------------------------------------
inlf         |
    nwifeinc |  -.0120237   .0048398    -2.48   0.013    -.0215096   -.0025378
        educ |   .1309047   .0252542     5.18   0.000     .0814074     .180402
       exper |   .1233476   .0187164     6.59   0.000     .0866641    .1600311
     expersq |  -.0018871      .0006    -3.15   0.002     -.003063   -.0007111
         age |  -.0528527   .0084772    -6.23   0.000    -.0694678   -.0362376
     kidslt6 |  -.8683285   .1185223    -7.33   0.000    -1.100628    -.636029
     kidsge6 |    .036005   .0434768     0.83   0.408     -.049208    .1212179
       _cons |   .2700768    .508593     0.53   0.595    -.7267473    1.266901
-------------+----------------------------------------------------------------
mills        |
      lambda |   .0322619   .1336246     0.24   0.809    -.2296376    .2941613
-------------+----------------------------------------------------------------
         rho |    0.04861
       sigma |  .66362875
      lambda |  .03226186   .1336246
------------------------------------------------------------------------------

heckman lwage educ exper expersq nwifeinc age kidslt6 kidsge6, select(inlf=nwifeinc educ exper ///
	expersq age kidslt6 kidsge6) twostep mills(lambda)

Heckman selection model -- two-step estimates   Number of obs      =       753
(regression model with sample selection)        Censored obs       =       325
                                                Uncensored obs     =       428

                                                Wald chi2(14)      =    231.73
                                                Prob > chi2        =    0.0000

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lwage        |
        educ |   .1187171   .0340507     3.49   0.000      .051979    .1854553
       exper |   .0598358    .033673     1.78   0.076    -.0061621    .1258336
     expersq |  -.0010523   .0006381    -1.65   0.099     -.002303    .0001984
    nwifeinc |   .0038434   .0044919     0.86   0.392    -.0049607    .0126474
         age |   -.011158   .0134792    -0.83   0.408    -.0375767    .0152606
     kidslt6 |  -.1880451   .2308275    -0.81   0.415    -.6404586    .2643685
     kidsge6 |  -.0122255   .0296063    -0.41   0.680    -.0702527    .0458018
       _cons |  -.5602852   .4587672    -1.22   0.222    -1.459452    .3388819
-------------+----------------------------------------------------------------
inlf         |
    nwifeinc |  -.0120237   .0048398    -2.48   0.013    -.0215096   -.0025378
        educ |   .1309047   .0252542     5.18   0.000     .0814074     .180402
       exper |   .1233476   .0187164     6.59   0.000     .0866641    .1600311
     expersq |  -.0018871      .0006    -3.15   0.002     -.003063   -.0007111
         age |  -.0528527   .0084772    -6.23   0.000    -.0694678   -.0362376
     kidslt6 |  -.8683285   .1185223    -7.33   0.000    -1.100628    -.636029
     kidsge6 |    .036005   .0434768     0.83   0.408     -.049208    .1212179
       _cons |   .2700768    .508593     0.53   0.595    -.7267473    1.266901
-------------+----------------------------------------------------------------
mills        |
      lambda |   .2884635   .4635617     0.62   0.534    -.6201008    1.197028
-------------+----------------------------------------------------------------
         rho |    0.41830
       sigma |  .68961378
      lambda |  .28846351   .4635617
------------------------------------------------------------------------------

reg lambda nwifeinc educ exper expersq age kidslt6 kidsge6 if inlf

      Source |       SS       df       MS              Number of obs =     428
-------------+------------------------------           F(  7,   420) = 1519.49
       Model |  51.4583785     7  7.35119693           Prob > F      =  0.0000
    Residual |   2.0319395   420  .004837951           R-squared     =  0.9620
-------------+------------------------------           Adj R-squared =  0.9614
       Total |   53.490318   427  .125270066           Root MSE      =  .06956

------------------------------------------------------------------------------
      lambda |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    nwifeinc |   .0064163   .0003463    18.53   0.000     .0057355     .007097
        educ |  -.0652865   .0015751   -41.45   0.000    -.0683826   -.0621904
       exper |  -.0663031   .0013951   -47.53   0.000    -.0690454   -.0635608
     expersq |   .0010572   .0000419    25.22   0.000     .0009748    .0011396
         age |   .0264769   .0005649    46.87   0.000     .0253666    .0275873
     kidslt6 |    .458195   .0092439    49.57   0.000     .4400248    .4763651
     kidsge6 |  -.0187996   .0029099    -6.46   0.000    -.0245193   -.0130799
       _cons |   .7012603   .0332077    21.12   0.000     .6359863    .7665342
------------------------------------------------------------------------------
Example 17.7 on page 568 using mroz.dta.
use mroz, clear

probit inlf nwifeinc motheduc fatheduc huseduc exper expersq age kidslt6 kidsge6

Probit estimates                                  Number of obs   =        753
                                                  LR chi2(9)      =     207.10
                                                  Prob > chi2     =     0.0000
Log likelihood = -411.32238                       Pseudo R2       =     0.2011

------------------------------------------------------------------------------
        inlf |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    nwifeinc |  -.0074294   .0048787    -1.52   0.128    -.0169915    .0021327
    motheduc |   .0295321   .0185718     1.59   0.112     -.006868    .0659322
    fatheduc |   .0133487   .0178491     0.75   0.455    -.0216349    .0483324
     huseduc |   .0161391    .019595     0.82   0.410    -.0222664    .0545446
       exper |   .1285092   .0185226     6.94   0.000     .0922056    .1648129
     expersq |  -.0019474   .0005955    -3.27   0.001    -.0031146   -.0007803
         age |  -.0527657   .0085423    -6.18   0.000    -.0695082   -.0360231
     kidslt6 |  -.8149255   .1160833    -7.02   0.000    -1.042445   -.5874063
     kidsge6 |   .0241511   .0432253     0.56   0.576     -.060569    .1088712
       _cons |   1.146672   .4932706     2.32   0.020     .1798798    2.113465
------------------------------------------------------------------------------

predict xb, xb
gen lambda = normden(xb)/norm(xb)
ivreg lwage (educ =nwifeinc motheduc fatheduc huseduc age kidslt6 kidsge6 ) exper expersq lambda

Instrumental variables (2SLS) regression

      Source |       SS       df       MS              Number of obs =     428
-------------+------------------------------           F(  4,   423) =    9.44
       Model |  34.2001949     4  8.55004873           Prob > F      =  0.0000
    Residual |  189.127246   423  .447109329           R-squared     =  0.1531
-------------+------------------------------           Adj R-squared =  0.1451
       Total |  223.327441   427  .523015084           Root MSE      =  .66866

------------------------------------------------------------------------------
       lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        educ |   .0877631   .0214236     4.10   0.000     .0456531    .1298732
       exper |   .0457425   .0165895     2.76   0.006     .0131345    .0783505
     expersq |  -.0009128   .0004467    -2.04   0.042    -.0017909   -.0000347
      lambda |   .0404355   .1334279     0.30   0.762    -.2218287    .3026997
       _cons |  -.3249134   .3334547    -0.97   0.330    -.9803479    .3305212
------------------------------------------------------------------------------
Instrumented:  educ
Instruments:   exper expersq lambda nwifeinc motheduc fatheduc huseduc age
               kidslt6 kidsge6
------------------------------------------------------------------------------

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.