-------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  c:\acdbookrevision\stata_final_programs_2013\racd06p2.txt
  log type:  text
 opened on:  25 Jan 2013, 09:42:34

. 
. ********** OVERVIEW OF racd06p2.do **********
. 
. * STATA Program 
. * copyright C 2013 by A. Colin Cameron and Pravin K. Trivedi 
. * used for "Regression Analyis of Count Data" SECOND EDITION
. * by A. Colin Cameron and Pravin K. Trivedi (2013)
. * Cambridge University Press
. 
. * To run you need file
. *   racd06data2rectrips.dta
. * and user-written Stata addon
. *   hnblgit
. * in your directory
. 
. ********** SETUP **********
. 
. set more off

. version 12

. clear all

. * set linesize 82
. set scheme s1mono  /* Graphics scheme */

. 
. ************
. 
. * This STATA program analyzes doctor visits data for chapter 6.3
. *   6.4 RECREATIONAL TRIPS
.  
. ********** DATA DESCRIPTION
. 
. * A detailed discussion of the variables can be found in 
. * C. Sellar, J.R. Stoll and J.P. Chavas (1985), 
. * "Validation of Empirical Measures of Welfare Change: A Comparison of nonmarket 
. * Techniques," Land Economics, 61, 156-175.  
. * Data used with permission of Sellar et al. (1985)
. * And also T. Ozuna and I. Gomaz (1995) 
. * "Specification and Testing of Count Data Recreation Demand Functions," 
. * Empirical Economics, 20, 543-550.
. 
. * See these articles for more detailed discussion 
. * Also see racd06makedata2rectrips.dta.do for further details
. 
. ********** RESULTS FOR ONE MODEL HERE DIFFER FROM THE BOOK
. 
. * This Stata program reanalyzes the data given in the published paper by
. * Gurmu and Trivedi (1996). Their results used quite different code written 
. * in a program other than Stata.
. 
. * Virtually all the results are reproduced here, except chisquare goodness-of-fit
. * tests and predicted probabilities are obtained only for some of the models.
. 
. * Also the results obtained here for the finite mixture Poisson two-component
. * model differ from the Gurmu and Trivedi (1996) estimates.
. * Their paper found a higher log-likelihood for this model than we find here.
. * So the book reports the original Gurmu and Trivedi (1996) estimates
. 
. * The results obtained below for Table 6.12 are 
. *   Finite mixture 2 component Poisson regression
. *     Variable      Low Users              High users
. * -------------+----------------------------------------------------------------
. *        _cons | -1.766     6.19         2.479     6.19
. *           SO |   .655    14.97          .086     0.63
. *          SKI |   .438     2.45          .631     3.43
. *            I |  -.010     0.20          .003     0.02 
. *          FC3 |  1.543     8.04         -.687     1.90
. *           C1 |  -.044     2.40          .074     3.36
. *           C3 |  -.030     2.85         -.073     5.66
. *           C4 |   .060     5.03         -.014     0.83
. *           pi |   .909                   .092 
. *         -lnL |                   939 
. *          BIC |                  1987
. *   
. *     Variable      Low Users              High users
. * -------------+----------------------------------------------------------------
. *        _cons | -1.243    -5.09         4.707     6.46
. *           SO |   .616    16.84         -.053    -0.63
. *          SKI |   .476     2.67          .363     1.64
. *            I |  -.073    -1.60         -.374    -3.24 
. *          FC3 |  1.316     7.02         -.849    -1.54
. *           C1 |  -.002    -0.14          .005     0.30
. *           C3 |  -.058    -7.53         -.012    -1.04
. *           C4 |   .054     5.22         -.005    -0.58 
. *           pi |   .920                   .080 
. *          lnL |                   956 
. *          BIC |                  1947
. 
. 
. ********** 6.4.1 RECREATIONAL TRIPS DATA: READ AND SUMMARIZE 
. 
. use racd06data2rectrips.dta, clear

. 
. ********* Tables 6.9 and 6.10  Data Description
. 
. *** TABLE 6.9: FREQUENCIES
. 
. tabulate TRIPS

  Number of |
    boating |
   trips to |
       Lake |
 Somerville |
    in 1980 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        417       63.28       63.28
          1 |         68       10.32       73.60
          2 |         38        5.77       79.36
          3 |         34        5.16       84.52
          4 |         17        2.58       87.10
          5 |         13        1.97       89.07
          6 |         11        1.67       90.74
          7 |          2        0.30       91.05
          8 |          8        1.21       92.26
          9 |          1        0.15       92.41
         10 |         13        1.97       94.39
         11 |          2        0.30       94.69
         12 |          5        0.76       95.45
         15 |         14        2.12       97.57
         16 |          1        0.15       97.72
         20 |          3        0.46       98.18
         25 |          3        0.46       98.63
         26 |          1        0.15       98.79
         30 |          3        0.46       99.24
         40 |          3        0.46       99.70
         50 |          1        0.15       99.85
         88 |          1        0.15      100.00
------------+-----------------------------------
      Total |        659      100.00

. 
. *** TABLE 6.10: VARIABLE DESCRIPTIONS AND SUMMARY STATISTICS
. 
. describe

Contains data from racd06data2rectrips.dta
  obs:           659                          
 vars:             8                          7 Jun 2011 10:46
 size:        21,088                          
-------------------------------------------------------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------------------------------------------------------
TRIPS           float  %9.0g                  Number of boating trips to Lake Somerville in 1980
SO              float  %9.0g                  Facility's subjective quality ranking on a scale of 1 to 5
SKI             float  %9.0g                  Equals 1 if engaged in water-skiing at Lake
I               float  %9.0g                  Household income of the head of the group Income ($1,000/year)
FC3             float  %9.0g                  Equals 1 if user's fee paid at Lake Somerville
C1              float  %9.0g                  Dollar expenditure when visiting Lake Conroe
C3              float  %9.0g                  Dollar expenditure when visiting Lake Somerville
C4              float  %9.0g                  Dollar expenditure when visiting Lake Houston
-------------------------------------------------------------------------------------------------------------------------------
Sorted by:  

. summarize

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       TRIPS |       659     2.24431    6.292475          0         88
          SO |       659    1.418816    1.811986          0          5
         SKI |       659    .3672231    .4824142          0          1
           I |       659    3.852807    1.851937          1          9
         FC3 |       659    .0197269    .1391657          0          1
-------------+--------------------------------------------------------
          C1 |       659     55.4237    46.68265       4.34     493.77
          C3 |       659    59.92805    46.37668      4.767    491.547
          C4 |       659     55.9903    46.13321        5.7    491.049

. correlate
(obs=659)

             |    TRIPS       SO      SKI        I      FC3       C1       C3       C4
-------------+------------------------------------------------------------------------
       TRIPS |   1.0000
          SO |   0.3864   1.0000
         SKI |   0.0790   0.1263   1.0000
           I |  -0.0600   0.0374   0.2936   1.0000
         FC3 |   0.2791   0.1359   0.0278  -0.0241   1.0000
          C1 |  -0.0422   0.0772   0.1607   0.1379   0.0093   1.0000
          C3 |  -0.1237   0.0034   0.1547   0.1392  -0.0342   0.9767   1.0000
          C4 |  -0.0205   0.0898   0.1437   0.1176   0.0165   0.9865   0.9646   1.0000


. 
. ********* 6.4.2 INITIAL SPECIFICATIONS: POISSON and NB2 MODELS (Table 6.11)
. 
. * Global for the regressors
. global XLIST SO SKI I FC3 C1 C3 C4 

. 
. * Poisson
. poisson TRIPS $XLIST

Iteration 0:   log likelihood =  -2866.625  
Iteration 1:   log likelihood = -1811.5015  
Iteration 2:   log likelihood = -1536.5136  
Iteration 3:   log likelihood = -1529.4565  
Iteration 4:   log likelihood = -1529.4313  
Iteration 5:   log likelihood = -1529.4313  

Poisson regression                                Number of obs   =        659
                                                  LR chi2(7)      =    2543.90
                                                  Prob > chi2     =     0.0000
Log likelihood = -1529.4313                       Pseudo R2       =     0.4540

------------------------------------------------------------------------------
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          SO |   .4717259   .0170905    27.60   0.000     .4382291    .5052227
         SKI |   .4182137   .0571905     7.31   0.000     .3061224    .5303051
           I |  -.1113232   .0195885    -5.68   0.000    -.1497159   -.0729304
         FC3 |   .8981652   .0789854    11.37   0.000     .7433567    1.052974
          C1 |  -.0034297   .0031178    -1.10   0.271    -.0095405    .0026811
          C3 |  -.0425364   .0016703   -25.47   0.000    -.0458102   -.0392626
          C4 |   .0361336   .0027096    13.34   0.000     .0308229    .0414444
       _cons |   .2649934   .0937224     2.83   0.005     .0813009    .4486859
------------------------------------------------------------------------------

. estimates store POISSdef

. poisson TRIPS $XLIST, vce(robust) 

Iteration 0:   log pseudolikelihood =  -2866.625  
Iteration 1:   log pseudolikelihood = -1811.5015  
Iteration 2:   log pseudolikelihood = -1536.5136  
Iteration 3:   log pseudolikelihood = -1529.4565  
Iteration 4:   log pseudolikelihood = -1529.4313  
Iteration 5:   log pseudolikelihood = -1529.4313  

Poisson regression                                Number of obs   =        659
                                                  Wald chi2(7)    =     273.48
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -1529.4313                 Pseudo R2       =     0.4540

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          SO |   .4717259    .048887     9.65   0.000     .3759092    .5675426
         SKI |   .4182137   .1940159     2.16   0.031     .0379495     .798478
           I |  -.1113232   .0503458    -2.21   0.027    -.2099991   -.0126472
         FC3 |   .8981652   .2470961     3.63   0.000     .4138657    1.382465
          C1 |  -.0034297   .0147083    -0.23   0.816    -.0322575    .0253981
          C3 |  -.0425364   .0117435    -3.62   0.000    -.0655533   -.0195195
          C4 |   .0361336   .0093932     3.85   0.000     .0177232     .054544
       _cons |   .2649934   .4327988     0.61   0.540    -.5832767    1.113264
------------------------------------------------------------------------------

. estimates store POISSON

. 
. * Diagnostics
. quietly glm TRIPS SO SKI I C1 C3 C4 FC3, vce(robust) family(poisson)

. display "Pearson statistic = " e(dispers_p)
Pearson statistic = 6.2981465

. display "Deviance statistic = " e(dispers)
Deviance statistic = 3.5419133

. 
. * Now get various Rsquareds
. predict yhat, mu

. quietly correlate TRIPS yhat

. display "Squared correlation of TRIPS and predicted mean = " r(rho)^2
Squared correlation of TRIPS and predicted mean = .16877406

. scalar deviance = e(deviance)

. scalar pearson = e(deviance_p)

. * Need to compare to intercept only model
. quietly glm TRIPS, vce(robust) family(poisson)

. display "Pearson in fitted model = " pearson "  and in intercept model = " e(deviance_p)
Pearson in fitted model = 4100.0934  and in intercept model = 11608.767

. display "Pearson R-squared = " pearson/e(deviance_p)
Pearson R-squared = .3531894

. display "Deviance in fitted model = " deviance "  and in intercept model = " e(deviance)
Deviance in fitted model = 2305.7855  and in intercept model = 4849.6861

. display "Deviance R-squared = " deviance/e(deviance)
Deviance R-squared = .47545047

. drop yhat

. scalar drop pearson deviance

. 
. * Overdispersion tests
. quietly poisson TRIPS $XLIST

. predict muhat, n

. generate ystar = ((TRIPS-muhat)^2-TRIPS)/muhat  

. regress ystar muhat, noconstant vce(robust)     // NB2 form

Linear regression                                      Number of obs =     659
                                                       F(  1,   658) =    8.31
                                                       Prob > F      =  0.0041
                                                       R-squared     =  0.0129
                                                       Root MSE      =  59.121

------------------------------------------------------------------------------
             |               Robust
       ystar |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       muhat |   1.316051   .4566598     2.88   0.004     .4193649    2.212737
------------------------------------------------------------------------------

. regress ystar, vce(robust)   // NB1 form

Linear regression                                      Number of obs =     659
                                                       F(  0,   658) =    0.00
                                                       Prob > F      =       .
                                                       R-squared     =  0.0000
                                                       Root MSE      =  59.247

------------------------------------------------------------------------------
             |               Robust
       ystar |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |     5.5658   2.307927     2.41   0.016     1.034011    10.09759
------------------------------------------------------------------------------

. drop muhat ystar

. 
. * Predicted probabilities
. quietly poisson TRIPS $XLIST, vce(robust)

. foreach y of numlist 0/5 8 11 14 17 62 {
  2.    predict pp`y', pr(`y')
  3.    predict cump`y', pr(0,`y')
  4.    }

. replace pp8 = cump8 - cump5
(659 real changes made)

. replace pp11 = cump11 - cump8
(659 real changes made)

. replace pp14 = cump14 - cump11
(659 real changes made)

. replace pp17 = cump17 - cump14
(654 real changes made)

. replace pp62 = cump62 - cump17
(134 real changes made)

. * sum pp*
. * sum cump*
. 
. * Chisquare goodness of fit test
. * The cells are 0, 1, 2, ...., $MAXCOUNT or more
. global MAXCOUNT 5

. generate ycensored = TRIPS

. replace ycensored = $MAXCOUNT + 1 if TRIPS >= $MAXCOUNT + 1
(61 real changes made)

. generate one = 1

. quietly poisson TRIPS $XLIST, vce(robust)

