## Chapter 18 Count, Fractional, and Other Nonnegative Responses

### Examples

```
------------------------------------------------------------------------------
name:  SN
log:  \iiexample18.smcl
log type:  smcl
opened on:  12 May 2020, 10:32:08
. **********************************************

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

.  * Chapter 18  -  Count, Fractional, and Other Nonnegative Responses
.  **********************************************

.  // Example 18.1 (Effects of Education on Fertility)

. bcuse fertil2, clear nodesc

. eststo Linear: reg children educ age agesq evermarr urban electric tv

Source |       SS           df       MS      Number of obs   =     4,358
-------------+----------------------------------   F(7, 4350)      =    893.91
Model |  12688.9349         7  1812.70499   Prob > F        =    0.0000
Residual |  8821.09719     4,350  2.02783843   R-squared       =    0.5899
Total |  21510.0321     4,357  4.93689055   Root MSE        =     1.424

------------------------------------------------------------------------------
children |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |  -.0644086   .0063199   -10.19   0.000    -.0767987   -.0520184
age |   .2724736    .017019    16.01   0.000     .2391077    .3058395
agesq |  -.0019067    .000274    -6.96   0.000    -.0024438   -.0013696
evermarr |   .6822725    .052167    13.08   0.000     .5799986    .7845463
urban |  -.2278933   .0458653    -4.97   0.000    -.3178126    -.137974
electric |  -.2617394   .0758688    -3.45   0.001     -.410481   -.1129979
tv |  -.2499509   .0901474    -2.77   0.006    -.4266858   -.0732161
_cons |   -3.39384   .2445496   -13.88   0.000    -3.873281   -2.914398
------------------------------------------------------------------------------

. eststo Poisson: poisson children educ age agesq evermarr urban electric tv, r nolog

Poisson regression                              Number of obs     =      4,358
Wald chi2(7)      =    6261.94
Prob > chi2       =     0.0000
Log pseudolikelihood = -6497.0599               Pseudo R2         =     0.3219

------------------------------------------------------------------------------
|               Robust
children |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |  -.0216645   .0025918    -8.36   0.000    -.0267442   -.0165847
age |   .3373308   .0094473    35.71   0.000     .3188144    .3558473
agesq |  -.0041158    .000144   -28.57   0.000    -.0043981   -.0038335
evermarr |    .314751   .0232117    13.56   0.000      .269257     .360245
urban |  -.0860549   .0200471    -4.29   0.000    -.1253465   -.0467633
electric |  -.1205347   .0372925    -3.23   0.001    -.1936266   -.0474428
tv |  -.1447046   .0438055    -3.30   0.001    -.2305617   -.0588475
_cons |  -5.374829   .1477633   -36.37   0.000     -5.66444   -5.085219
------------------------------------------------------------------------------

. margins,

Predictive margins                              Number of obs     =      4,358
Model VCE    : Robust

Expression   : Predicted number of events, predict()

------------------------------------------------------------------------------
|            Delta-method
|     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons |   2.267554   .0213693   106.11   0.000     2.225671    2.309437
------------------------------------------------------------------------------

. margins, dydx(educ tv)

Average marginal effects                        Number of obs     =      4,358
Model VCE    : Robust

Expression   : Predicted number of events, predict()
dy/dx w.r.t. : educ tv

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |  -.0491254    .005968    -8.23   0.000    -.0608223   -.0374284
tv |  -.3281255   .0993952    -3.30   0.001    -.5229365   -.1333144
------------------------------------------------------------------------------

. estout Linear Poisson, cells(b(nostar fmt(4)) se(par fmt(4))) stats(ll r2 r2_p N, ///
fmt(%9.0g %9.0g %9.0g) labels(Log-Likelihood R-Squared Psuedo_R-Sqaured N )) ///
varlabels(_cons constant) varwidth(10) ti("Table 18.1 OLS and Poisson Estimates of ///
a Fertility Equation: (children)")

Table 18.1 OLS and Poisson Estimates of a Fertility Equation: (children)
------------------------------------
Linear      Poisson
b/se         b/se
------------------------------------
main
educ            -0.0644      -0.0217
(0.0063)     (0.0026)
age              0.2725       0.3373
(0.0170)     (0.0094)
agesq           -0.0019      -0.0041
(0.0003)     (0.0001)
evermarr         0.6823       0.3148
(0.0522)     (0.0232)
urban           -0.2279      -0.0861
(0.0459)     (0.0200)
electric        -0.2617      -0.1205
(0.0759)     (0.0373)
tv              -0.2500      -0.1447
(0.0901)     (0.0438)
constant        -3.3938      -5.3748
(0.2445)     (0.1478)
------------------------------------
Log-Like~d    -7720.219     -6497.06
R-Squared      .5899078
Psuedo_R~d                  .3218618
N                  4358         4358
------------------------------------

. est clear

.  // Example 18.2 (Is Education Endogenous in the Fertility Equation?)

. reg educ frsthalf age agesq evermarr urban electric tv

Source |       SS           df       MS      Number of obs   =     4,358
-------------+----------------------------------   F(7, 4350)      =    208.02
Model |  16850.0414         7  2407.14877   Prob > F        =    0.0000
Residual |    50336.75     4,350  11.5716667   R-squared       =    0.2508
Total |  67186.7914     4,357  15.4204249   Root MSE        =    3.4017

------------------------------------------------------------------------------
educ |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
frsthalf |  -.6361072   .1038091    -6.13   0.000    -.8396259   -.4325885
age |  -.0702853   .0406438    -1.73   0.084    -.1499678    .0093971
agesq |  -.0008118   .0006544    -1.24   0.215    -.0020947    .0004711
evermarr |  -.8023536   .1241223    -6.46   0.000    -1.045697   -.5590106
urban |   .8637296    .108786     7.94   0.000     .6504536    1.077006
electric |   1.977712   .1787579    11.06   0.000     1.627255    2.328168
tv |   2.714666   .2113782    12.84   0.000     2.300257    3.129075
_cons |    8.20343   .5752279    14.26   0.000     7.075691     9.33117
------------------------------------------------------------------------------

. predict v2, r
(3 missing values generated)

. poisson children educ age agesq evermarr urban electric tv v2, r nolog

Poisson regression                              Number of obs     =      4,358
Wald chi2(8)      =    6267.44
Prob > chi2       =     0.0000
Log pseudolikelihood = -6496.7706               Pseudo R2         =     0.3219

------------------------------------------------------------------------------
|               Robust
children |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |  -.0459847   .0295654    -1.56   0.120    -.1039319    .0119625
age |   .3357196   .0097048    34.59   0.000     .3166986    .3547405
agesq |  -.0041373   .0001451   -28.52   0.000    -.0044216   -.0038529
evermarr |   .2941007   .0343224     8.57   0.000       .22683    .3613714
urban |  -.0647957   .0323494    -2.00   0.045    -.1281994    -.001392
electric |  -.0711916   .0688407    -1.03   0.301    -.2061168    .0637337
tv |  -.0780223   .0937508    -0.83   0.405    -.2617705    .1057258
v2 |    .024515   .0296235     0.83   0.408     -.033546    .0825761
_cons |   -5.18482   .2767832   -18.73   0.000    -5.727305   -4.642335
------------------------------------------------------------------------------

. log close
name:  SN
log:  iiexample18.smcl
log type:  smcl
opened on:  12 May 2020, 10:32:11
------------------------------------------------------------------------------------------
```