## Chapter 15 - Binary Response Models

### Examples

```------------------------------------------------------------------------------------------
name:  SN
log:  myReplications\iiexample15.smcl
log type:  smcl
opened on:   9 May 2020, 17:51:45
. **********************************************
. * Solomon Negash - Examples
. * Wooldridge (2010). Economic Analysis of Cross-Section and Panel Data. 2nd ed.
. * STATA Program, version 16.1.

. * Chapter 15  - Binary Response Models
. ********************************************

. // Example 15.1 (Married Women's Labor Force Participation)

. bcuse mroz, clear nodesc

. eststo Hetrosced: reg inlf nwifeinc exper expersq educ age kidslt6 kidsge6

Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(7, 745)       =     38.22
Model |  48.8080578         7  6.97257968   Prob > F        =    0.0000
Residual |  135.919698       745  .182442547   R-squared       =    0.2642
Total |  184.727756       752  .245648611   Root MSE        =    .42713

------------------------------------------------------------------------------
inlf |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0034052   .0014485    -2.35   0.019    -.0062488   -.0005616
exper |   .0394924   .0056727     6.96   0.000     .0283561    .0506287
expersq |  -.0005963   .0001848    -3.23   0.001    -.0009591   -.0002335
educ |   .0379953    .007376     5.15   0.000      .023515    .0524756
age |  -.0160908   .0024847    -6.48   0.000    -.0209686    -.011213
kidslt6 |  -.2618105   .0335058    -7.81   0.000    -.3275875   -.1960335
kidsge6 |   .0130122    .013196     0.99   0.324    -.0128935    .0389179
_cons |   .5855192    .154178     3.80   0.000     .2828442    .8881943
------------------------------------------------------------------------------

. eststo Robust: reg inlf nwifeinc exper expersq educ age kidslt6 kidsge6, r

Linear regression                               Number of obs     =        753
F(7, 745)         =      62.48
Prob > F          =     0.0000
R-squared         =     0.2642
Root MSE          =     .42713

------------------------------------------------------------------------------
|               Robust
inlf |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0034052   .0015249    -2.23   0.026    -.0063988   -.0004115
exper |   .0394924     .00581     6.80   0.000     .0280864    .0508983
expersq |  -.0005963     .00019    -3.14   0.002    -.0009693   -.0002233
educ |   .0379953    .007266     5.23   0.000      .023731    .0522596
age |  -.0160908    .002399    -6.71   0.000    -.0208004   -.0113812
kidslt6 |  -.2618105   .0317832    -8.24   0.000    -.3242058   -.1994152
kidsge6 |   .0130122   .0135329     0.96   0.337     -.013555    .0395795
_cons |   .5855192   .1522599     3.85   0.000     .2866098    .8844287
------------------------------------------------------------------------------

. estout, cells(b(nostar fmt(4)) se(par fmt(4)))  ///
stats(ll r2 r2_p N, fmt(%9.3f %9.0g) labels(Log-Likelihood R-squared Psuedo-R2 N))

--------------------------------------
Hetrosced       Robust
b/se         b/se
--------------------------------------
nwifeinc          -0.0034      -0.0034
(0.0014)     (0.0015)
exper              0.0395       0.0395
(0.0057)     (0.0058)
expersq           -0.0006      -0.0006
(0.0002)     (0.0002)
educ               0.0380       0.0380
(0.0074)     (0.0073)
age               -0.0161      -0.0161
(0.0025)     (0.0024)
kidslt6           -0.2618      -0.2618
(0.0335)     (0.0318)
kidsge6            0.0130       0.0130
(0.0132)     (0.0135)
_cons              0.5855       0.5855
(0.1542)     (0.1523)
--------------------------------------
Log-Likeli~d     -423.892     -423.892
R-squared        .2642162     .2642162
Psuedo-R2
N                     753          753
--------------------------------------

. eststo clear

. // Example 15.2 (Married Women's Labor Force Participation

. eststo LPM: reg inlf nwifeinc exper expersq educ age kidslt6 kidsge6

Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(7, 745)       =     38.22
Model |  48.8080578         7  6.97257968   Prob > F        =    0.0000
Residual |  135.919698       745  .182442547   R-squared       =    0.2642
Total |  184.727756       752  .245648611   Root MSE        =    .42713

------------------------------------------------------------------------------
inlf |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0034052   .0014485    -2.35   0.019    -.0062488   -.0005616
exper |   .0394924   .0056727     6.96   0.000     .0283561    .0506287
expersq |  -.0005963   .0001848    -3.23   0.001    -.0009591   -.0002335
educ |   .0379953    .007376     5.15   0.000      .023515    .0524756
age |  -.0160908   .0024847    -6.48   0.000    -.0209686    -.011213
kidslt6 |  -.2618105   .0335058    -7.81   0.000    -.3275875   -.1960335
kidsge6 |   .0130122    .013196     0.99   0.324    -.0128935    .0389179
_cons |   .5855192    .154178     3.80   0.000     .2828442    .8881943
------------------------------------------------------------------------------

. eststo Logit: logit inlf nwifeinc exper expersq educ age kidslt6 kidsge6, nolog

Logistic regression                             Number of obs     =        753
LR chi2(7)        =     226.22
Prob > chi2       =     0.0000
Log likelihood = -401.76515                     Pseudo R2         =     0.2197

------------------------------------------------------------------------------
inlf |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0213452   .0084214    -2.53   0.011    -.0378509   -.0048394
exper |   .2058695   .0320569     6.42   0.000     .1430391    .2686999
expersq |  -.0031541   .0010161    -3.10   0.002    -.0051456   -.0011626
educ |   .2211704   .0434396     5.09   0.000     .1360303    .3063105
age |  -.0880244    .014573    -6.04   0.000     -.116587   -.0594618
kidslt6 |  -1.443354   .2035849    -7.09   0.000    -1.842373   -1.044335
kidsge6 |   .0601122   .0747897     0.80   0.422     -.086473    .2066974
_cons |   .4254524   .8603697     0.49   0.621    -1.260841    2.111746
------------------------------------------------------------------------------

. eststo Probit: probit inlf nwifeinc exper expersq educ age kidslt6 kidsge6, nolog

Probit regression                               Number of obs     =        753
LR chi2(7)        =     227.14
Prob > chi2       =     0.0000
Log likelihood = -401.30219                     Pseudo R2         =     0.2206

------------------------------------------------------------------------------
inlf |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0120237   .0048398    -2.48   0.013    -.0215096   -.0025378
exper |   .1233476   .0187164     6.59   0.000     .0866641    .1600311
expersq |  -.0018871      .0006    -3.15   0.002     -.003063   -.0007111
educ |   .1309047   .0252542     5.18   0.000     .0814074     .180402
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    -.7267472    1.266901
------------------------------------------------------------------------------

. estout, cells(b(nostar fmt(4)) se(par fmt(4))) stats(ll r2 r2_p N, ///
fmt(%9.3f %9.0g) labels(Log-Likelihood R-squared Psuedo-R2 N)) ///
ti("Table 15.1 LPM, Logit, and Probit Estimates of Labor Force Participation: (inlf)")

Table 15.1 LPM, Logit, and Probit Estimates of Labor Force Participation: (inlf)
---------------------------------------------------
LPM        Logit       Probit
b/se         b/se         b/se
---------------------------------------------------
main
nwifeinc          -0.0034      -0.0213      -0.0120
(0.0014)     (0.0084)     (0.0048)
exper              0.0395       0.2059       0.1233
(0.0057)     (0.0321)     (0.0187)
expersq           -0.0006      -0.0032      -0.0019
(0.0002)     (0.0010)     (0.0006)
educ               0.0380       0.2212       0.1309
(0.0074)     (0.0434)     (0.0253)
age               -0.0161      -0.0880      -0.0529
(0.0025)     (0.0146)     (0.0085)
kidslt6           -0.2618      -1.4434      -0.8683
(0.0335)     (0.2036)     (0.1185)
kidsge6            0.0130       0.0601       0.0360
(0.0132)     (0.0748)     (0.0435)
_cons              0.5855       0.4255       0.2701
(0.1542)     (0.8604)     (0.5086)
---------------------------------------------------
Log-Likeli~d     -423.892     -401.765     -401.302
R-squared        .2642162
Psuedo-R2                     .2196814     .2205805
N                     753          753          753
---------------------------------------------------

. eststo clear

. // Example 15.3 (Testing Exogeneity of Education in the Women's LFP Model) (Page 587)

. reg educ nwifeinc exper expersq age kidslt6 kidsge6 motheduc fatheduc huseduc

Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(9, 743)       =     74.07
Model |  1849.07781         9   205.45309   Prob > F        =    0.0000
Residual |  2060.96203       743  2.77383853   R-squared       =    0.4729
Total |  3910.03984       752  5.19952106   Root MSE        =    1.6655

------------------------------------------------------------------------------
educ |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |   .0156893   .0058267     2.69   0.007     .0042506     .027128
exper |   .0577544   .0220604     2.62   0.009     .0144462    .1010625
expersq |   -.000784    .000721    -1.09   0.277    -.0021994    .0006314
age |  -.0059011   .0098709    -0.60   0.550    -.0252792     .013477
kidslt6 |   .1195954   .1307071     0.91   0.360    -.1370038    .3761945
kidsge6 |  -.0731404   .0515299    -1.42   0.156     -.174302    .0280212
motheduc |   .1300347   .0225669     5.76   0.000     .0857322    .1743373
fatheduc |   .0950702   .0214618     4.43   0.000     .0529373    .1372032
huseduc |   .3475092   .0235063    14.78   0.000     .3013626    .3936558
_cons |    5.43695   .5873755     9.26   0.000     4.283837    6.590064
------------------------------------------------------------------------------

. predict v2, r

. probit inlf nwifeinc exper expersq educ age kidslt6 kidsge6 v2, nolog

Probit regression                               Number of obs     =        753
LR chi2(8)        =     227.90
Prob > chi2       =     0.0000
Log likelihood = -400.92551                     Pseudo R2         =     0.2213

------------------------------------------------------------------------------
inlf |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0102851   .0052347    -1.96   0.049     -.020545   -.0000253
exper |   .1262477   .0190256     6.64   0.000     .0889582    .1635373
expersq |  -.0019432   .0006032    -3.22   0.001    -.0031254   -.0007609
educ |   .1035752   .0403061     2.57   0.010     .0245767    .1825737
age |  -.0543808   .0086633    -6.28   0.000    -.0713605   -.0374012
kidslt6 |  -.8630859   .1187394    -7.27   0.000    -1.095811    -.630361
kidsge6 |   .0313802   .0437901     0.72   0.474    -.0544468    .1172071
v2 |   .0433658    .050021     0.87   0.386    -.0546736    .1414051
_cons |   .6209105   .6497413     0.96   0.339     -.652559     1.89438
------------------------------------------------------------------------------

. // Example 15.3 (Endogeniety of Nonwife income in the Women's LFP Model) (Page 589)

. reg nwifeinc huseduc educ exper expersq age kidslt6 kidsge6

Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(7, 745)       =     27.13
Model |  20676.7702         7  2953.82432   Prob > F        =    0.0000
Residual |  81120.3455       745   108.88637   R-squared       =    0.2031
Total |  101797.116       752  135.368505   Root MSE        =    10.435

------------------------------------------------------------------------------
nwifeinc |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
huseduc |   1.178155   .1609449     7.32   0.000     .8621956    1.494115
educ |   .6746951   .2136829     3.16   0.002     .2552029    1.094187
exper |  -.3129878   .1382549    -2.26   0.024    -.5844034   -.0415721
expersq |  -.0004776   .0045196    -0.11   0.916    -.0093501     .008395
age |   .3401521   .0597084     5.70   0.000     .2229354    .4573687
kidslt6 |   .8262718   .8183785     1.01   0.313    -.7803306    2.432874
kidsge6 |   .4355289   .3219888     1.35   0.177    -.1965845    1.067642
_cons |  -14.72048   3.787326    -3.89   0.000    -22.15559   -7.285382
------------------------------------------------------------------------------

. predict v3, r

. probit inlf nwifeinc exper expersq educ age kidslt6 kidsge6 v3, nolog

Probit regression                               Number of obs     =        753
LR chi2(8)        =     229.14
Prob > chi2       =     0.0000
Log likelihood = -400.30301                     Pseudo R2         =     0.2225

------------------------------------------------------------------------------
inlf |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0368641   .0182706    -2.02   0.044    -.0726738   -.0010543
exper |   .1163123   .0193312     6.02   0.000     .0784239    .1542007
expersq |  -.0019459   .0006009    -3.24   0.001    -.0031235   -.0007682
educ |   .1702153   .0376718     4.52   0.000     .0963798    .2440507
age |   -.044953   .0101367    -4.43   0.000    -.0648206   -.0250855
kidslt6 |  -.8444363   .1198154    -7.05   0.000     -1.07927   -.6096025
kidsge6 |   .0477905   .0443204     1.08   0.281    -.0390758    .1346568
v3 |   .0267093   .0189352     1.41   0.158    -.0104031    .0638217
_cons |   .0171187   .5392914     0.03   0.975    -1.039873     1.07411
------------------------------------------------------------------------------

. margeff

Average marginal effects on Prob(inlf==1) after probit

------------------------------------------------------------------------------
inlf |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
nwifeinc |  -.0110576   .0054418    -2.03   0.042    -.0217234   -.0003918
exper |   .0348887   .0053903     6.47   0.000     .0243239    .0454535
expersq |  -.0005837   .0001767    -3.30   0.001    -.0009299   -.0002374
educ |   .0510572   .0108776     4.69   0.000     .0297375    .0723769
age |   -.013484   .0029275    -4.61   0.000    -.0192217   -.0077463
kidslt6 |  -.2532945   .0324497    -7.81   0.000    -.3168947   -.1896942
kidsge6 |   .0143351   .0132656     1.08   0.280    -.0116651    .0403353
v3 |   .0080116     .00566     1.42   0.157    -.0030817     .019105
------------------------------------------------------------------------------

. // Example 15.4. (Women's Labor Force Participation and Having More than Two Children)

. u labsup, clear

. g agesq= age^2

. eststo LPM_OLS: reg worked morekids nonmomi educ age agesq black hispan

Source |       SS           df       MS      Number of obs   =    31,857
-------------+----------------------------------   F(7, 31849)     =    405.04
Model |  630.048635         7  90.0069478   Prob > F        =    0.0000
Residual |  7077.35169    31,849  .222215821   R-squared       =    0.0817
Total |  7707.40032    31,856  .241945013   Root MSE        =     .4714

------------------------------------------------------------------------------
worked |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
morekids |  -.1091198   .0054742   -19.93   0.000    -.1198495   -.0983901
nonmomi |  -.0011675   .0001354    -8.63   0.000    -.0014328   -.0009022
educ |   .0206475   .0009053    22.81   0.000     .0188731    .0224219
age |   .0562704   .0112458     5.00   0.000     .0342282    .0783125
agesq |  -.0007829   .0001932    -4.05   0.000    -.0011616   -.0004041
black |   .0176482   .0338829     0.52   0.602    -.0487636      .08406
hispan |  -.1285859   .0339362    -3.79   0.000    -.1951022   -.0620696
_cons |   -.448645   .1649612    -2.72   0.007    -.7719752   -.1253148
------------------------------------------------------------------------------

. eststo Probit: probit worked morekids nonmomi educ age agesq black hispan, nolog

Probit regression                               Number of obs     =     31,857
LR chi2(7)        =    2693.96
Prob > chi2       =     0.0000
Log likelihood = -20218.111                     Pseudo R2         =     0.0625

------------------------------------------------------------------------------
worked |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
morekids |  -.2986554   .0150511   -19.84   0.000    -.3281551   -.2691558
nonmomi |  -.0031412   .0003701    -8.49   0.000    -.0038665   -.0024159
educ |   .0554282   .0024978    22.19   0.000     .0505327    .0603237
age |   .1479387   .0308452     4.80   0.000     .0874834    .2083941
agesq |  -.0020364   .0005305    -3.84   0.000    -.0030763   -.0009966
black |   .0412891   .0916525     0.45   0.652    -.1383465    .2209248
hispan |  -.3586388     .09188    -3.90   0.000    -.5387203   -.1785574
_cons |  -2.496476   .4516554    -5.53   0.000    -3.381704   -1.611247
------------------------------------------------------------------------------

. eststo ProbitAPE:  margins, dydx(morekids) post

Average marginal effects                        Number of obs     =     31,857
Model VCE    : OIM

Expression   : Pr(worked), predict()
dy/dx w.r.t. : morekids

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
morekids |  -.1082686   .0053561   -20.21   0.000    -.1187664   -.0977708
------------------------------------------------------------------------------

. eststo LPM_IV: ivreg worked (morekids=samesex) nonmomi educ age agesq black hispan

Instrumental variables (2SLS) regression

Source |       SS           df       MS      Number of obs   =    31,857
-------------+----------------------------------   F(7, 31849)     =    345.86
Model |  567.677514         7  81.0967877   Prob > F        =    0.0000
Residual |  7139.72281    31,849   .22417416   R-squared       =    0.0737
Total |  7707.40032    31,856  .241945013   Root MSE        =    .47347

------------------------------------------------------------------------------
worked |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
morekids |   -.200832   .0964721    -2.08   0.037    -.3899211    -.011743
nonmomi |    -.00126   .0001671    -7.54   0.000    -.0015874   -.0009325
educ |   .0175522   .0033755     5.20   0.000     .0109361    .0241682
age |   .0603517   .0120811     5.00   0.000     .0366722    .0840311
agesq |  -.0008178   .0001975    -4.14   0.000     -.001205   -.0004307
black |   .0168118   .0340432     0.49   0.621    -.0499142    .0835379
hispan |  -.1308112   .0341655    -3.83   0.000    -.1977768   -.0638456
_cons |   -.454969   .1658195    -2.74   0.006    -.7799816   -.1299564
------------------------------------------------------------------------------
Instrumented:  morekids
Instruments:   nonmomi educ age agesq black hispan samesex
------------------------------------------------------------------------------

. eststo Biprobit_IV: biprobit (worked morekids nonmomi educ age agesq black hispan) ///
(morekids=samesex nonmomi educ age agesq black hispan)

Seemingly unrelated bivariate probit            Number of obs     =     31,857
Wald chi2(14)     =    5124.29
Log likelihood = -41106.422                     Prob > chi2       =     0.0000

------------------------------------------------------------------------------
|      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
worked       |
morekids |  -.7025719    .204014    -3.44   0.001    -1.102432   -.3027119
nonmomi |  -.0034903    .000395    -8.84   0.000    -.0042645   -.0027161
educ |   .0405621   .0085385     4.75   0.000     .0238271    .0572972
age |   .1632256   .0312412     5.22   0.000     .1019939    .2244573
agesq |  -.0021524   .0005277    -4.08   0.000    -.0031867    -.001118
black |   .0367322   .0909997     0.40   0.686    -.1416239    .2150883
hispan |  -.3614826   .0912096    -3.96   0.000    -.5402502    -.182715
_cons |  -2.475317   .4496294    -5.51   0.000    -3.356575    -1.59406
-------------+----------------------------------------------------------------
morekids     |
samesex |   .1446566   .0144319    10.02   0.000     .1163705    .1729427
nonmomi |  -.0027063   .0003685    -7.34   0.000    -.0034285   -.0019841
educ |  -.0907148   .0024968   -36.33   0.000    -.0956083   -.0858212
age |   .1190243   .0307613     3.87   0.000     .0587333    .1793154
agesq |   -.001028   .0005284    -1.95   0.052    -.0020636    7.54e-06
black |  -.0277804   .0921479    -0.30   0.763     -.208387    .1528263
hispan |  -.0690523   .0922843    -0.75   0.454    -.2499262    .1118217
_cons |  -1.572557   .4514335    -3.48   0.000    -2.457351   -.6877639
-------------+----------------------------------------------------------------
/athrho |   .2599507   .1396201     1.86   0.063    -.0136996     .533601
-------------+----------------------------------------------------------------
rho |   .2542495   .1305946                     -.0136987    .4881289
------------------------------------------------------------------------------
LR test of rho=0: chi2(1) = 3.33969                       Prob > chi2 = 0.0676

. eststo BiprobitAPE: margins, dydx(morekids) post

Average marginal effects                        Number of obs     =     31,857
Model VCE    : OIM

Expression   : Pr(worked=1,morekids=1), predict()
dy/dx w.r.t. : morekids

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
morekids |  -.1163742   .0287226    -4.05   0.000    -.1726695   -.0600788
------------------------------------------------------------------------------

. eststo Biprobit: biprobit (worked morekids nonmomi educ age agesq black hispan) ///
(morekids nonmomi educ age agesq black hispan)

Seemingly unrelated bivariate probit            Number of obs     =     31,857
Wald chi2(13)     =    5878.97
Log likelihood = -41157.989                     Prob > chi2       =     0.0000

------------------------------------------------------------------------------
|      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
worked       |
morekids |  -.9663993    .243112    -3.98   0.000     -1.44289   -.4899086
nonmomi |  -.0036516   .0003815    -9.57   0.000    -.0043994   -.0029039
educ |   .0292476   .0114284     2.56   0.010     .0068483    .0516469
age |   .1701076   .0305804     5.56   0.000     .1101711    .2300441
agesq |  -.0021836   .0005188    -4.21   0.000    -.0032005   -.0011668
black |   .0325432   .0897866     0.36   0.717    -.1434353    .2085216
hispan |  -.3550572   .0904013    -3.93   0.000    -.5322405    -.177874
_cons |  -2.403905   .4506848    -5.33   0.000    -3.287231   -1.520579
-------------+----------------------------------------------------------------
morekids     |
nonmomi |  -.0026773    .000368    -7.28   0.000    -.0033985    -.001956
educ |   -.090503   .0024904   -36.34   0.000     -.095384    -.085622
age |   .1204846    .030709     3.92   0.000     .0602961     .180673
agesq |  -.0010565   .0005275    -2.00   0.045    -.0020903   -.0000227
black |    -.02663   .0920542    -0.29   0.772    -.2070529     .153793
hispan |  -.0667949    .092191    -0.72   0.469     -.247486    .1138962
_cons |  -1.522285   .4506283    -3.38   0.001      -2.4055   -.6390698
-------------+----------------------------------------------------------------
/athrho |   .4545144   .1974215     2.30   0.021     .0675755    .8414534
-------------+----------------------------------------------------------------
rho |   .4256028    .161661                      .0674728    .6865781
------------------------------------------------------------------------------
LR test of rho=0: chi2(1) = 3.70365                       Prob > chi2 = 0.0543

. eststo Biprobit_APE: margins, dydx(morekids) post

Average marginal effects                        Number of obs     =     31,857
Model VCE    : OIM

Expression   : Pr(worked=1,morekids=1), predict()
dy/dx w.r.t. : morekids

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
morekids |  -.1507563   .0293686    -5.13   0.000    -.2083177   -.0931949
------------------------------------------------------------------------------

. estout LPM_OLS Probit LPM_IV Biprobit_IV Biprobit,  keep(morekids) cells(b(nostar fmt(4)) ///
se(par fmt(4))) stats(ll r2 r2_p N, fmt(%9.3f %9.0g) labels(Log-Likelihood R-squared Psuedo-R2 N)) ///
ti("Table 15.2 Estimated Effect of Having Three or More Children on Women's Labor Force Participation")

Table 15.2 Estimated Effect of Having Three or More Children on Women's Labor Force Participation
-----------------------------------------------------------------------------
LPM_OLS       Probit       LPM_IV  Biprobit_IV     Biprobit
b/se         b/se         b/se         b/se         b/se
-----------------------------------------------------------------------------
main
morekids          -0.1091      -0.2987      -0.2008      -0.7026      -0.9664
(0.0055)     (0.0151)     (0.0965)     (0.2040)     (0.2431)
-----------------------------------------------------------------------------
Log-Likeli~d    -2.12e+04    -2.02e+04                 -4.11e+04    -4.12e+04
R-squared        .0817459                  .0736536
Psuedo-R2                     .0624612
N                   31857        31857        31857        31857        31857
-----------------------------------------------------------------------------

. estout LPM_OLS ProbitAPE LPM_IV BiprobitAPE Biprobit_APE, keep(morekids) ///
cells(b(nostar fmt(4)) se(par fmt(4)))
-----------------------------------------------------------------------------
LPM_OLS    ProbitAPE       LPM_IV  BiprobitAPE Biprobit_APE
b/se         b/se         b/se         b/se         b/se
-----------------------------------------------------------------------------
morekids          -0.1091      -0.1083      -0.2008      -0.1164      -0.1508
(0.0055)     (0.0054)     (0.0965)     (0.0287)     (0.0294)
-----------------------------------------------------------------------------

. eststo clear

. // Example 15.5 (Panel Data Models for Women's Labor Force Participation)

. use lfp, clear

. xtset id period
panel variable:  id (strongly balanced)
time variable:  period, 1 to 5
delta:  1 unit

. eststo FE_Linear: xtreg lfp kids lhinc edu age agesq black i.period, fe cluster(id)
note: educ omitted because of collinearity
note: age omitted because of collinearity
note: agesq omitted because of collinearity
note: black omitted because of collinearity

Fixed-effects (within) regression               Number of obs     =     28,315
Group variable: id                              Number of groups  =      5,663

R-sq:                                           Obs per group:
within  = 0.0031                                         min =          5
between = 0.0103                                         avg =        5.0
overall = 0.0091                                         max =          5

F(6,5662)         =       5.61
corr(u_i, Xb)  = -0.0073                        Prob > F          =     0.0000

(Std. Err. adjusted for 5,663 clusters in id)
------------------------------------------------------------------------------
|               Robust
lfp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |  -.0388976   .0091682    -4.24   0.000    -.0568708   -.0209244
lhinc |  -.0089439   .0045947    -1.95   0.052    -.0179513    .0000635
educ |          0  (omitted)
age |          0  (omitted)
agesq |          0  (omitted)
black |          0  (omitted)
|
period |
2  |  -.0042799    .003401    -1.26   0.208    -.0109472    .0023875
3  |  -.0108953   .0041859    -2.60   0.009    -.0191012   -.0026894
4  |  -.0123002   .0044918    -2.74   0.006    -.0211058   -.0034945
5  |  -.0176797   .0048541    -3.64   0.000    -.0271957   -.0081637
|
_cons |   .8090216   .0375234    21.56   0.000     .7354614    .8825818
-------------+----------------------------------------------------------------
sigma_u |  .42247488
sigma_e |  .21363541
rho |  .79636335   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. eststo Probit_Pooled: probit lfp kids lhinc edu age agesq black i.period, cluster(id) nolog

Probit regression                               Number of obs     =     28,315
Wald chi2(10)     =     537.36
Prob > chi2       =     0.0000
Log pseudolikelihood = -16556.671               Pseudo R2         =     0.0651

(Std. Err. adjusted for 5,663 clusters in id)
------------------------------------------------------------------------------
|               Robust
lfp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |  -.1989144   .0153153   -12.99   0.000    -.2289319   -.1688969
lhinc |  -.2110738   .0242901    -8.69   0.000    -.2586816   -.1634661
educ |   .0796863   .0065453    12.17   0.000     .0668577    .0925149
age |   .1449159   .0122179    11.86   0.000     .1209693    .1688624
agesq |  -.0019912   .0001522   -13.08   0.000    -.0022895   -.0016928
black |   .2209396   .0659041     3.35   0.001       .09177    .3501093
|
period |
2  |  -.0124245   .0104551    -1.19   0.235    -.0329162    .0080672
3  |  -.0325178   .0127431    -2.55   0.011    -.0574938   -.0075418
4  |   -.046097   .0136286    -3.38   0.001    -.0728087   -.0193853
5  |  -.0577767    .014632    -3.95   0.000    -.0864548   -.0290985
|
_cons |  -1.064449    .261872    -4.06   0.000    -1.577709   -.5511895
------------------------------------------------------------------------------

. eststo Probit_APE: margins, dydx(kids lhinc) post

Average marginal effects                        Number of obs     =     28,315
Model VCE    : Robust

Expression   : Pr(lfp), predict()
dy/dx w.r.t. : kids lhinc

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |  -.0660184   .0049222   -13.41   0.000    -.0756657   -.0563711
lhinc |   -.070054   .0079821    -8.78   0.000    -.0856987   -.0544093
------------------------------------------------------------------------------

. eststo FE_logit: xtlogit lfp kids lhin i.period, fe nolog
note: multiple positive outcomes within groups encountered.
note: 4,608 groups (23,040 obs) dropped because of all positive or
all negative outcomes.

Conditional fixed-effects logistic regression   Number of obs     =      5,275
Group variable: id                              Number of groups  =      1,055

Obs per group:
min =          5
avg =        5.0
max =          5

LR chi2(6)        =      57.27
Log likelihood  = -2003.4184                    Prob > chi2       =     0.0000

------------------------------------------------------------------------------
lfp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |  -.6438386   .1247828    -5.16   0.000    -.8884084   -.3992688
lhinc |  -.1842911   .0826019    -2.23   0.026    -.3461878   -.0223943
|
period |
2  |  -.0928039   .0889937    -1.04   0.297    -.2672283    .0816205
3  |  -.2247989   .0887976    -2.53   0.011     -.398839   -.0507587
4  |  -.2479323   .0888953    -2.79   0.005     -.422164   -.0737006
5  |  -.3563745   .0888354    -4.01   0.000    -.5304886   -.1822604
------------------------------------------------------------------------------

. by id: egen kidsbar = mean(kids)

. by id: egen lhincbar = mean(lhinc)

. eststo RE_Probit: probit lfp kids lhinc kidsbar lhincbar educ black age agesq i.period, cluster(id) nolog

Probit regression                               Number of obs     =     28,315
Wald chi2(12)     =     538.09
Prob > chi2       =     0.0000
Log pseudolikelihood = -16516.436               Pseudo R2         =     0.0673

(Std. Err. adjusted for 5,663 clusters in id)
------------------------------------------------------------------------------
|               Robust
lfp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |  -.1173749   .0269743    -4.35   0.000    -.1702435   -.0645064
lhinc |  -.0288098    .014344    -2.01   0.045    -.0569234   -.0006961
kidsbar |  -.0856913   .0311857    -2.75   0.006     -.146814   -.0245685
lhincbar |  -.2501781   .0352907    -7.09   0.000    -.3193466   -.1810097
educ |   .0841338   .0067302    12.50   0.000     .0709428    .0973248
black |   .2030668   .0663945     3.06   0.002     .0729359    .3331976
age |   .1516424   .0124831    12.15   0.000      .127176    .1761089
agesq |  -.0020672   .0001553   -13.31   0.000    -.0023717   -.0017628
|
period |
2  |  -.0135701   .0103752    -1.31   0.191    -.0339051    .0067648
3  |  -.0331991   .0127197    -2.61   0.009    -.0581293    -.008269
4  |  -.0390317   .0136244    -2.86   0.004    -.0657351   -.0123284
5  |  -.0552425   .0146067    -3.78   0.000    -.0838711   -.0266139
|
_cons |  -.7260562   .2836985    -2.56   0.010    -1.282095   -.1700173
------------------------------------------------------------------------------

. eststo RE_APE: margins, dydx(kids lhinc) post

Average marginal effects                        Number of obs     =     28,315
Model VCE    : Robust

Expression   : Pr(lfp), predict()
dy/dx w.r.t. : kids lhinc

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |   -.038852   .0089243    -4.35   0.000    -.0563433   -.0213608
lhinc |  -.0095363   .0047482    -2.01   0.045    -.0188426     -.00023
------------------------------------------------------------------------------

. eststo CRE_Probit: xtprobit lfp kids lhinc kidsbar lhincbar educ black age agesq i.period, re  nolog

Random-effects probit regression                Number of obs     =     28,315
Group variable: id                              Number of groups  =      5,663

Random effects u_i ~ Gaussian                   Obs per group:
min =          5
avg =        5.0
max =          5

Integration method: mvaghermite                 Integration pts.  =         12

Wald chi2(12)     =     623.40
Log likelihood  = -8609.9002                    Prob > chi2       =     0.0000

------------------------------------------------------------------------------
lfp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |  -.3970102   .0701298    -5.66   0.000     -.534462   -.2595584
lhinc |  -.1003399   .0469979    -2.13   0.033    -.1924541   -.0082258
kidsbar |  -.4085664   .0898875    -4.55   0.000    -.5847428   -.2323901
lhincbar |  -.8941069   .1199703    -7.45   0.000    -1.129244   -.6589695
educ |   .3189079    .024327    13.11   0.000     .2712279     .366588
black |   .6388784   .1903525     3.36   0.001     .2657945    1.011962
age |   .7282057   .0445623    16.34   0.000     .6408651    .8155462
agesq |  -.0098358   .0005747   -17.11   0.000    -.0109623   -.0087094
|
period |
2  |  -.0451653   .0499429    -0.90   0.366    -.1430516     .052721
3  |  -.1247056   .0501522    -2.49   0.013    -.2230022    -.026409
4  |  -.1356834   .0500679    -2.71   0.007    -.2338147   -.0375522
5  |   -.200357    .049539    -4.04   0.000    -.2974515   -.1032624
|
_cons |  -5.359375   1.000514    -5.36   0.000    -7.320346   -3.398404
-------------+----------------------------------------------------------------
/lnsig2u |   2.947234   .0435842                      2.861811    3.032657
-------------+----------------------------------------------------------------
sigma_u |   4.364995   .0951224                      4.182484     4.55547
rho |   .9501326    .002065                       .945926    .9540279
------------------------------------------------------------------------------
LR test of rho=0: chibar2(01) = 1.6e+04                Prob >= chibar2 = 0.000

. eststo CRE_APE: margins, dydx(kids lhinc) post

Average marginal effects                        Number of obs     =     28,315
Model VCE    : OIM

Expression   : Pr(lfp=1), predict(pr)
dy/dx w.r.t. : kids lhinc

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
kids |  -.0301539   .0053261    -5.66   0.000    -.0405928   -.0197149
lhinc |  -.0076211   .0035696    -2.13   0.033    -.0146174   -.0006247
------------------------------------------------------------------------------

. estout FE_Linear Probit_Pooled Probit_APE RE_Probit RE_APE CRE_Probit CRE_APE FE_logit, ///
keep(kids lhinc kidsbar lhincbar) cells(b(nostar fmt(4)) se(par fmt(4))) ///
stats(ll r2 r2_p N, fmt(%9.0g) labels(Log-Likelihood R-squared Psuedo-R2 N))

--------------------------------------------------------------------------------------------------------------------
FE_Linear Probit_Poo~d   Probit_APE    RE_Probit       RE_APE   CRE_Probit      CRE_APE     FE_logit
b/se         b/se         b/se         b/se         b/se         b/se         b/se         b/se
--------------------------------------------------------------------------------------------------------------------
main
kids              -0.0389      -0.1989      -0.0660      -0.1174      -0.0389      -0.3970      -0.0302      -0.6438
(0.0092)     (0.0153)     (0.0049)     (0.0270)     (0.0089)     (0.0701)     (0.0053)     (0.1248)
lhinc             -0.0089      -0.2111      -0.0701      -0.0288      -0.0095      -0.1003      -0.0076      -0.1843
(0.0046)     (0.0243)     (0.0080)     (0.0143)     (0.0047)     (0.0470)     (0.0036)     (0.0826)
kidsbar                                                  -0.0857                   -0.4086
(0.0312)                  (0.0899)
lhincbar                                                 -0.2502                   -0.8941
(0.0353)                  (0.1200)
--------------------------------------------------------------------------------------------------------------------
Log-Likeli~d     6689.422    -16556.67                 -16516.44                   -8609.9                 -2003.418
R-squared        .0031198
Psuedo-R2                     .0650713                  .0673433                                            .0140919
N                   28315        28315        28315        28315        28315        28315        28315         5275
--------------------------------------------------------------------------------------------------------------------

. eststo clear

. // Example 15.6 (Dynamic Women's LFP Equation)

. xtset id period
panel variable:  id (strongly balanced)
time variable:  period, 1 to 5
delta:  1 unit
. forv i=2/5 {
by id: gen kids`i' = kids[`i']
}