. capture drop pyhat dy* pf* mf* py* pres* pscore*

. predict pyhat, n

. generate pres = TRIPS - pyhat

. foreach var in $XLIST {
  2.   generate pscore`var' = pres*`var'
  3.   }

. * The cells are 0, 1, 2, ...., $MAXCOUNT or more
. generate pfitsum = 0

. forvalues i = 0/$MAXCOUNT {
  2.    generate dy`i' = ycensored == `i' 
  3.    predict pfit`i', pr(`i')
  4.    generate mfit`i' = dy`i' - pfit`i'
  5.    quietly replace pfitsum = pfitsum + pfit`i'
  6.    }

. local i = $MAXCOUNT+1

. generate dy`i' = ycensored == `i' 

. generate pfit`i' = 1 - pfitsum

. generate mfit`i' = dy`i' - pfit`i'

. drop pfitsum

. * Generate Pearson
. scalar Pearson = 0

. scalar range = $MAXCOUNT+1

. global MAXPLUSONE = range

. forvalues i = 0/$MAXPLUSONE {
  2.    quietly sum mfit`i'
  3.    scalar diffsquared = r(mean)^2
  4.    quietly sum pfit`i'
  5.    * display "count" `i' "  " r(N)*diffsquared/r(mean)
.    scalar Pearson = Pearson + r(N)*diffsquared/r(mean) 
  6.    }

. display Pearson
136.62723

. * countfit TRIPS $XLIST, prm nograph maxcount(6)   
. * Generate Andrews chisquare goodness of fittest
. scalar range = $MAXCOUNT+1

. global MAXPLUSONE = range

. * NR^2 from the uncentered regression has Chisq distribution
. local i = $MAXCOUNT+1

. drop mfit`i'

. regress one mfit* pres pscore*, noconstant

      Source |       SS       df       MS              Number of obs =     659
-------------+------------------------------           F( 14,   645) =   28.63
       Model |   252.58037    14   18.041455           Prob > F      =  0.0000
    Residual |   406.41963   645  .630107954           R-squared     =  0.3833
-------------+------------------------------           Adj R-squared =  0.3699
       Total |         659   659           1           Root MSE      =  .79379

------------------------------------------------------------------------------
         one |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       mfit0 |   2.415836   .2012938    12.00   0.000     2.020566    2.811107
       mfit1 |   .7793654   .1929628     4.04   0.000     .4004542    1.158277
       mfit2 |   .6401953   .1956595     3.27   0.001     .2559887    1.024402
       mfit3 |   .7144358   .1983843     3.60   0.000     .3248787    1.103993
       mfit4 |   .2145685   .2234262     0.96   0.337     -.224162    .6532991
       mfit5 |  -.0292655   .2515508    -0.12   0.907    -.5232229    .4646918
        pres |  -.0128264   .0203336    -0.63   0.528    -.0527545    .0271017
    pscoreSO |  -.0159804   .0057943    -2.76   0.006    -.0273584   -.0046024
   pscoreSKI |  -.0480466   .0164136    -2.93   0.004    -.0802772    -.015816
     pscoreI |   .0374864   .0081548     4.60   0.000     .0214732    .0534995
   pscoreFC3 |  -.0071467   .0267627    -0.27   0.790    -.0596992    .0454059
    pscoreC1 |   .0024056    .000729     3.30   0.001      .000974    .0038372
    pscoreC3 |    .001858   .0003785     4.91   0.000     .0011147    .0026013
    pscoreC4 |  -.0030179   .0007111    -4.24   0.000    -.0044142   -.0016216
------------------------------------------------------------------------------

. scalar Andrews = e(N)*e(r2)

. display "GoF Test N R^2 = " e(N)*e(r2) " with p-value = " chi2tail($MAXCOUNT,e(N)*e(r2))
GoF Test N R^2 = 252.58037 with p-value = 1.536e-52

. 
. * Negbin2
. nbreg TRIPS $XLIST, dispersion(mean)

Fitting Poisson model:

Iteration 0:   log likelihood =  -2866.625  
Iteration 1:   log likelihood = -1811.5015  
Iteration 2:   log likelihood = -1536.5136  
Iteration 3:   log likelihood = -1529.4565  
Iteration 4:   log likelihood = -1529.4313  
Iteration 5:   log likelihood = -1529.4313  

Fitting constant-only model:

Iteration 0:   log likelihood = -1320.5971  
Iteration 1:   log likelihood = -1065.6673  
Iteration 2:   log likelihood =  -1064.723  
Iteration 3:   log likelihood = -1064.7225  
Iteration 4:   log likelihood = -1064.7225  

Fitting full model:

Iteration 0:   log likelihood = -992.69381  (not concave)
Iteration 1:   log likelihood = -922.08966  
Iteration 2:   log likelihood = -831.14918  
Iteration 3:   log likelihood = -825.59425  
Iteration 4:   log likelihood = -825.55759  
Iteration 5:   log likelihood = -825.55758  

Negative binomial regression                      Number of obs   =        659
                                                  LR chi2(7)      =     478.33
Dispersion     = mean                             Prob > chi2     =     0.0000
Log likelihood = -825.55758                       Pseudo R2       =     0.2246

------------------------------------------------------------------------------
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          SO |    .721999   .0453323    15.93   0.000     .6331493    .8108487
         SKI |   .6121388   .1504163     4.07   0.000     .3173282    .9069493
           I |  -.0260589   .0452342    -0.58   0.565    -.1147163    .0625986
         FC3 |   .6691677   .3614399     1.85   0.064    -.0392415    1.377577
          C1 |   .0480086   .0159516     3.01   0.003      .016744    .0792732
          C3 |   -.092691   .0082685   -11.21   0.000    -.1088969   -.0764851
          C4 |   .0388357   .0117139     3.32   0.001     .0158769    .0617945
       _cons |  -1.121936   .2208284    -5.08   0.000    -1.554752   -.6891205
-------------+----------------------------------------------------------------
    /lnalpha |   .3157293   .1060209                      .1079321    .5235264
-------------+----------------------------------------------------------------
       alpha |   1.371259   .1453821                      1.113972     1.68797
------------------------------------------------------------------------------
Likelihood-ratio test of alpha=0:  chibar2(01) = 1407.75 Prob>=chibar2 = 0.000

. estimates store NB2def

. nbreg TRIPS $XLIST, vce(robust) dispersion(mean)

Fitting Poisson model:

Iteration 0:   log pseudolikelihood =  -2866.625  
Iteration 1:   log pseudolikelihood = -1811.5015  
Iteration 2:   log pseudolikelihood = -1536.5136  
Iteration 3:   log pseudolikelihood = -1529.4565  
Iteration 4:   log pseudolikelihood = -1529.4313  
Iteration 5:   log pseudolikelihood = -1529.4313  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -1320.5971  
Iteration 1:   log pseudolikelihood = -1065.6673  
Iteration 2:   log pseudolikelihood =  -1064.723  
Iteration 3:   log pseudolikelihood = -1064.7225  
Iteration 4:   log pseudolikelihood = -1064.7225  

Fitting full model:

Iteration 0:   log pseudolikelihood = -992.69381  (not concave)
Iteration 1:   log pseudolikelihood = -922.08966  
Iteration 2:   log pseudolikelihood = -831.14918  
Iteration 3:   log pseudolikelihood = -825.59425  
Iteration 4:   log pseudolikelihood = -825.55759  
Iteration 5:   log pseudolikelihood = -825.55758  

Negative binomial regression                      Number of obs   =        659
Dispersion           = mean                       Wald chi2(7)    =     445.58
Log pseudolikelihood = -825.55758                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          SO |    .721999   .0583691    12.37   0.000     .6075977    .8364004
         SKI |   .6121388   .2003177     3.06   0.002     .2195233    1.004754
           I |  -.0260589   .0548465    -0.48   0.635    -.1335561    .0814384
         FC3 |   .6691677   .3205802     2.09   0.037     .0408421    1.297493
          C1 |   .0480086   .0283108     1.70   0.090    -.0074795    .1034968
          C3 |   -.092691    .014518    -6.38   0.000    -.1211458   -.0642362
          C4 |   .0388357   .0177502     2.19   0.029      .004046    .0736254
       _cons |  -1.121936   .2964056    -3.79   0.000    -1.702881   -.5409919
-------------+----------------------------------------------------------------
    /lnalpha |   .3157293   .1350229                      .0510892    .5803693
-------------+----------------------------------------------------------------
       alpha |   1.371259   .1851514                      1.052417    1.786698
------------------------------------------------------------------------------

. estimates store NB2

. foreach y of numlist 0/5 8 11 14 17 62 {
  2.    predict pnb`y', pr(`y')
  3.    predict cumnb`y', pr(0,`y')
  4.    }

. replace pnb8 = cumnb8 - cumnb5
(659 real changes made)

. replace pnb11 = cumnb11 - cumnb8
(659 real changes made)

. replace pnb14 = cumnb14 - cumnb11
(658 real changes made)

. replace pnb17 = cumnb17 - cumnb14
(658 real changes made)

. replace pnb62 = cumnb62 - cumnb17
(326 real changes made)

. 
. * Negbin2 check: fitted mean is unusually large
. predict munb2
(option n assumed; predicted number of events)

. summarize munb2, detail

                 Predicted number of events
-------------------------------------------------------------
      Percentiles      Smallest
 1%     .0259999       .0006295
 5%     .0520313       .0147986
10%     .0689261       .0151538       Obs                 659
25%      .111235       .0203141       Sum of Wgt.         659

50%     .2366224                      Mean           8.962897
                        Largest       Std. Dev.      152.0876
75%      2.78074       66.65919
90%     8.571424       71.44934       Variance       23130.64
95%     15.47732        83.7941       Skewness       25.51657
99%     40.38062       3902.384       Kurtosis       653.7082

. 
. * Negbin1
. nbreg TRIPS $XLIST, vce(robust) dispersion(constant) 

Fitting Poisson model:

Iteration 0:   log pseudolikelihood =  -2866.625  
Iteration 1:   log pseudolikelihood = -1811.5015  
Iteration 2:   log pseudolikelihood = -1536.5136  
Iteration 3:   log pseudolikelihood = -1529.4565  
Iteration 4:   log pseudolikelihood = -1529.4313  
Iteration 5:   log pseudolikelihood = -1529.4313  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -1604.1198  
Iteration 1:   log pseudolikelihood =  -1446.016  
Iteration 2:   log pseudolikelihood = -1202.8116  
Iteration 3:   log pseudolikelihood = -1065.0775  
Iteration 4:   log pseudolikelihood = -1064.7226  
Iteration 5:   log pseudolikelihood = -1064.7225  

Fitting full model:

Iteration 0:   log pseudolikelihood = -1064.7225  
Iteration 1:   log pseudolikelihood = -1054.8431  
Iteration 2:   log pseudolikelihood = -992.64056  
Iteration 3:   log pseudolikelihood =  -868.3528  
Iteration 4:   log pseudolikelihood = -848.97958  
Iteration 5:   log pseudolikelihood = -833.63151  
Iteration 6:   log pseudolikelihood = -833.54833  
Iteration 7:   log pseudolikelihood = -833.54831  

Negative binomial regression                      Number of obs   =        659
Dispersion           = constant                   Wald chi2(7)    =     501.90
Log pseudolikelihood = -833.54831                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          SO |   .5760759   .0273407    21.07   0.000     .5224891    .6296628
         SKI |    .181337   .1281728     1.41   0.157    -.0698771    .4325511
           I |  -.0179127   .0302619    -0.59   0.554    -.0772249    .0413994
         FC3 |   1.034979   .2866802     3.61   0.000     .4730959    1.596862
          C1 |   .0018225   .0116311     0.16   0.875    -.0209741     .024619
          C3 |  -.0279032   .0090972    -3.07   0.002    -.0457333   -.0100731
          C4 |    .023511    .008059     2.92   0.004     .0077156    .0393063
       _cons |  -.6201893   .2049484    -3.03   0.002    -1.021881   -.2184979
-------------+----------------------------------------------------------------
    /lndelta |   1.884622   .2013934                      1.489898    2.279345
-------------+----------------------------------------------------------------
       delta |   6.583863   1.325946                      4.436642    9.770282
------------------------------------------------------------------------------

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |    659   -1064.722   -833.5483      9     1685.097    1725.513
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. estimates store NB1

. predict munb1
(option n assumed; predicted number of events)

. summarize munb1, detail

                 Predicted number of events
-------------------------------------------------------------
      Percentiles      Smallest
 1%     .2067848       .0625774
 5%     .2729032       .1470124
10%     .3019193       .1746988       Obs                 659
25%     .3620908       .1768115       Sum of Wgt.         659

50%     .4815007                      Mean           2.244309
                        Largest       Std. Dev.       3.82433
75%     3.122336       24.16492
90%     6.307141       30.96744       Variance        14.6255
95%      8.54717       36.73519       Skewness       5.185864
99%     14.80399       46.72718       Kurtosis       46.48673

. 
. * Negbin2 with quadratic and interactions in costs
. generate C1sq = C1*C1

. generate C3sq = C3*C3

. generate C4sq = C4*C4

. generate C1C3 = C1*C3

. generate C1C4 = C1*C4

. generate C3C4 = C3*C4

. nbreg TRIPS SO I SKI FC3 C*, vce(robust)

Fitting Poisson model:

Iteration 0:   log pseudolikelihood =  -3184.358  
Iteration 1:   log pseudolikelihood = -2129.3162  
Iteration 2:   log pseudolikelihood = -1308.0042  
Iteration 3:   log pseudolikelihood = -1244.1194  
Iteration 4:   log pseudolikelihood = -1236.2064  
Iteration 5:   log pseudolikelihood = -1235.9239  
Iteration 6:   log pseudolikelihood = -1235.9221  
Iteration 7:   log pseudolikelihood = -1235.9221  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -1320.5971  
Iteration 1:   log pseudolikelihood = -1065.6673  
Iteration 2:   log pseudolikelihood =  -1064.723  
Iteration 3:   log pseudolikelihood = -1064.7225  
Iteration 4:   log pseudolikelihood = -1064.7225  

Fitting full model:

Iteration 0:   log pseudolikelihood = -992.32956  (not concave)
Iteration 1:   log pseudolikelihood = -882.58831  
Iteration 2:   log pseudolikelihood = -806.27482  
Iteration 3:   log pseudolikelihood = -802.84247  
Iteration 4:   log pseudolikelihood = -802.49382  
Iteration 5:   log pseudolikelihood = -802.49002  
Iteration 6:   log pseudolikelihood = -802.49002  

Negative binomial regression                      Number of obs   =        659
Dispersion           = mean                       Wald chi2(13)   =     531.29
Log pseudolikelihood = -802.49002                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          SO |   .6776066   .0587344    11.54   0.000     .5624892    .7927239
           I |  -.0147004   .0530642    -0.28   0.782    -.1187044    .0893035
         SKI |   .5782513   .1885648     3.07   0.002     .2086711    .9478315
         FC3 |    .570499   .3344164     1.71   0.088    -.0849451    1.225943
          C1 |   .0857148   .0370514     2.31   0.021     .0130953    .1583343
          C3 |  -.1402702   .0209839    -6.68   0.000     -.181398   -.0991424
          C4 |   .0507941   .0237569     2.14   0.033     .0042313    .0973568
        C1sq |  -.0053421   .0018563    -2.88   0.004    -.0089804   -.0017038
        C3sq |  -.0008515   .0007621    -1.12   0.264    -.0023451    .0006422
        C4sq |  -.0002016   .0003803    -0.53   0.596     -.000947    .0005438
        C1C3 |   .0060414    .002118     2.85   0.004     .0018902    .0101926
        C1C4 |   .0038352   .0018945     2.02   0.043     .0001221    .0075483
        C3C4 |   -.003484   .0021661    -1.61   0.108    -.0077294    .0007614
       _cons |  -1.160403   .3250511    -3.57   0.000    -1.797492   -.5233147
-------------+----------------------------------------------------------------
    /lnalpha |   .0938501   .1339843                     -.1687543    .3564544
-------------+----------------------------------------------------------------
       alpha |   1.098395   .1471677                      .8447164    1.428256
------------------------------------------------------------------------------

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |    659   -1064.722     -802.49     15      1634.98    1702.341
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. predict munb2interact
(option n assumed; predicted number of events)

. summarize munb2interact, detail

                 Predicted number of events
-------------------------------------------------------------
      Percentiles      Smallest
 1%      .014851       1.46e-18
 5%     .0402354       .0041866
10%      .061906       .0057527       Obs                 659
25%     .0988699       .0064088       Sum of Wgt.         659

50%     .2306382                      Mean           2.799993
                        Largest       Std. Dev.      6.556366
75%     2.492393       38.06474
90%     8.111975       42.24525       Variance       42.98593
95%     13.57655       53.02405       Skewness       4.707932
99%     35.79942       70.33098       Kurtosis        32.9643

. 
. *** TABLE 6.11: POISSON and NB2 ESTIMATES
. 
. estimates table POISSdef POISSON NB2def NB2, b(%9.3f) t(%10.2f) ///
>    stats(ll aic bic N k) equations(1)

------------------------------------------------------------------
    Variable |  POISSdef     POISSON       NB2def        NB2      
-------------+----------------------------------------------------
#1           |
          SO |      0.472        0.472        0.722        0.722  
             |      27.60         9.65        15.93        12.37  
         SKI |      0.418        0.418        0.612        0.612  
             |       7.31         2.16         4.07         3.06  
           I |     -0.111       -0.111       -0.026       -0.026  
             |      -5.68        -2.21        -0.58        -0.48  
         FC3 |      0.898        0.898        0.669        0.669  
             |      11.37         3.63         1.85         2.09  
          C1 |     -0.003       -0.003        0.048        0.048  
             |      -1.10        -0.23         3.01         1.70  
          C3 |     -0.043       -0.043       -0.093       -0.093  
             |     -25.47        -3.62       -11.21        -6.38  
          C4 |      0.036        0.036        0.039        0.039  
             |      13.34         3.85         3.32         2.19  
       _cons |      0.265        0.265       -1.122       -1.122  
             |       2.83         0.61        -5.08        -3.79  
-------------+----------------------------------------------------
lnalpha      |
       _cons |                                0.316        0.316  
             |                                 2.98         2.34  
-------------+----------------------------------------------------
Statistics   |                                                    
          ll |  -1529.431    -1529.431     -825.558     -825.558  
         aic |   3074.863     3074.863     1669.115     1669.115  
         bic |   3110.788     3110.788     1709.532     1709.532  
           N |        659          659          659          659  
           k |      8.000        8.000        9.000        9.000  
------------------------------------------------------------------
                                                       legend: b/t

. 
. *** TABLE 6.14 (Part 1): PREDICTED PROBABILITIES FROM POISSON AND NB2
. 
. tabulate TRIPS 

  Number of |
    boating |
   trips to |
       Lake |
 Somerville |
    in 1980 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        417       63.28       63.28
          1 |         68       10.32       73.60
          2 |         38        5.77       79.36
          3 |         34        5.16       84.52
          4 |         17        2.58       87.10
          5 |         13        1.97       89.07
          6 |         11        1.67       90.74
          7 |          2        0.30       91.05
          8 |          8        1.21       92.26
          9 |          1        0.15       92.41
         10 |         13        1.97       94.39
         11 |          2        0.30       94.69
         12 |          5        0.76       95.45
         15 |         14        2.12       97.57
         16 |          1        0.15       97.72
         20 |          3        0.46       98.18
         25 |          3        0.46       98.63
         26 |          1        0.15       98.79
         30 |          3        0.46       99.24
         40 |          3        0.46       99.70
         50 |          1        0.15       99.85
         88 |          1        0.15      100.00
------------+-----------------------------------
      Total |        659      100.00

. sum pp*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         pp0 |       659    .4196377    .2993687   7.85e-37    .982392
         pp1 |       659    .2208405    .1181427   6.52e-35   .3678773
         pp2 |       659    .1030655     .080823   2.71e-33   .2706588
         pp3 |       659    .0616823    .0749082   7.52e-32   .2240418
         pp4 |       659    .0448711    .0671734   1.56e-30   .1953618
-------------+--------------------------------------------------------
         pp5 |       659    .0344572    .0580832   2.60e-29    .175465
         pp8 |       659     .060924    .1206823          0   .4284386
        pp11 |       659    .0255609    .0718394          0   .3630392
        pp14 |       659    .0117349    .0483664          0   .3211519
        pp17 |       659    .0059385    .0321014          0   .2905961
-------------+--------------------------------------------------------
        pp62 |       659    .0097842    .0810561          0   .9994811

. sum cump*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       cump0 |       659    .4196377    .2993687   7.85e-37    .982392
       cump1 |       659    .6404782    .3694934   6.60e-35   .9998441
       cump2 |       659    .7435437    .3554941   2.78e-33   .9999991
       cump3 |       659    .8052259      .32044   7.79e-32          1
       cump4 |       659    .8500971    .2834526   1.64e-30          1
-------------+--------------------------------------------------------
       cump5 |       659    .8845543    .2500909   2.76e-29          1
       cump8 |       659    .9454783    .1785921   4.91e-26          1
      cump11 |       659    .9710392    .1349753   2.96e-23          1
      cump14 |       659    .9827741    .1070785   8.13e-21          1
      cump17 |       659    .9887126    .0897666   1.20e-18          1
-------------+--------------------------------------------------------
      cump62 |       659    .9984968    .0385877   .0094143          1

. sum pnb*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        pnb0 |       659    .6418745    .3082488   .0019096   .9993709
        pnb1 |       659    .1224031    .0561099   .0006286    .224679
        pnb2 |       659    .0503028    .0452092   4.69e-07   .1293086
        pnb3 |       659    .0303256    .0347147   3.68e-10   .0908396
        pnb4 |       659    .0214932     .027299   2.96e-13   .0700097
-------------+--------------------------------------------------------
        pnb5 |       659    .0164107    .0221661   2.41e-16   .0569552
        pnb8 |       659     .032676    .0475893          0   .1254335
       pnb11 |       659    .0196791    .0316183          0   .0887708
       pnb14 |       659    .0131008    .0228531          0   .0687326
       pnb17 |       659    .0092751    .0174332          0   .0560916
-------------+--------------------------------------------------------
       pnb62 |       659     .034165    .0829472          0    .366749

. sum cumnb*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      cumnb0 |       659    .6418745    .3082488   .0019096   .9993709
      cumnb1 |       659    .7642776     .296349   .0033019   .9999995
      cumnb2 |       659    .8145804      .26861   .0045056          1
      cumnb3 |       659     .844906     .244619   .0056004          1
      cumnb4 |       659    .8663992    .2249148   .0066209          1
-------------+--------------------------------------------------------
      cumnb5 |       659    .8828099    .2085443   .0075859          1
      cumnb8 |       659    .9154859    .1724799   .0102482          1
     cumnb11 |       659     .935165    .1480781   .0126716          1
     cumnb14 |       659    .9482658    .1302771   .0149316          1
     cumnb17 |       659    .9575409     .116646   .0170694          1
-------------+--------------------------------------------------------
     cumnb62 |       659    .9917059    .0520976   .0425734          1

. 
. ********* 6.4.3 MODIFIED COUNT MODELS (Tables 6.12 and 6.13)
. 
. *** FINITE MIXTURES MODELS (Table 6.12) 
. 
. ** Note: finite Mixtrues here does not reproduce earlier results of Gurmu and Trivedi
. * They have lnL = -916.63
. * Here lnL = -938.66 if use difficult option and
. * and  lnL = -956.84 if do not.
. * Gurmu and Trivedi found lower lnL so report that.
. 
. * Finite mixtures Poisson - 2 components unconstrained
. * Without difficult option
. fmm TRIPS $XLIST, components(2) mixtureof(poisson) vce(robust)

Fitting Poisson model:

Iteration 0:   log likelihood =  -2866.625  
Iteration 1:   log likelihood = -1811.5015  
Iteration 2:   log likelihood = -1536.5136  
Iteration 3:   log likelihood = -1529.4565  
Iteration 4:   log likelihood = -1529.4313  
Iteration 5:   log likelihood = -1529.4313  

Fitting 2 component Poisson model:

Iteration 0:   log pseudolikelihood = -1524.4609  (not concave)
Iteration 1:   log pseudolikelihood = -1217.3991  
Iteration 2:   log pseudolikelihood = -1138.4069  (not concave)
Iteration 3:   log pseudolikelihood = -1115.5687  (not concave)
Iteration 4:   log pseudolikelihood = -1080.2392  (not concave)
Iteration 5:   log pseudolikelihood = -1080.0906  (not concave)
Iteration 6:   log pseudolikelihood = -1069.6348  (not concave)
Iteration 7:   log pseudolikelihood = -1048.0558  (not concave)
Iteration 8:   log pseudolikelihood = -1011.9261  (not concave)
Iteration 9:   log pseudolikelihood = -996.26291  (not concave)
Iteration 10:  log pseudolikelihood = -990.61711  
Iteration 11:  log pseudolikelihood =  -960.5608  
Iteration 12:  log pseudolikelihood = -957.22066  
Iteration 13:  log pseudolikelihood =  -956.8399  
Iteration 14:  log pseudolikelihood = -956.83968  
Iteration 15:  log pseudolikelihood = -956.83968  

2 component Poisson regression                    Number of obs   =        659
                                                  Wald chi2(14)   =    1111.14
Log pseudolikelihood = -956.83968                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
          SO |   .6125998   .0363714    16.84   0.000     .5413132    .6838865
         SKI |   .4763238   .1781983     2.67   0.008     .1270616     .825586
           I |   -.073048   .0456672    -1.60   0.110    -.1625541    .0164581
         FC3 |   1.315873   .1875421     7.02   0.000     .9482973    1.683449
          C1 |     -.0017     .01179    -0.14   0.885     -.024808    .0214079
          C3 |  -.0580426   .0077103    -7.53   0.000    -.0731546   -.0429307
          C4 |   .0543631   .0104186     5.22   0.000     .0339431    .0747832
       _cons |  -1.243061      .2442    -5.09   0.000    -1.721684   -.7644376
-------------+----------------------------------------------------------------
component2   |
          SO |  -.0530802   .0836292    -0.63   0.526    -.2169903      .11083
         SKI |   .3634098   .2212908     1.64   0.101    -.0703122    .7971318
           I |  -.3740674   .1153315    -3.24   0.001    -.6001129   -.1480218
         FC3 |  -.8493415   .5523961    -1.54   0.124    -1.932018     .233335
          C1 |   .0048554   .0161729     0.30   0.764     -.026843    .0365537
          C3 |  -.0118398   .0113883    -1.04   0.299    -.0341604    .0104808
          C4 |  -.0051648   .0089645    -0.58   0.565    -.0227349    .0124053
       _cons |   4.707441   .7283489     6.46   0.000     3.279904    6.134979
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.441621   .1749126    13.96   0.000     2.098799    2.784443
------------------------------------------------------------------------------
         pi1 |   .9199465   .0128814                      .8907863    .9418293
         pi2 |   .0800535   .0128814                      .0581707    .1092137