. forv i=2/5 {
by id: gen lhinc`i' = lhinc[`i']
}

. g lfp_1 = l.lfp
(5,663 missing values generated)

. by id: g lfp1st = lfp[1]

. eststo RE_Probit: xtprobit lfp lfp_1 lfp1st kids kids2-kids5 lhinc lhinc2-lhinc5 ///
black age agesq educ per5 per4 per3, nolog

Random-effects probit regression                Number of obs     =     22,652
Group variable: id                              Number of groups  =      5,663

Random effects u_i ~ Gaussian                   Obs per group:
min =          4
avg =        4.0
max =          4

Integration method: mvaghermite                 Integration pts.  =         12

Wald chi2(19)     =    4108.39
Log likelihood  = -5028.9994                    Prob > chi2       =     0.0000

------------------------------------------------------------------------------
lfp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lfp_1 |   1.543212   .0666285    23.16   0.000     1.412623    1.673801
lfp1st |   2.523804   .1553997    16.24   0.000     2.219226    2.828382
kids |  -.1451527   .0787035    -1.84   0.065    -.2994088    .0091033
kids2 |   .3232176   .0965951     3.35   0.001     .1338947    .5125406
kids3 |   .1071765   .1232038     0.87   0.384    -.1342985    .3486516
kids4 |   .0173548   .1273505     0.14   0.892    -.2322475    .2669572
kids5 |  -.3904321   .1058279    -3.69   0.000     -.597851   -.1830131
lhinc |  -.0747984   .0508154    -1.47   0.141    -.1743947     .024798
lhinc2 |  -.0231497   .0589568    -0.39   0.695    -.1387029    .0924036
lhinc3 |  -.0829647   .0624976    -1.33   0.184    -.2054578    .0395284
lhinc4 |  -.0864221   .0608129    -1.42   0.155    -.2056133     .032769
lhinc5 |   .0622538   .0590987     1.05   0.292    -.0535775    .1780851
black |   .1319675   .0980651     1.35   0.178    -.0602365    .3241715
age |   .1278587   .0193926     6.59   0.000     .0898499    .1658675
agesq |  -.0016877     .00024    -7.03   0.000    -.0021581   -.0012173
educ |   .0497964   .0100056     4.98   0.000     .0301859     .069407
per5 |  -.0785389   .0464676    -1.69   0.091    -.1696137     .012536
per4 |  -.0295055   .0463489    -0.64   0.524    -.1203477    .0613366
per3 |   -.055971   .0458111    -1.22   0.222     -.145759    .0338171
_cons |  -2.941813   .4359963    -6.75   0.000     -3.79635   -2.087276
-------------+----------------------------------------------------------------
/lnsig2u |   .0934029   .1221436                     -.1459941    .3327999
-------------+----------------------------------------------------------------
sigma_u |   1.047809   .0639916                      .9296036    1.181045
rho |   .5233338   .0304694                      .4635662    .5824405
------------------------------------------------------------------------------
LR test of rho=0: chibar2(01) = 160.68                 Prob >= chibar2 = 0.000