------------------------------------------------------------------------------

. 
. * Finite mixtures Poisson - 2 components unconstrained
. * With difficult option
. fmm TRIPS $XLIST, components(2) mixtureof(poisson) vce(robust) difficult

Fitting Poisson model:

Iteration 0:   log likelihood =  -2866.625  
Iteration 1:   log likelihood = -1811.5015  
Iteration 2:   log likelihood = -1536.5136  
Iteration 3:   log likelihood = -1529.4565  
Iteration 4:   log likelihood = -1529.4313  
Iteration 5:   log likelihood = -1529.4313  

Fitting 2 component Poisson model:

Iteration 0:   log pseudolikelihood = -1524.4609  (not concave)
Iteration 1:   log pseudolikelihood = -1280.3416  (not concave)
Iteration 2:   log pseudolikelihood = -1214.9785  (not concave)
Iteration 3:   log pseudolikelihood = -1046.3108  (not concave)
Iteration 4:   log pseudolikelihood = -961.73474  
Iteration 5:   log pseudolikelihood = -959.10633  
Iteration 6:   log pseudolikelihood = -954.30525  
Iteration 7:   log pseudolikelihood = -948.87554  
Iteration 8:   log pseudolikelihood = -948.81289  
Iteration 9:   log pseudolikelihood = -942.35939  
Iteration 10:  log pseudolikelihood = -938.71046  
Iteration 11:  log pseudolikelihood = -938.66008  
Iteration 12:  log pseudolikelihood = -938.66004  

2 component Poisson regression                    Number of obs   =        659
                                                  Wald chi2(14)   =     943.65
Log pseudolikelihood = -938.66004                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
          SO |   .6551551   .0437756    14.97   0.000     .5693564    .7409537
         SKI |   .4376842   .1787585     2.45   0.014     .0873241    .7880443
           I |  -.0098197    .049289    -0.20   0.842    -.1064245     .086785
         FC3 |   1.542281   .1919338     8.04   0.000     1.166098    1.918465
          C1 |  -.0442385   .0184437    -2.40   0.016    -.0803875   -.0080894
          C3 |  -.0292213   .0102599    -2.85   0.004    -.0493303   -.0091123
          C4 |   .0695349   .0138194     5.03   0.000     .0424494    .0966203
       _cons |  -1.766423   .2855313    -6.19   0.000    -2.326054   -1.206792
-------------+----------------------------------------------------------------
component2   |
          SO |   .0859619   .1370339     0.63   0.530    -.1826197    .3545435
         SKI |    .630614   .1841031     3.43   0.001     .2697785    .9914495
           I |    .002736   .1559299     0.02   0.986     -.302881    .3083531
         FC3 |  -.6874224   .3623183    -1.90   0.058    -1.397553    .0227084
          C1 |   .0740427   .0220197     3.36   0.001     .0308848    .1172005
          C3 |   -.072647    .012837    -5.66   0.000    -.0978071   -.0474869
          C4 |  -.0137317   .0166229    -0.83   0.409    -.0463119    .0188485
       _cons |   2.479197    1.10946     2.23   0.025     .3046957    4.653698
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.298382    .213278    10.78   0.000     1.880365    2.716399
------------------------------------------------------------------------------
         pi1 |   .9087429    .017687                       .867653    .9379874
         pi2 |   .0912571    .017687                      .0620126     .132347
------------------------------------------------------------------------------

. estimates store FMP2

. predict fmmpmu1, eq(component1)

. predict fmmpmu2, eq(component2)

. summarize fmmpmu1 fmmpmu2, detail

                 predicted mean: component1
-------------------------------------------------------------
      Percentiles      Smallest
 1%     .0417949       .0021269
 5%     .0655968       .0089509
10%     .0787248       .0232972       Obs                 659
25%     .1112899       .0296951       Sum of Wgt.         659

50%     .2107916                      Mean           1.586541
                        Largest       Std. Dev.      8.625211
75%     1.390841       23.42982
90%     3.381974       31.72486       Variance       74.39427
95%     5.191111       45.49994       Skewness       21.10818
99%     18.00034       207.6996       Kurtosis        497.778

                 predicted mean: component2
-------------------------------------------------------------
      Percentiles      Smallest
 1%     .4786181       .0779567
 5%     1.571355       .0811914
10%     2.324083       .0968075       Obs                 659
25%     3.564886       .1239639       Sum of Wgt.         659

50%     5.936271                      Mean           18.12704
                        Largest       Std. Dev.      196.6486
75%     10.94436       54.97381
90%     16.15627       77.84518       Variance       38670.67
95%      24.3079       1534.837       Skewness       22.81481
99%     50.37337       4818.031       Kurtosis       545.6433

. 
. * Finite mixtures NB2 - 2 components unconstrained
. fmm TRIPS $XLIST, components(2) mixtureof(negbin2) vce(robust)

Fitting Negative Binomial-2 model:

Iteration 0:   log likelihood =  -2866.625  
Iteration 1:   log likelihood = -1811.5015  
Iteration 2:   log likelihood = -1536.5136  
Iteration 3:   log likelihood = -1529.4565  
Iteration 4:   log likelihood = -1529.4313  
Iteration 5:   log likelihood = -1529.4313  

Iteration 0:   log likelihood = -1320.5971  
Iteration 1:   log likelihood = -1065.6673  
Iteration 2:   log likelihood =  -1064.723  
Iteration 3:   log likelihood = -1064.7225  
Iteration 4:   log likelihood = -1064.7225  

Iteration 0:   log likelihood = -992.69381  (not concave)
Iteration 1:   log likelihood = -922.08966  
Iteration 2:   log likelihood = -831.14918  
Iteration 3:   log likelihood = -825.59425  
Iteration 4:   log likelihood = -825.55759  
Iteration 5:   log likelihood = -825.55758  

Fitting 2 component Negative Binomial-2 model:

Iteration 0:   log pseudolikelihood =  -825.5329  (not concave)
Iteration 1:   log pseudolikelihood = -825.45949  (not concave)
Iteration 2:   log pseudolikelihood = -823.21264  (not concave)
Iteration 3:   log pseudolikelihood = -811.45138  (not concave)
Iteration 4:   log pseudolikelihood = -806.56567  (not concave)
Iteration 5:   log pseudolikelihood = -805.06456  (not concave)
Iteration 6:   log pseudolikelihood = -803.84485  (not concave)
Iteration 7:   log pseudolikelihood = -803.26165  (not concave)
Iteration 8:   log pseudolikelihood = -802.79504  (not concave)
Iteration 9:   log pseudolikelihood = -802.37502  (not concave)
Iteration 10:  log pseudolikelihood = -801.93829  (not concave)
Iteration 11:  log pseudolikelihood = -801.50465  (not concave)
Iteration 12:  log pseudolikelihood = -801.07984  (not concave)
Iteration 13:  log pseudolikelihood = -800.67995  (not concave)
Iteration 14:  log pseudolikelihood = -800.32312  (not concave)
Iteration 15:  log pseudolikelihood = -799.99895  
Iteration 16:  log pseudolikelihood = -796.70987  (not concave)
Iteration 17:  log pseudolikelihood = -796.11797  (not concave)
Iteration 18:  log pseudolikelihood = -795.85818  
Iteration 19:  log pseudolikelihood = -794.76895  
Iteration 20:  log pseudolikelihood = -791.38168  
Iteration 21:  log pseudolikelihood = -791.09041  (not concave)
Iteration 22:  log pseudolikelihood =  -791.0208  (not concave)
Iteration 23:  log pseudolikelihood = -790.89092  (not concave)
Iteration 24:  log pseudolikelihood = -790.74051  (not concave)
Iteration 25:  log pseudolikelihood =  -790.5897  (not concave)
Iteration 26:  log pseudolikelihood = -790.21083  (not concave)
Iteration 27:  log pseudolikelihood = -790.14548  
Iteration 28:  log pseudolikelihood = -789.83716  (not concave)
Iteration 29:  log pseudolikelihood = -788.71971  
Iteration 30:  log pseudolikelihood = -787.77451  
Iteration 31:  log pseudolikelihood = -786.69223  
Iteration 32:  log pseudolikelihood = -786.07348  
Iteration 33:  log pseudolikelihood = -786.03456  
Iteration 34:  log pseudolikelihood = -786.01032  
Iteration 35:  log pseudolikelihood = -786.01004  
Iteration 36:  log pseudolikelihood = -786.01004  

2 component Negative Binomial-2 regression        Number of obs   =        659
                                                  Wald chi2(14)   =     971.59
Log pseudolikelihood = -786.01004                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
          SO |   .8897931   .0447052    19.90   0.000     .8021725    .9774138
         SKI |   .4493153   .1794648     2.50   0.012     .0975707    .8010598
           I |  -.0487088   .0476779    -1.02   0.307    -.1421558    .0447381
         FC3 |   1.069746   .3599138     2.97   0.003     .3643283    1.775165
          C1 |  -.0001105   .0178368    -0.01   0.995    -.0350701     .034849
          C3 |  -.0500733   .0095576    -5.24   0.000    -.0688059   -.0313407
          C4 |   .0469594   .0151094     3.11   0.002     .0173455    .0765732
       _cons |  -1.876866   .2056477    -9.13   0.000    -2.279928   -1.473804
-------------+----------------------------------------------------------------
component2   |
          SO |  -.0949407   .2232259    -0.43   0.671    -.5324554    .3425739
         SKI |   1.369172   .3856075     3.55   0.000      .613395    2.124949
           I |  -.0327249   .1394548    -0.23   0.814    -.3060514    .2406015
         FC3 |  -.1294348   .3026502    -0.43   0.669    -.7226183    .4637488
          C1 |   .1858894   .0247869     7.50   0.000     .1373079    .2344708
          C3 |  -.2527872   .0265495    -9.52   0.000    -.3048233   -.2007512
          C4 |   .0486012   .0142185     3.42   0.001     .0207335    .0764689
       _cons |   1.006089   .9680322     1.04   0.299    -.8912195    2.903397
-------------+----------------------------------------------------------------
 /imlogitpi1 |   1.952194   .5181711     3.77   0.000     .9365978    2.967791
   /lnalpha1 |  -.1916578   .1318739    -1.45   0.146    -.4501258    .0668102
   /lnalpha2 |  -1.646558   .5327954    -3.09   0.002    -2.690818   -.6022984
------------------------------------------------------------------------------
      alpha1 |   .8255893   .1088737                      .6375479    1.069093
      alpha2 |    .192712   .1026761                      .0678254    .5475517
         pi1 |   .8756857   .0564082                      .7184119    .9510976
         pi2 |   .1243143   .0564082                      .0489024    .2815881
------------------------------------------------------------------------------

. estimates store FMNB2

. predict fmmnb2mu1, eq(component1)

. predict fmmnb2mu2, eq(component2)

. summarize fmmnb2mu1 fmmnb2mu2, detail

                 predicted mean: component1
-------------------------------------------------------------
      Percentiles      Smallest
 1%     .0282895       .0033164
 5%     .0485094       .0224942
10%     .0559414       .0236705       Obs                 659
25%     .0765332       .0250522       Sum of Wgt.         659

50%     .1354479                      Mean           2.767834
                        Largest       Std. Dev.      11.62284
75%     2.365206       56.20646
90%     6.883991       64.61595       Variance       135.0904
95%     12.02669       73.07887       Skewness       16.80953
99%     30.49224       257.0614       Kurtosis       353.0671

                 predicted mean: component2
-------------------------------------------------------------
      Percentiles      Smallest
 1%      .001958       2.06e-07
 5%     .0111711       .0003645
10%     .0248065       .0004218       Obs                 659
25%     .0938323       .0009144       Sum of Wgt.         659

50%     .2847602                      Mean           29313.54
                        Largest       Std. Dev.      539008.6
75%     1.623237       845.1647
90%     10.30647       62751.63       Variance       2.91e+11
95%     31.85419        7829068       Skewness       18.96553
99%     251.8368       1.14e+07       Kurtosis       370.3982

. 
. * Finite mixtures NB1 - 2 components unconstrained
. fmm TRIPS $XLIST, components(2) mixtureof(negbin1) vce(robust)

Fitting Negative Binomial-1 model:

Iteration 0:   log likelihood =  -2866.625  
Iteration 1:   log likelihood = -1811.5015  
Iteration 2:   log likelihood = -1536.5136  
Iteration 3:   log likelihood = -1529.4565  
Iteration 4:   log likelihood = -1529.4313  
Iteration 5:   log likelihood = -1529.4313  

Iteration 0:   log likelihood = -1604.1198  
Iteration 1:   log likelihood =  -1446.016  
Iteration 2:   log likelihood = -1202.8116  
Iteration 3:   log likelihood = -1065.0775  
Iteration 4:   log likelihood = -1064.7226  
Iteration 5:   log likelihood = -1064.7225  

Iteration 0:   log likelihood = -1064.7225  
Iteration 1:   log likelihood = -1054.8431  
Iteration 2:   log likelihood = -992.64056  
Iteration 3:   log likelihood =  -868.3528  
Iteration 4:   log likelihood = -848.97958  
Iteration 5:   log likelihood = -833.63151  
Iteration 6:   log likelihood = -833.54833  
Iteration 7:   log likelihood = -833.54831  

Fitting 2 component Negative Binomial-1 model:

Iteration 0:   log pseudolikelihood = -833.54883  (not concave)
Iteration 1:   log pseudolikelihood =  -832.9275  (not concave)
Iteration 2:   log pseudolikelihood = -831.58497  (not concave)
Iteration 3:   log pseudolikelihood = -823.67474  (not concave)
Iteration 4:   log pseudolikelihood =  -820.6545  (not concave)
Iteration 5:   log pseudolikelihood = -818.97364  (not concave)
Iteration 6:   log pseudolikelihood = -817.04827  (not concave)
Iteration 7:   log pseudolikelihood = -815.57719  (not concave)
Iteration 8:   log pseudolikelihood = -814.56683  (not concave)
Iteration 9:   log pseudolikelihood = -813.57901  (not concave)
Iteration 10:  log pseudolikelihood = -810.51864  (not concave)
Iteration 11:  log pseudolikelihood = -807.62792  (not concave)
Iteration 12:  log pseudolikelihood = -806.16542  (not concave)
Iteration 13:  log pseudolikelihood = -805.36078  (not concave)
Iteration 14:  log pseudolikelihood = -804.54236  (not concave)
Iteration 15:  log pseudolikelihood = -802.40439  (not concave)
Iteration 16:  log pseudolikelihood = -801.25777  (not concave)
Iteration 17:  log pseudolikelihood =  -800.8177  (not concave)
Iteration 18:  log pseudolikelihood = -800.58694  (not concave)
Iteration 19:  log pseudolikelihood =  -800.3811  (not concave)
Iteration 20:  log pseudolikelihood = -800.22547  (not concave)
Iteration 21:  log pseudolikelihood = -800.09644  (not concave)
Iteration 22:  log pseudolikelihood = -799.98204  (not concave)
Iteration 23:  log pseudolikelihood = -799.85523  (not concave)
Iteration 24:  log pseudolikelihood = -799.65886  (not concave)
Iteration 25:  log pseudolikelihood = -799.51985  (not concave)
Iteration 26:  log pseudolikelihood = -799.37826  (not concave)
Iteration 27:  log pseudolikelihood =  -799.2473  (not concave)
Iteration 28:  log pseudolikelihood = -799.15169  (not concave)
Iteration 29:  log pseudolikelihood = -799.08573  (not concave)
Iteration 30:  log pseudolikelihood = -799.01712  (not concave)
Iteration 31:  log pseudolikelihood = -797.43501  (not concave)
Iteration 32:  log pseudolikelihood = -796.76575  (not concave)
Iteration 33:  log pseudolikelihood = -796.59355  (not concave)
Iteration 34:  log pseudolikelihood = -796.53124  (not concave)
Iteration 35:  log pseudolikelihood = -796.48198  (not concave)
Iteration 36:  log pseudolikelihood = -796.44097  (not concave)
Iteration 37:  log pseudolikelihood = -796.40559  (not concave)
Iteration 38:  log pseudolikelihood = -796.36935  (not concave)
Iteration 39:  log pseudolikelihood = -796.34033  (not concave)
Iteration 40:  log pseudolikelihood = -796.31301  (not concave)
Iteration 41:  log pseudolikelihood = -796.28411  (not concave)
Iteration 42:  log pseudolikelihood = -796.25644  (not concave)
Iteration 43:  log pseudolikelihood = -796.22963  (not concave)
Iteration 44:  log pseudolikelihood = -796.20184  (not concave)
Iteration 45:  log pseudolikelihood = -796.17326  (not concave)
Iteration 46:  log pseudolikelihood = -796.14422  (not concave)
Iteration 47:  log pseudolikelihood = -796.11461  (not concave)
Iteration 48:  log pseudolikelihood = -796.08421  (not concave)
Iteration 49:  log pseudolikelihood = -796.05324  (not concave)
Iteration 50:  log pseudolikelihood = -796.02187  (not concave)
Iteration 51:  log pseudolikelihood = -795.99023  (not concave)
Iteration 52:  log pseudolikelihood = -795.95831  (not concave)
Iteration 53:  log pseudolikelihood = -795.92621  (not concave)
Iteration 54:  log pseudolikelihood =  -795.8939  (not concave)
Iteration 55:  log pseudolikelihood =  -795.8614  (not concave)
Iteration 56:  log pseudolikelihood =  -795.8286  (not concave)
Iteration 57:  log pseudolikelihood = -795.79549  (not concave)
Iteration 58:  log pseudolikelihood =   -795.762  (not concave)
Iteration 59:  log pseudolikelihood = -795.72809  (not concave)
Iteration 60:  log pseudolikelihood = -795.69373  (not concave)
Iteration 61:  log pseudolikelihood =  -795.6589  (not concave)
Iteration 62:  log pseudolikelihood = -795.62358  (not concave)
Iteration 63:  log pseudolikelihood = -795.58783  (not concave)
Iteration 64:  log pseudolikelihood = -795.55167  (not concave)
Iteration 65:  log pseudolikelihood = -795.51522  
Iteration 66:  log pseudolikelihood = -794.99016  
Iteration 67:  log pseudolikelihood = -794.58803  
Iteration 68:  log pseudolikelihood = -794.58224  
Iteration 69:  log pseudolikelihood = -794.58222  

2 component Negative Binomial-1 regression        Number of obs   =        659
                                                  Wald chi2(14)   =     965.62
Log pseudolikelihood = -794.58222                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
          SO |     .92547   .0626901    14.76   0.000     .8025996     1.04834
         SKI |  -.4255404   .2365718    -1.80   0.072    -.8892126    .0381318
           I |   .0731551   .1204633     0.61   0.544    -.1629485    .3092588
         FC3 |  -.6314727   .2284892    -2.76   0.006    -1.079303   -.1836421
          C1 |  -.0270125    .017598    -1.53   0.125    -.0615039    .0074789
          C3 |   .0025677   .0060045     0.43   0.669    -.0092009    .0143362
          C4 |   .0253309   .0160878     1.57   0.115    -.0062006    .0568623
       _cons |   -2.63441   .4901937    -5.37   0.000    -3.595172   -1.673648
-------------+----------------------------------------------------------------
component2   |
          SO |   .5105455   .0418441    12.20   0.000     .4285325    .5925585
         SKI |   .7456464   .1503196     4.96   0.000     .4510255    1.040267
           I |  -.0543847   .0438442    -1.24   0.215    -.1403177    .0315484
         FC3 |   .3046122   .2396505     1.27   0.204    -.1650941    .7743185
          C1 |   .0596445   .0110443     5.40   0.000     .0379981    .0812909
          C3 |  -.0963347   .0102403    -9.41   0.000    -.1164053    -.076264
          C4 |   .0298933   .0074505     4.01   0.000     .0152906     .044496
       _cons |  -.2869701   .2608747    -1.10   0.271    -.7982752    .2243349
-------------+----------------------------------------------------------------
 /imlogitpi1 |  -.7479719   .2559513    -2.92   0.003    -1.249627   -.2463166
   /lndelta1 |  -13.69168   1.777844    -7.70   0.000    -17.17619   -10.20717
   /lndelta2 |   1.742019   .2504394     6.96   0.000     1.251167    2.232871
------------------------------------------------------------------------------
      delta1 |   1.13e-06   2.01e-06                      3.47e-08    .0000369
      delta2 |   5.708858   1.429723                      3.494418    9.326606
         pi1 |   .3212634    .055811                      .2227647    .4387303
         pi2 |   .6787366    .055811                      .5612697    .7772353
------------------------------------------------------------------------------

. estimates store FMNB1

. predict fmmnb1mu1, eq(component1)

. predict fmmnb1mu2, eq(component2)

. summarize fmmnb1mu1 fmmnb1mu2, detail

                 predicted mean: component1
-------------------------------------------------------------
      Percentiles      Smallest
 1%     .0527696        .004925
 5%     .0619004       .0476774
10%     .0706775       .0503531       Obs                 659
25%     .0859038       .0505571       Sum of Wgt.         659

50%     .1169077                      Mean           1.417252
                        Largest       Std. Dev.      2.784524
75%     1.378191       12.67304
90%     4.676682       14.10757       Variance       7.753572
95%     7.774936       14.69514       Skewness       3.591086
99%     11.82099       29.77579       Kurtosis       23.17944

                 predicted mean: component2
-------------------------------------------------------------
      Percentiles      Smallest
 1%     .0465634       .0011169
 5%      .093645       .0234085
10%     .1364622       .0250417       Obs                 659
25%     .2231292       .0328587       Sum of Wgt.         659

50%      .470687                      Mean           8.843421
                        Largest       Std. Dev.       152.461
75%     2.893963       42.72643
90%     7.871804       66.10026       Variance       23244.35
95%     12.31917       83.66249       Skewness       25.53441
99%     38.01073       3912.738       Kurtosis       654.3214

. 
. * TO DO - get predicted probabilities
. 
. * Finite mixtures NB2 with quadratic and interactions in costs
. fmm TRIPS SO I SKI FC3 C*, components(2) mixtureof(negbin2) vce(robust) iter(120)

Fitting Negative Binomial-2 model:

Iteration 0:   log likelihood =  -3184.358  
Iteration 1:   log likelihood = -2129.3162  
Iteration 2:   log likelihood = -1308.0042  
Iteration 3:   log likelihood = -1244.1194  
Iteration 4:   log likelihood = -1236.2064  
Iteration 5:   log likelihood = -1235.9239  
Iteration 6:   log likelihood = -1235.9221  
Iteration 7:   log likelihood = -1235.9221  

Iteration 0:   log likelihood = -1320.5971  
Iteration 1:   log likelihood = -1065.6673  
Iteration 2:   log likelihood =  -1064.723  
Iteration 3:   log likelihood = -1064.7225  
Iteration 4:   log likelihood = -1064.7225  

Iteration 0:   log likelihood = -992.32956  (not concave)
Iteration 1:   log likelihood = -882.58831  
Iteration 2:   log likelihood = -806.27482  
Iteration 3:   log likelihood = -802.84247  
Iteration 4:   log likelihood = -802.49382  
Iteration 5:   log likelihood = -802.49002  
Iteration 6:   log likelihood = -802.49002  

Fitting 2 component Negative Binomial-2 model:

Iteration 0:   log pseudolikelihood = -802.46926  (not concave)
Iteration 1:   log pseudolikelihood = -799.71423  (not concave)
Iteration 2:   log pseudolikelihood = -787.25268  (not concave)
Iteration 3:   log pseudolikelihood = -784.25839  (not concave)
Iteration 4:   log pseudolikelihood = -782.98413  (not concave)
Iteration 5:   log pseudolikelihood =  -782.3245  (not concave)
Iteration 6:   log pseudolikelihood = -780.72215  (not concave)
Iteration 7:   log pseudolikelihood = -779.98831  (not concave)
Iteration 8:   log pseudolikelihood = -779.55662  (not concave)
Iteration 9:   log pseudolikelihood = -779.27651  (not concave)
Iteration 10:  log pseudolikelihood = -779.14581  (not concave)
Iteration 11:  log pseudolikelihood = -778.81098  (not concave)
Iteration 12:  log pseudolikelihood = -778.19088  (not concave)
Iteration 13:  log pseudolikelihood = -778.17448  (not concave)
Iteration 14:  log pseudolikelihood = -777.96353  (not concave)
Iteration 15:  log pseudolikelihood =  -777.8582  (not concave)
Iteration 16:  log pseudolikelihood =  -777.7557  (not concave)
Iteration 17:  log pseudolikelihood = -777.65543  (not concave)
Iteration 18:  log pseudolikelihood = -777.55607  (not concave)
Iteration 19:  log pseudolikelihood = -777.45859  (not concave)
Iteration 20:  log pseudolikelihood = -777.36319  (not concave)
Iteration 21:  log pseudolikelihood = -777.26963  (not concave)
Iteration 22:  log pseudolikelihood = -777.17756  (not concave)
Iteration 23:  log pseudolikelihood = -777.08729  (not concave)
Iteration 24:  log pseudolikelihood = -776.99846  (not concave)
Iteration 25:  log pseudolikelihood = -776.91091  (not concave)
Iteration 26:  log pseudolikelihood = -776.82416  (not concave)
Iteration 27:  log pseudolikelihood =  -776.7382  (not concave)
Iteration 28:  log pseudolikelihood = -776.65248  (not concave)
Iteration 29:  log pseudolikelihood = -776.56688  (not concave)
Iteration 30:  log pseudolikelihood = -776.48072  (not concave)
Iteration 31:  log pseudolikelihood = -776.39391  (not concave)
Iteration 32:  log pseudolikelihood = -776.30563  (not concave)
Iteration 33:  log pseudolikelihood = -776.21579  (not concave)
Iteration 34:  log pseudolikelihood = -776.12334  (not concave)
Iteration 35:  log pseudolikelihood = -776.02824  (not concave)
Iteration 36:  log pseudolikelihood =  -775.9293  (not concave)
Iteration 37:  log pseudolikelihood = -775.82655  (not concave)
Iteration 38:  log pseudolikelihood = -775.71879  (not concave)
Iteration 39:  log pseudolikelihood = -775.60636  (not concave)
Iteration 40:  log pseudolikelihood = -775.48835  (not concave)
Iteration 41:  log pseudolikelihood = -775.36572  (not concave)
Iteration 42:  log pseudolikelihood = -775.23807  (not concave)
Iteration 43:  log pseudolikelihood = -775.10727  (not concave)
Iteration 44:  log pseudolikelihood = -774.97349  (not concave)
Iteration 45:  log pseudolikelihood = -774.83921  (not concave)
Iteration 46:  log pseudolikelihood = -774.70503  (not concave)
Iteration 47:  log pseudolikelihood = -774.57291  (not concave)
Iteration 48:  log pseudolikelihood = -774.44406  (not concave)
Iteration 49:  log pseudolikelihood = -774.31873  (not concave)
Iteration 50:  log pseudolikelihood = -774.19896  (not concave)
Iteration 51:  log pseudolikelihood = -774.08346  (not concave)
Iteration 52:  log pseudolikelihood = -773.97423  (not concave)
Iteration 53:  log pseudolikelihood = -773.86934  (not concave)
Iteration 54:  log pseudolikelihood =  -773.7701  (not concave)
Iteration 55:  log pseudolikelihood = -773.67451  (not concave)
Iteration 56:  log pseudolikelihood = -773.58315  (not concave)
Iteration 57:  log pseudolikelihood = -773.49413  (not concave)
Iteration 58:  log pseudolikelihood = -773.40758  (not concave)
Iteration 59:  log pseudolikelihood = -773.32194  (not concave)
Iteration 60:  log pseudolikelihood = -773.23766  (not concave)
Iteration 61:  log pseudolikelihood = -773.15403  (not concave)
Iteration 62:  log pseudolikelihood = -773.07258  (not concave)
Iteration 63:  log pseudolikelihood = -772.99332  (not concave)
Iteration 64:  log pseudolikelihood = -772.91798  (not concave)
Iteration 65:  log pseudolikelihood = -772.84623  (not concave)
Iteration 66:  log pseudolikelihood =  -772.7791  (not concave)
Iteration 67:  log pseudolikelihood = -772.71591  (not concave)
Iteration 68:  log pseudolikelihood = -772.65715  (not concave)
Iteration 69:  log pseudolikelihood = -772.60207  (not concave)
Iteration 70:  log pseudolikelihood = -772.55094  (not concave)
Iteration 71:  log pseudolikelihood = -772.50305  (not concave)
Iteration 72:  log pseudolikelihood = -772.45856  (not concave)
Iteration 73:  log pseudolikelihood = -772.41683  (not concave)
Iteration 74:  log pseudolikelihood = -772.37797  (not concave)
Iteration 75:  log pseudolikelihood = -772.34138  (not concave)
Iteration 76:  log pseudolikelihood = -772.30714  (not concave)
Iteration 77:  log pseudolikelihood = -772.27473  (not concave)
Iteration 78:  log pseudolikelihood = -772.24417  (not concave)
Iteration 79:  log pseudolikelihood = -772.21503  (not concave)
Iteration 80:  log pseudolikelihood = -772.18733  (not concave)
Iteration 81:  log pseudolikelihood =  -772.1607  (not concave)
Iteration 82:  log pseudolikelihood = -772.13514  (not concave)
Iteration 83:  log pseudolikelihood = -772.11036  (not concave)
Iteration 84:  log pseudolikelihood = -772.08637  (not concave)
Iteration 85:  log pseudolikelihood = -772.06293  (not concave)
Iteration 86:  log pseudolikelihood = -772.04006  (not concave)
Iteration 87:  log pseudolikelihood = -772.01756  (not concave)
Iteration 88:  log pseudolikelihood = -771.99548  (not concave)
Iteration 89:  log pseudolikelihood = -771.97363  (not concave)
Iteration 90:  log pseudolikelihood =  -771.9521  (not concave)
Iteration 91:  log pseudolikelihood =  -771.9307  (not concave)
Iteration 92:  log pseudolikelihood = -771.90956  (not concave)
Iteration 93:  log pseudolikelihood = -771.88855  (not concave)
Iteration 94:  log pseudolikelihood = -771.86785  (not concave)
Iteration 95:  log pseudolikelihood = -771.84749  (not concave)
Iteration 96:  log pseudolikelihood = -771.82776  (not concave)
Iteration 97:  log pseudolikelihood =  -771.8085  (not concave)
Iteration 98:  log pseudolikelihood = -771.78968  (not concave)
Iteration 99:  log pseudolikelihood = -771.77111  (not concave)
Iteration 100: log pseudolikelihood = -771.75282  (not concave)
Iteration 101: log pseudolikelihood = -771.73472  (not concave)
Iteration 102: log pseudolikelihood = -771.71687  (not concave)
Iteration 103: log pseudolikelihood = -771.71512  (not concave)
Iteration 104: log pseudolikelihood = -771.69537  (not concave)
Iteration 105: log pseudolikelihood = -771.68393  (not concave)
Iteration 106: log pseudolikelihood = -771.66476  (not concave)
Iteration 107: log pseudolikelihood = -771.64722  (not concave)
Iteration 108: log pseudolikelihood = -771.64368  (not concave)
Iteration 109: log pseudolikelihood = -771.64184  (not concave)
Iteration 110: log pseudolikelihood = -771.64078  (not concave)
Iteration 111: log pseudolikelihood =  -771.6401  (not concave)
Iteration 112: log pseudolikelihood = -771.63976  (not concave)
Iteration 113: log pseudolikelihood = -771.63641  (not concave)
Iteration 114: log pseudolikelihood = -771.63641  (not concave)
Iteration 115: log pseudolikelihood = -771.63641  (not concave)
Iteration 116: log pseudolikelihood = -771.63641  (not concave)
Iteration 117: log pseudolikelihood = -771.63641  (not concave)
Iteration 118: log pseudolikelihood = -771.63641  (not concave)
Iteration 119: log pseudolikelihood = -771.63641  (not concave)
Iteration 120: log pseudolikelihood = -771.63641  (not concave)
convergence not achieved

2 component Negative Binomial-2 regression        Number of obs   =        659
                                                  Wald chi2(23)   =          .
Log pseudolikelihood = -771.63641                 Prob > chi2     =          .

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
          SO |    .786909   .1580699     4.98   0.000     .4770976     1.09672
           I |  -.0063495   .0526086    -0.12   0.904    -.1094604    .0967614
         SKI |   .3895712    .255352     1.53   0.127    -.1109095    .8900519
         FC3 |   .7828721   .4721001     1.66   0.097    -.1424272    1.708171
          C1 |   .0735316   .1604521     0.46   0.647    -.2409488    .3880119
          C3 |  -.1232798   .0583072    -2.11   0.034    -.2375598   -.0089997
          C4 |   .0485691   .1988938     0.24   0.807    -.3412556    .4383938
        C1sq |    -.00537   .0166719    -0.32   0.747    -.0380463    .0273064
        C3sq |   -.000856   .0008718    -0.98   0.326    -.0025647    .0008527
        C4sq |  -.0001763   .0038796    -0.05   0.964    -.0077803    .0074276
        C1C3 |   .0060281   .0189599     0.32   0.751    -.0311327    .0431889
        C1C4 |   .0038351   .0143795     0.27   0.790    -.0243482    .0320185
        C3C4 |  -.0034684   .0212139    -0.16   0.870    -.0450469    .0381102
       _cons |  -1.846232   .3894935    -4.74   0.000    -2.609626   -1.082839
-------------+----------------------------------------------------------------
component2   |
          SO |   .1448624   1.021254     0.14   0.887    -1.856758    2.146483
           I |   -.309624          .        .       .            .           .
         SKI |   .6939544          .        .       .            .           .
         FC3 |  -.1964491   .9614425    -0.20   0.838    -2.080842    1.687944
          C1 |   .1055798          .        .       .            .           .
          C3 |  -.1564606   .0462175    -3.39   0.001    -.2470453    -.065876
          C4 |   .0578239   .0722821     0.80   0.424    -.0838463    .1994942
        C1sq |  -.0053296   .1462352    -0.04   0.971    -.2919453    .2812861
        C3sq |  -.0008106   .0204489    -0.04   0.968    -.0408897    .0392685
        C4sq |  -.0002298   .0054603    -0.04   0.966    -.0109319    .0104723
        C1C3 |   .0060468   .1731465     0.03   0.972    -.3333141    .3454077
        C1C4 |   .0038264   .1175322     0.03   0.974    -.2265324    .2341852
        C3C4 |  -.0035058   .1295272    -0.03   0.978    -.2573745    .2503628
       _cons |   2.228115          .        .       .            .           .
-------------+----------------------------------------------------------------
 /imlogitpi1 |   3.218809   .8579006     3.75   0.000     1.537355    4.900263
   /lnalpha1 |  -.3614631   .3058778    -1.18   0.237    -.9609726    .2380463
   /lnalpha2 |  -25.82672   6.244484    -4.14   0.000    -38.06568   -13.58776
------------------------------------------------------------------------------
Warning: convergence not achieved
      alpha1 |   .6966563   .2130917                      .3825207    1.268768
      alpha2 |   6.08e-12   3.79e-11                      2.94e-17    1.26e-06
         pi1 |    .961536   .0317291                      .8230798    .9926104
         pi2 |    .038464   .0317291                      .0073896    .1769202
------------------------------------------------------------------------------

. estimates store FMNB2interact

. 
. *** TABLE 6.12: FINITE MIXTURES MODELS
. 
. estimates table FMP2 FMNB2 FMNB1, b(%10.3f) t(%10.2f) eq(1) stats(ll aic bic N k)

-----------------------------------------------------
    Variable |    FMP2        FMNB2        FMNB1     
-------------+---------------------------------------
#1           |
          SO |      0.655        0.890        0.925  
             |      14.97        19.90        14.76  
         SKI |      0.438        0.449       -0.426  
             |       2.45         2.50        -1.80  
           I |     -0.010       -0.049        0.073  
             |      -0.20        -1.02         0.61  
         FC3 |      1.542        1.070       -0.631  
             |       8.04         2.97        -2.76  
          C1 |     -0.044       -0.000       -0.027  
             |      -2.40        -0.01        -1.53  
          C3 |     -0.029       -0.050        0.003  
             |      -2.85        -5.24         0.43  
          C4 |      0.070        0.047        0.025  
             |       5.03         3.11         1.57  
       _cons |     -1.766       -1.877       -2.634  
             |      -6.19        -9.13        -5.37  
-------------+---------------------------------------
component2   |
          SO |      0.086       -0.095        0.511  
             |       0.63        -0.43        12.20  
         SKI |      0.631        1.369        0.746  
             |       3.43         3.55         4.96  
           I |      0.003       -0.033       -0.054  
             |       0.02        -0.23        -1.24  
         FC3 |     -0.687       -0.129        0.305  
             |      -1.90        -0.43         1.27  
          C1 |      0.074        0.186        0.060  
             |       3.36         7.50         5.40  
          C3 |     -0.073       -0.253       -0.096  
             |      -5.66        -9.52        -9.41  
          C4 |     -0.014        0.049        0.030  
             |      -0.83         3.42         4.01  
       _cons |      2.479        1.006       -0.287  
             |       2.23         1.04        -1.10  
-------------+---------------------------------------
imlogitpi1   |
       _cons |      2.298        1.952       -0.748  
             |      10.78         3.77        -2.92  
-------------+---------------------------------------
lnalpha1     |
       _cons |                  -0.192               
             |                   -1.45               
-------------+---------------------------------------
lnalpha2     |
       _cons |                  -1.647               
             |                   -3.09               
-------------+---------------------------------------
lndelta1     |
       _cons |                              -13.692  
             |                                -7.70  
-------------+---------------------------------------
lndelta2     |
       _cons |                                1.742  
             |                                 6.96  
-------------+---------------------------------------
Statistics   |                                       
          ll |   -938.660     -786.010     -794.582  
         aic |   1911.320     1610.020     1627.164  
         bic |   1987.662     1695.344     1712.488  
           N |        659          659          659  
           k |     17.000       19.000       19.000  
-----------------------------------------------------
                                          legend: b/t

. 
. *** HURDLE AND ZERO-INFLATED MODELS (Table 6.13)
. 
. generate DTRIPS = TRIPS > 0

. 
. * Problem: TRIPS are necessarily > 0 if FC3 = 1
. tabulate FC3 DTRIPS

  Equals 1 |
 if user's |
  fee paid |
   at Lake |        DTRIPS
Somerville |         0          1 |     Total
-----------+----------------------+----------
         0 |       417        229 |       646 
         1 |         0         13 |        13 
-----------+----------------------+----------
     Total |       417        242 |       659 


. 
. global XLIST SO SKI I FC3 C1 C3 C4 

. global XLISTSHORT SO SKI I C1 C3 C4 