. eststo RE_APE: margins, dydx(lfp_1 lfp1st kids lhinc) post

Average marginal effects                        Number of obs     =     22,652
Model VCE    : OIM

Expression   : Pr(lfp=1), predict(pr)
dy/dx w.r.t. : lfp_1 lfp1st kids lhinc

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lfp_1 |   .1556348   .0097058    16.04   0.000     .1366119    .1746578
lfp1st |   .2545288   .0100773    25.26   0.000     .2347776    .2742799
kids |  -.0146388   .0079031    -1.85   0.064    -.0301286    .0008509
lhinc |  -.0075435    .005124    -1.47   0.141    -.0175864    .0024993
------------------------------------------------------------------------------

. eststo Probit_Pooled: probit lfp lfp_1 kids lhinc kidsbar lhincbar educ black age agesq , nolog

Probit regression                               Number of obs     =     22,652
LR chi2(9)        =   17745.39
Prob > chi2       =     0.0000
Log likelihood = -5331.9397                     Pseudo R2         =     0.6246

------------------------------------------------------------------------------
lfp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lfp_1 |   2.873296    .026994   106.44   0.000     2.820389    2.926204
kids |  -.0408857   .0613472    -0.67   0.505    -.1611241    .0793526
lhinc |    -.05965   .0398225    -1.50   0.134    -.1377005    .0184006
kidsbar |  -.0209041   .0624636    -0.33   0.738    -.1433306    .1015224
lhincbar |  -.0763568   .0467387    -1.63   0.102    -.1679629    .0152494
educ |    .030652   .0053293     5.75   0.000     .0202066    .0410973
black |   .0741813   .0537819     1.38   0.168    -.0312293    .1795919
age |   .0866671   .0101111     8.57   0.000     .0668496    .1064845
agesq |  -.0011241   .0001248    -9.01   0.000    -.0013687   -.0008796
_cons |  -2.080879   .2301204    -9.04   0.000    -2.531907   -1.629852
------------------------------------------------------------------------------

. eststo Probit_APE: margins, dydx(lfp_1 kids lhinc) post

Average marginal effects                        Number of obs     =     22,652
Model VCE    : OIM

Expression   : Pr(lfp), predict()
dy/dx w.r.t. : lfp_1 kids lhinc

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lfp_1 |   .3575142   .0038879    91.96   0.000      .349894    .3651344
kids |  -.0050873   .0076335    -0.67   0.505    -.0200486    .0098741
lhinc |   -.007422   .0049559    -1.50   0.134    -.0171354    .0022913
------------------------------------------------------------------------------

. eststo clear

. log close
name:  SN
log:  myReplications\iiexample15.smcl
log type:  smcl
closed on:   9 May 2020, 17:56:03
------------------------------------------------------------------------------------------
```