. 
. * Hurdle first component: NB2 - recode a to exp(a)
. * Has problems after about 20 iterations
. 
. program lfNB2binary
  1.   version 10.1
  2.   args lnf theta1 a               
  3.   tempvar mu p expa
  4.   local y "$ML_y1"                 
  5.   generate double `mu'      = exp(`theta1')
  6.   generate double `expa'    = exp(`a')
  7.   generate double `p'       = 1 - (1/(1+`expa'*`mu'))^(1/`expa') 
  8.   quietly replace `lnf'     = `y'*ln(`p') + ln(1-`p') - `y'*ln(1-`p')
  9. end

. 
. * This includes SKI which is not identified
. ml model lf lfNB2binary (DTRIPS = $XLIST) (), vce(robust)

. ml maximize, iter(20)

initial:       log pseudolikelihood = -456.78399
alternative:   log pseudolikelihood = -435.07645
rescale:       log pseudolikelihood = -435.07645
rescale eq:    log pseudolikelihood = -433.27603
Iteration 0:   log pseudolikelihood = -433.27603  (not concave)
Iteration 1:   log pseudolikelihood = -224.31498  
Iteration 2:   log pseudolikelihood = -185.89869  
Iteration 3:   log pseudolikelihood = -173.65472  (not concave)
Iteration 4:   log pseudolikelihood = -173.17159  
Iteration 5:   log pseudolikelihood = -171.79856  
Iteration 6:   log pseudolikelihood = -152.84317  (not concave)
Iteration 7:   log pseudolikelihood = -150.74778  
Iteration 8:   log pseudolikelihood = -146.87911  
Iteration 9:   log pseudolikelihood = -140.21812  (not concave)
Iteration 10:  log pseudolikelihood = -138.75854  
Iteration 11:  log pseudolikelihood = -138.17864  
Iteration 12:  log pseudolikelihood = -131.91503  
Iteration 13:  log pseudolikelihood =   -130.147  
Iteration 14:  log pseudolikelihood = -128.72613  
Iteration 15:  log pseudolikelihood = -127.96385  (not concave)
Iteration 16:  log pseudolikelihood = -127.88657  
Iteration 17:  log pseudolikelihood = -127.59187  
Iteration 18:  log pseudolikelihood = -127.33461  
Iteration 19:  log pseudolikelihood = -127.32984  (backed up)
Iteration 20:  log pseudolikelihood = -127.32976  (backed up)
convergence not achieved

                                                  Number of obs   =        659
                                                  Wald chi2(7)    =     193.24
Log pseudolikelihood = -127.32976                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
      DTRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
eq1          |
          SO |     20.626   2.305418     8.95   0.000     16.10746    25.14453
         SKI |   4.422545   2.308856     1.92   0.055    -.1027287    8.947819
           I |  -.0816789   .3973798    -0.21   0.837    -.8605291    .6971712
         FC3 |    244.905   41.10006     5.96   0.000     164.3503    325.4596
          C1 |   .2726978    .294918     0.92   0.355    -.3053308    .8507265
          C3 |  -.5110286   .2299707    -2.22   0.026    -.9617628   -.0602944
          C4 |   .2259611    .184293     1.23   0.220    -.1352465    .5871687
       _cons |  -5.025266   2.820849    -1.78   0.075    -10.55403    .5034959
-------------+----------------------------------------------------------------
eq2          |
       _cons |    3.51824   .1317104    26.71   0.000     3.260092    3.776387
------------------------------------------------------------------------------
Warning: convergence not achieved

. 
. * This drops SKI which is not identified
. ml model lf lfNB2binary (DTRIPS = $XLISTSHORT) (), vce(robust)

. ml maximize, iter(12)

initial:       log pseudolikelihood = -456.78399
alternative:   log pseudolikelihood = -435.07645
rescale:       log pseudolikelihood = -435.07645
rescale eq:    log pseudolikelihood = -433.27603
Iteration 0:   log pseudolikelihood = -433.27603  (not concave)
Iteration 1:   log pseudolikelihood = -225.67756  (not concave)
Iteration 2:   log pseudolikelihood = -212.45596  
Iteration 3:   log pseudolikelihood = -170.00965  (not concave)
Iteration 4:   log pseudolikelihood = -168.55899  
Iteration 5:   log pseudolikelihood = -162.21633  
Iteration 6:   log pseudolikelihood = -148.75943  
Iteration 7:   log pseudolikelihood = -141.98322  
Iteration 8:   log pseudolikelihood = -137.10163  
Iteration 9:   log pseudolikelihood = -131.10183  (not concave)
Iteration 10:  log pseudolikelihood = -130.74531  
Iteration 11:  log pseudolikelihood = -130.70568  
Iteration 12:  log pseudolikelihood = -129.80954  
convergence not achieved

                                                  Number of obs   =        659
                                                  Wald chi2(6)    =       6.16
Log pseudolikelihood = -129.80954                 Prob > chi2     =     0.4051

------------------------------------------------------------------------------
             |               Robust
      DTRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
eq1          |
          SO |   18.13441   15.56548     1.17   0.244    -12.37337     48.6422
         SKI |   3.832226    4.18135     0.92   0.359    -4.363069    12.02752
           I |  -.0677034   .4117861    -0.16   0.869    -.8747894    .7393825
          C1 |   .2626725   .3704435     0.71   0.478    -.4633833    .9887283
          C3 |  -.4913213   .3819919    -1.29   0.198    -1.240012     .257369
          C4 |   .2159826   .1904966     1.13   0.257    -.1573838    .5893491
       _cons |  -4.613904   2.926218    -1.58   0.115    -10.34919    1.121379
-------------+----------------------------------------------------------------
eq2          |
       _cons |   3.339855   .8754861     3.81   0.000     1.623934    5.055776
------------------------------------------------------------------------------
Warning: convergence not achieved

. estimates store H1NB2

. scalar llH1NB2 = e(ll)

. scalar kH1NB2 = e(k)

. 
. * Get the predicted probability of a zero 
. * This code only works for this example
. matrix bhurd = e(b)

. scalar bSO = bhurd[1,1]

. scalar bSKI = bhurd[1,2]

. scalar bI = bhurd[1,3]

. scalar bC1 = bhurd[1,4]

. scalar bC3 = bhurd[1,5]

. scalar bC4 = bhurd[1,6]

. scalar bcons = bhurd[1,7]

. * Recall that reparameterized as exp(alpha) not alpha
. scalar alpha1 = ln(bhurd[1,e(k)])

. di "alpha for first part of hurdle NB2 = " alpha1
alpha for first part of hurdle NB2 = 1.2059274

. generate xbhurd = bSO*SO + bSKI*SKI + bI*I + bC1*C1 + bC3*C3 + bC4*C4 + bcons

. generate f10 = (1 + alpha1*exp(xbhurd))^(-1/alpha1)

. 
. * Check by compare to logit predicted probability
. quietly logit DTRIPS $XLISTSHORT

. predict plogit
(option pr assumed; Pr(DTRIPS))

. generate f10logit = 1 - plogit

. correlate f10 f10logit
(obs=659)

             |      f10 f10logit
-------------+------------------
         f10 |   1.0000
    f10logit |   0.8945   1.0000


. * scatter f10 f10logit
. 
. * Hurdle second component: NB2
. ztnb TRIPS $XLIST if TRIPS>0, dispersion(mean) vce(robust)

Fitting Zero-truncated poisson model:

Iteration 0:   log pseudolikelihood =  -1017.652  
Iteration 1:   log pseudolikelihood = -1014.8441  
Iteration 2:   log pseudolikelihood = -1014.8355  
Iteration 3:   log pseudolikelihood = -1014.8355  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -662.19114  
Iteration 1:   log pseudolikelihood = -635.45582  
Iteration 2:   log pseudolikelihood = -631.90906  
Iteration 3:   log pseudolikelihood = -631.01142  
Iteration 4:   log pseudolikelihood = -630.91687  
Iteration 5:   log pseudolikelihood = -630.91359  
Iteration 6:   log pseudolikelihood = -630.91357  

Fitting full model:

Iteration 0:   log pseudolikelihood = -610.44577  
Iteration 1:   log pseudolikelihood = -602.75223  
Iteration 2:   log pseudolikelihood = -599.46049  
Iteration 3:   log pseudolikelihood = -591.63316  
Iteration 4:   log pseudolikelihood = -591.56343  
Iteration 5:   log pseudolikelihood = -591.56316  
Iteration 6:   log pseudolikelihood = -591.56316  

Zero-truncated negative binomial regression       Number of obs   =        242
Dispersion     = mean                             Wald chi2(7)    =     103.55
Log likelihood = -591.56316                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          SO |   .1716984   .0718771     2.39   0.017     .0308219    .3125749
         SKI |   .6223606   .1851015     3.36   0.001     .2595684    .9851529
           I |  -.0570864   .0588069    -0.97   0.332    -.1723457    .0581729
         FC3 |   .5763336   .2464433     2.34   0.019     .0933135    1.059354
          C1 |   .0570692   .0249603     2.29   0.022     .0081479    .1059905
          C3 |  -.0775205   .0131743    -5.88   0.000    -.1033417   -.0516994
          C4 |   .0123727   .0157709     0.78   0.433    -.0185377    .0432832
       _cons |   .8419364   .3668235     2.30   0.022     .1229757    1.560897
-------------+----------------------------------------------------------------
    /lnalpha |    .530299   .2768831                     -.0123819     1.07298
-------------+----------------------------------------------------------------
       alpha |    1.69944   .4705463                      .9876945     2.92408
------------------------------------------------------------------------------

. estimates store H2NB2

. scalar llH2NB2 = e(ll)

. scalar kH2NB2 = e(k)

. 
. * Get the predicted probability of a zero in the second part of model
. predict mu2, n

. scalar alpha2 = e(alpha)

. generate f20 = (1 + alpha2*mu2)^(-1/alpha2)

. 
. * Combine to get fitted mean
. generate muhurdle = mu2*(1-f10)/(1-f20)

. * or using binary logit
. generate muhurdlelogit = mu2*(1-f10logit)/(1-f20)

. 
. * Combine to get fitted probabilities
. * Not done. Need to code predictions from ztnb as predict after ztnb
. * does not have option pr( ). THen multiply these by (1-f10)/(1-f20)
. 
. * ZIP with only an interept for the zeros
. zip TRIPS $XLIST, inflate($XLIST) vce(robust)

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -2280.2755  
Iteration 1:   log pseudolikelihood =  -1631.497  
Iteration 2:   log pseudolikelihood = -1474.0656  
Iteration 3:   log pseudolikelihood = -1468.9929  
Iteration 4:   log pseudolikelihood = -1468.7085  
Iteration 5:   log pseudolikelihood = -1468.6493  
Iteration 6:   log pseudolikelihood = -1468.6359  
Iteration 7:   log pseudolikelihood = -1468.6331  
Iteration 8:   log pseudolikelihood = -1468.6326  
Iteration 9:   log pseudolikelihood = -1468.6326  
Iteration 10:  log pseudolikelihood = -1468.6326  

Fitting full model:

Iteration 0:   log pseudolikelihood = -1468.6326  
Iteration 1:   log pseudolikelihood = -1273.7416  
Iteration 2:   log pseudolikelihood = -1164.1206  
Iteration 3:   log pseudolikelihood = -1163.4193  
Iteration 4:   log pseudolikelihood = -1163.4191  
Iteration 5:   log pseudolikelihood = -1163.4191  

Zero-inflated Poisson regression                  Number of obs   =        659
                                                  Nonzero obs     =        242
                                                  Zero obs        =        417

Inflation model      = logit                      Wald chi2(7)    =      75.75
Log pseudolikelihood = -1163.419                  Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
TRIPS        |
          SO |   .0396788   .0834161     0.48   0.634    -.1238138    .2031715
         SKI |   .4691185   .1763189     2.66   0.008     .1235398    .8146972
           I |  -.0943536   .0477011    -1.98   0.048    -.1878461   -.0008612
         FC3 |   .6050712   .2358399     2.57   0.010     .1428335    1.067309
          C1 |   .0023539   .0144217     0.16   0.870    -.0259121    .0306199
          C3 |  -.0364429   .0108506    -3.36   0.001    -.0577096   -.0151762
          C4 |   .0235891   .0081585     2.89   0.004     .0075987    .0395795
       _cons |   2.113707   .5032877     4.20   0.000     1.127281    3.100133
-------------+----------------------------------------------------------------
inflate      |
          SO |  -1.651993   .2076671    -7.96   0.000    -2.059013   -1.244973
         SKI |   .0588168   .4614636     0.13   0.899    -.8456352    .9632688
           I |  -.0719113   .1110972    -0.65   0.517    -.2896579    .1458352
         FC3 |  -20.59898   .6327039   -32.56   0.000    -21.83905    -19.3589
          C1 |  -.0058103   .0244693    -0.24   0.812    -.0537693    .0421486
          C3 |   .0723226   .0208863     3.46   0.001     .0313861     .113259
          C4 |  -.0753998   .0251974    -2.99   0.003    -.1247858   -.0260137
       _cons |   3.558284    .532032     6.69   0.000      2.51552    4.601047
------------------------------------------------------------------------------

. estimates store ZIPint

. 
. * ZIP
. zip TRIPS $XLIST, inflate($XLIST) vce(robust)

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -2280.2755  
Iteration 1:   log pseudolikelihood =  -1631.497  
Iteration 2:   log pseudolikelihood = -1474.0656  
Iteration 3:   log pseudolikelihood = -1468.9929  
Iteration 4:   log pseudolikelihood = -1468.7085  
Iteration 5:   log pseudolikelihood = -1468.6493  
Iteration 6:   log pseudolikelihood = -1468.6359  
Iteration 7:   log pseudolikelihood = -1468.6331  
Iteration 8:   log pseudolikelihood = -1468.6326  
Iteration 9:   log pseudolikelihood = -1468.6326  
Iteration 10:  log pseudolikelihood = -1468.6326  

Fitting full model:

Iteration 0:   log pseudolikelihood = -1468.6326  
Iteration 1:   log pseudolikelihood = -1273.7416  
Iteration 2:   log pseudolikelihood = -1164.1206  
Iteration 3:   log pseudolikelihood = -1163.4193  
Iteration 4:   log pseudolikelihood = -1163.4191  
Iteration 5:   log pseudolikelihood = -1163.4191  

Zero-inflated Poisson regression                  Number of obs   =        659
                                                  Nonzero obs     =        242
                                                  Zero obs        =        417

Inflation model      = logit                      Wald chi2(7)    =      75.75
Log pseudolikelihood = -1163.419                  Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
TRIPS        |
          SO |   .0396788   .0834161     0.48   0.634    -.1238138    .2031715
         SKI |   .4691185   .1763189     2.66   0.008     .1235398    .8146972
           I |  -.0943536   .0477011    -1.98   0.048    -.1878461   -.0008612
         FC3 |   .6050712   .2358399     2.57   0.010     .1428335    1.067309
          C1 |   .0023539   .0144217     0.16   0.870    -.0259121    .0306199
          C3 |  -.0364429   .0108506    -3.36   0.001    -.0577096   -.0151762
          C4 |   .0235891   .0081585     2.89   0.004     .0075987    .0395795
       _cons |   2.113707   .5032877     4.20   0.000     1.127281    3.100133
-------------+----------------------------------------------------------------
inflate      |
          SO |  -1.651993   .2076671    -7.96   0.000    -2.059013   -1.244973
         SKI |   .0588168   .4614636     0.13   0.899    -.8456352    .9632688
           I |  -.0719113   .1110972    -0.65   0.517    -.2896579    .1458352
         FC3 |  -20.59898   .6327039   -32.56   0.000    -21.83905    -19.3589
          C1 |  -.0058103   .0244693    -0.24   0.812    -.0537693    .0421486
          C3 |   .0723226   .0208863     3.46   0.001     .0313861     .113259
          C4 |  -.0753998   .0251974    -2.99   0.003    -.1247858   -.0260137
       _cons |   3.558284    .532032     6.69   0.000      2.51552    4.601047
------------------------------------------------------------------------------

. estimates store ZIP

. 
. * ZINB with only an interept for the zeros
. zinb TRIPS $XLIST, inflate(_cons) vce(robust)

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -1174.5746  
Iteration 1:   log pseudolikelihood = -1160.9705  
Iteration 2:   log pseudolikelihood = -1077.3398  (not concave)
Iteration 3:   log pseudolikelihood =  -1068.049  
Iteration 4:   log pseudolikelihood = -1066.7146  
Iteration 5:   log pseudolikelihood =  -1065.335  
Iteration 6:   log pseudolikelihood = -1065.1735  
Iteration 7:   log pseudolikelihood = -1064.9077  
Iteration 8:   log pseudolikelihood = -1064.8298  
Iteration 9:   log pseudolikelihood = -1064.7656  
Iteration 10:  log pseudolikelihood = -1064.7235  
Iteration 11:  log pseudolikelihood = -1064.7226  
Iteration 12:  log pseudolikelihood = -1064.7225  
Iteration 13:  log pseudolikelihood = -1064.7225  

Fitting full model:

Iteration 0:   log pseudolikelihood = -1064.7225  (not concave)
Iteration 1:   log pseudolikelihood = -966.48963  
Iteration 2:   log pseudolikelihood = -837.49649  
Iteration 3:   log pseudolikelihood = -825.85671  
Iteration 4:   log pseudolikelihood = -825.55776  
Iteration 5:   log pseudolikelihood = -825.55758  
Iteration 6:   log pseudolikelihood = -825.55758  

Zero-inflated negative binomial regression        Number of obs   =        659
                                                  Nonzero obs     =        242
                                                  Zero obs        =        417

Inflation model      = logit                      Wald chi2(7)    =     445.58
Log pseudolikelihood = -825.5576                  Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
TRIPS        |
          SO |    .721999   .0583691    12.37   0.000     .6075977    .8364004
         SKI |   .6121388   .2003177     3.06   0.002     .2195233    1.004754
           I |  -.0260588   .0548466    -0.48   0.635    -.1335561    .0814384
         FC3 |   .6691677   .3205802     2.09   0.037      .040842    1.297493
          C1 |   .0480086   .0283108     1.70   0.090    -.0074795    .1034968
          C3 |   -.092691    .014518    -6.38   0.000    -.1211458   -.0642362
          C4 |   .0388357   .0177502     2.19   0.029      .004046    .0736254
       _cons |  -1.121936   .2964056    -3.79   0.000    -1.702881   -.5409919
-------------+----------------------------------------------------------------
inflate      |
       _cons |  -39.01491   .2093301  -186.38   0.000    -39.42519   -38.60463
-------------+----------------------------------------------------------------
    /lnalpha |   .3157293   .1350229     2.34   0.019     .0510893    .5803693
-------------+----------------------------------------------------------------
       alpha |   1.371259   .1851514                      1.052417    1.786698
------------------------------------------------------------------------------

. estimates store ZINBint

. 
. * ZINB
. zinb TRIPS $XLIST, inflate($XLIST) vce(robust)

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -1174.5746  (not concave)
Iteration 1:   log pseudolikelihood = -896.55816  
Iteration 2:   log pseudolikelihood = -821.43104  
Iteration 3:   log pseudolikelihood =   -801.058  
Iteration 4:   log pseudolikelihood = -787.22109  
Iteration 5:   log pseudolikelihood = -785.05939  
Iteration 6:   log pseudolikelihood =   -784.778  
Iteration 7:   log pseudolikelihood = -784.76497  
Iteration 8:   log pseudolikelihood = -784.76482  
Iteration 9:   log pseudolikelihood = -784.76478  
Iteration 10:  log pseudolikelihood = -784.76478  

Fitting full model:

Iteration 0:   log pseudolikelihood = -784.76478  
Iteration 1:   log pseudolikelihood = -730.80649  
Iteration 2:   log pseudolikelihood = -722.75848  (not concave)
Iteration 3:   log pseudolikelihood = -722.57622  
Iteration 4:   log pseudolikelihood = -722.41048  
Iteration 5:   log pseudolikelihood = -719.92151  
Iteration 6:   log pseudolikelihood = -719.48716  
Iteration 7:   log pseudolikelihood = -719.39618  
Iteration 8:   log pseudolikelihood = -719.37474  
Iteration 9:   log pseudolikelihood = -719.37052  
Iteration 10:  log pseudolikelihood = -719.36961  
Iteration 11:  log pseudolikelihood =  -719.3694  
Iteration 12:  log pseudolikelihood = -719.36935  
Iteration 13:  log pseudolikelihood = -719.36934  

Zero-inflated negative binomial regression        Number of obs   =        659
                                                  Nonzero obs     =        242
                                                  Zero obs        =        417

Inflation model      = logit                      Wald chi2(7)    =     140.80
Log pseudolikelihood = -719.3693                  Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
       TRIPS |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
TRIPS        |
          SO |    .170791   .0566653     3.01   0.003      .059729     .281853
         SKI |    .492453   .1459854     3.37   0.001     .2063268    .7785792
           I |  -.0688226   .0414572    -1.66   0.097    -.1500773    .0124321
         FC3 |    .547295   .2205721     2.48   0.013     .1149817    .9796083
          C1 |   .0399582   .0184614     2.16   0.030     .0037745    .0761418
          C3 |  -.0658707   .0104456    -6.31   0.000    -.0863437   -.0453977
          C4 |   .0207245   .0113653     1.82   0.068    -.0015512    .0430001
       _cons |   1.091936   .2919291     3.74   0.000     .5197651    1.664106
-------------+----------------------------------------------------------------
inflate      |
          SO |  -38.63617   2.002578   -19.29   0.000    -42.56115   -34.71119
         SKI |  -16.06663   1.083902   -14.82   0.000    -18.19104   -13.94222
           I |  -.2029069   .3395567    -0.60   0.550    -.8684258     .462612
         FC3 |  -11.42997   2.420961    -4.72   0.000    -16.17496   -6.684971
          C1 |   -.023586   .0152638    -1.55   0.122    -.0535026    .0063305
          C3 |   .0775286   .0214598     3.61   0.000     .0354681    .1195891
          C4 |  -.0628993   .0214707    -2.93   0.003    -.1049811   -.0208175
       _cons |   20.97537   2.850511     7.36   0.000     15.38847    26.56227
-------------+----------------------------------------------------------------
    /lnalpha |  -.1832683   .1150975    -1.59   0.111    -.4088553    .0423186
-------------+----------------------------------------------------------------
       alpha |   .8325447   .0958238                      .6644104    1.043227
------------------------------------------------------------------------------

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |    659   -784.7648   -719.3693     17     1472.739    1549.081
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. estimates store ZINB

. quietly zinb TRIPS $XLIST, inflate($XLIST) vuong

. display "Vuong statistic: " e(vuong)
Vuong statistic: 8.6194315

. foreach y of numlist 0/5 8 11 14 17 62 {
  2.    predict pzinb`y', pr(`y')
  3.    predict cumzinb`y', pr(0,`y')
  4.    }

. replace pzinb8 = cumzinb8 - cumzinb5
(659 real changes made)

. replace pzinb11 = cumzinb11 - cumzinb8
(659 real changes made)

. replace pzinb14 = cumzinb14 - cumzinb11
(659 real changes made)

. replace pzinb17 = cumzinb17 - cumzinb14
(659 real changes made)

. replace pzinb62 = cumzinb62 - cumzinb17
(634 real changes made)

. predict muZINB
(option n assumed; predicted number of events)

. summarize muZINB, detail

                 Predicted number of events
-------------------------------------------------------------
      Percentiles      Smallest
 1%     2.86e-10       6.69e-13
 5%     5.44e-10       1.13e-10
10%     7.40e-10       2.08e-10       Obs                 659
25%     1.54e-09       2.32e-10       Sum of Wgt.         659

50%     .0333058                      Mean           2.724989
                        Largest       Std. Dev.      14.22079
75%     3.165464        20.7974
90%     6.526104       28.08683       Variance       202.2309
95%     10.06582       28.60975       Skewness       22.94258
99%     18.91398       353.8577       Kurtosis       565.8138

. 
. *** TABLE 6.13: HURDLE and ZINB 
. 
. estimates table H1NB2 H2NB2 ZINB , b(%10.3f) t(%10.2f) eq(1) stats(ll aic bic N k)

-----------------------------------------------------
    Variable |   H1NB2        H2NB2         ZINB     
-------------+---------------------------------------
#1           |
          SO |     18.134        0.172        0.171  
             |       1.17         2.39         3.01  
         SKI |      3.832        0.622        0.492  
             |       0.92         3.36         3.37  
           I |     -0.068       -0.057       -0.069  
             |      -0.16        -0.97        -1.66  
          C1 |      0.263        0.057        0.040  
             |       0.71         2.29         2.16  
          C3 |     -0.491       -0.078       -0.066  
             |      -1.29        -5.88        -6.31  
          C4 |      0.216        0.012        0.021  
             |       1.13         0.78         1.82  
         FC3 |                   0.576        0.547  
             |                    2.34         2.48  
       _cons |     -4.614        0.842        1.092  
             |      -1.58         2.30         3.74  
-------------+---------------------------------------
eq2          |
       _cons |      3.340                            
             |       3.81                            
-------------+---------------------------------------
lnalpha      |
       _cons |                   0.530       -0.183  
             |                    1.92        -1.59  
-------------+---------------------------------------
inflate      |
          SO |                              -38.636  
             |                               -19.29  
         SKI |                              -16.067  
             |                               -14.82  
           I |                               -0.203  
             |                                -0.60  
         FC3 |                              -11.430  
             |                                -4.72  
          C1 |                               -0.024  
             |                                -1.55  
          C3 |                                0.078  
             |                                 3.61  
          C4 |                               -0.063  
             |                                -2.93  
       _cons |                               20.975  
             |                                 7.36  
-------------+---------------------------------------
Statistics   |                                       
          ll |   -129.810     -591.563     -719.369  
         aic |    275.619     1201.126     1472.739  
         bic |    311.545     1232.527     1549.081  
           N |        659          242          659  
           k |      8.000        9.000       17.000  
-----------------------------------------------------
                                          legend: b/t

. 
. summarize muhurdle muhurdlelogit muZINB

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
    muhurdle |       659    3.769482     24.7447          0   594.8442
muhurdlelo~t |       659    3.145244    23.44168   .0001906   594.8148
      muZINB |       659    2.724989    14.22079   6.69e-13   353.8577

. 
. *** TABLE 6.14 (Part 2): PREDICTED PROBABILITIES FROM ZERO-INFLATED NB2
. 
. * This program does not compute predicted probabilities for hurdle NB2
. sum pzinb*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      pzinb0 |       659    .6564488    .3977694   .0010773          1
      pzinb1 |       659    .0719351    .0917837   6.33e-13   .2636209
      pzinb2 |       659    .0535687    .0644303   1.69e-14   .1589722
      pzinb3 |       659     .040301     .047849   4.36e-16   .1141585
      pzinb4 |       659    .0308389    .0371937   1.11e-17   .0891283
-------------+--------------------------------------------------------
      pzinb5 |       659     .024008    .0298886   2.79e-19   .0731233
      pzinb8 |       659    .0465845    .0624331          0    .162215
     pzinb11 |       659    .0256087    .0393284          0   .1159534
     pzinb14 |       659    .0152644    .0267292          0   .0902659
     pzinb17 |       659    .0096573    .0191613          0   .0739125
-------------+--------------------------------------------------------
     pzinb62 |       659     .023506    .0676858          0   .4622448

. sum cumzinb*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
    cumzinb0 |       659    .6564488    .3977694   .0010773          1
    cumzinb1 |       659    .7283839    .3334541   .0023669          1
    cumzinb2 |       659    .7819526    .2871336   .0037815          1
    cumzinb3 |       659    .8222536    .2516807   .0052857          1
    cumzinb4 |       659    .8530925    .2233906   .0068602          1
-------------+--------------------------------------------------------
    cumzinb5 |       659    .8771005    .2001971   .0084926          1
    cumzinb8 |       659     .923685    .1504095   .0136589          1
   cumzinb11 |       659    .9492936    .1185557   .0191292          1
   cumzinb14 |       659     .964558    .0968503   .0248233          1
   cumzinb17 |       659    .9742154    .0814114    .030691          1
-------------+--------------------------------------------------------
   cumzinb62 |       659    .9977213    .0346661   .1267748          1

. 
. ********** CLOSE OUTPUT
. 
. * log close
. * clear
. * exit
. 
end of do-file

. exit, clear
