-------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  c:\acdbookrevision\webpage_finalize\racd06p1.txt
  log type:  text
 opened on:   6 Jun 2013, 15:43:08

. 
. ********** OVERVIEW OF racd06p1.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
. 
. * Chapter 6.3 only
. *   6.3 NMES DOCTOR VISITS 
. 
. * To run you need file
. *   racd06data1healthcare.dta
. * and user-written Stata addon
. *   fmm
. * in your directory
. 
. ********** SETUP **********
. 
. set more off

. version 11.2

. clear all

. set mem 10m

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

. 
. ********** DATA DESCRIPTION
. 
. * The data are extracted from the 1987-88 National Medical Expenditure Survey (NMES).
. * The extract and analysis are in P. Deb and P.K. Trivedi (1997),
. * Demand for Medical Care by the Elderly: A Finite Mixture Approach" 
. * Journal of Applied Econometrics, 12, 313-326.
. 
. * See this article for more detailed discussion 
. * Also see racd06makedata1healthcare.do for further details 
. 
. ********** RESULTS HERE DIFFER IN SOME PLACES FROM THE BOOK
. 
. * This Stata program reanalyzes the data given in the published paper by
. * Deb and Trivedi (1997). Their results used quite different code written 
. * in a program other than Stata, and there is some difference in results.
. 
. * Tables 6.1 and 6.2 generated here are the same as Deb and Trivedi (1997).
. * For Tables 6.3 - 6.5 generatedhere there are differences for some of the
. * many models estimated. The book reports the tables in the published article.
. * For Tables 6.6 - 6.8 the diferences are small and the book reports
. * the Stata output given below.
. 
. * Using the results obtained below Table 6.4 in the book becomes
. 
. *   TABLE 6.4 RE-COMPUTED USING CODE WRITTEN IN STATA
. 
. *   NB1 or NB2     Model     k     lnL     AIC    BIC     T_GOF
. *   -------------------------------------------------------------
. *   NB1            NB        18  -12156   24348   24463    Not
. *   NB1            NBH       36  -12126   24325   24554  computed
. *   NB1            CFMNB-2   21  -12098   24238   24372    Not 
. *   NB1            FMNB-2    37  -12092   24259   24495  computed
. *   NB1            CFMNB-3   24  -12096   24239   24392    Not
. *   NB1            FMNB-3    56  -12050   24210   24562  computed
. *   -------------------------------------------------------------
. *   NB2            NB        18  -12202   24440   24555    Not
. *   NB2            NBH       36  -12108   24289   24519  computed
. *   NB2            CFMNB-2   21  -12149   24340   24474    Not 
. *   NB2            FMNB-2    37  -12139   24352   24589  computed
. *   NB2            CFMNB-3   24  -12144   24336   24490    Not
. *   NB2            FMNB-3    56  -12080   24272   24630  computed
. *   -------------------------------------------------------------
. 
. ********** 6.3.1 NMES DOCTOR VISITS DATA: READ DATA AND SUMMARIZE 
. 
. use racd06data1healthcare.dta, clear

. 
. *** TABLE 6.1: OFP Frequency distribution
. generate OFPfreqs = OFP

. replace OFPfreqs = 13 if OFPfreqs >= 13
(427 real changes made)

. tabulate OFPfreqs

   OFPfreqs |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        683       15.50       15.50
          1 |        481       10.92       26.42
          2 |        428        9.71       36.13
          3 |        420        9.53       45.67
          4 |        383        8.69       54.36
          5 |        338        7.67       62.03
          6 |        268        6.08       68.11
          7 |        217        4.93       73.04
          8 |        188        4.27       77.30
          9 |        171        3.88       81.18
         10 |        128        2.91       84.09
         11 |        115        2.61       86.70
         12 |         86        1.95       88.65
         13 |        500       11.35      100.00
------------+-----------------------------------
      Total |      4,406      100.00

. 
. *** TABLE 6.2: Variable descriptions and summary statistics
. describe

Contains data from racd06data1healthcare.dta
  obs:         4,406                          
 vars:            23                          7 Jun 2011 10:39
 size:       405,352                          
-------------------------------------------------------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------------------------------------------------------
OFP             float  %9.0g                  Number of physician office visits
OFNP            float  %9.0g                  Number of non-physician office visits
OPP             float  %9.0g                  Number of physician outpatient visits
OPNP            float  %9.0g                  Number of non-physician outpatient visits
EMR             float  %9.0g                  Number of emergency room visits
HOSP            float  %9.0g                  Number hospitalizations
EXCLHLTH        float  %9.0g                  Equals 1 if self perceived health is excellent
POORHLTH        float  %9.0g                  Equals 1 if self perceived health is poor
NUMCHRON        float  %9.0g                  Number of chronic conditions
ADLDIFF         float  %9.0g                  Equals 1 if the person has a condition that limits activities of daily living
NOREAST         float  %9.0g                  Equals 1 if the person lives in northeastern U.S.
MIDWEST         float  %9.0g                  Equals 1 if the person lives in the midwestern U.S.
WEST            float  %9.0g                  Equals 1 if the person lives in the western U.S.
AGE             float  %9.0g                  Age in years (divided by 10)
BLACK           float  %9.0g                  Equals 1 if the person is African American
MALE            float  %9.0g                  Equals 1 if the person is male
MARRIED         float  %9.0g                  Equals 1 if the person is married
SCHOOL          float  %9.0g                  Number of years of education
FAMINC          float  %9.0g                  Family income in $10,000
EMPLOYED        float  %9.0g                  Equals 1 if the person is employed
PRIVINS         float  %9.0g                  Equals 1 if the person is covered by private health insurance
MEDICAID        float  %9.0g                  Equals 1 if the person is covered by Medicaid
OFPfreqs        float  %9.0g                  
-------------------------------------------------------------------------------------------------------------------------------
Sorted by:  
     Note:  dataset has changed since last saved

. summarize

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         OFP |      4406    5.774399    6.759225          0         89
        OFNP |      4406    1.618021    5.317056          0        104
         OPP |      4406    .7507944    3.652759          0        141
        OPNP |      4406    .5360872    3.879506          0        155
         EMR |      4406    .2635043    .7036586          0         12
-------------+--------------------------------------------------------
        HOSP |      4406    .2959601    .7463978          0          8
    EXCLHLTH |      4406    .0778484    .2679633          0          1
    POORHLTH |      4406    .1257376    .3315911          0          1
    NUMCHRON |      4406    1.541988    1.349632          0          8
     ADLDIFF |      4406    .2040399    .4030441          0          1
-------------+--------------------------------------------------------
     NOREAST |      4406    .1899682    .3923203          0          1
     MIDWEST |      4406    .2625965    .4400949          0          1
        WEST |      4406    .1811167    .3851585          0          1
         AGE |      4406    7.402406    .6334051        6.6       10.9
       BLACK |      4406     .117113    .3215914          0          1
-------------+--------------------------------------------------------
        MALE |      4406    .4035406    .4906631          0          1
     MARRIED |      4406    .5460735    .4979292          0          1
      SCHOOL |      4406    10.29029    3.738736          0         18
      FAMINC |      4406    2.527132    2.924648    -1.0125    54.8351
    EMPLOYED |      4406    .1032683    .3043435          0          1
-------------+--------------------------------------------------------
     PRIVINS |      4406    .7764412    .4166769          0          1
    MEDICAID |      4406    .0912392    .2879817          0          1
    OFPfreqs |      4406    5.008171    4.256362          0         13

. 
. tabulate OFP

  Number of |
  physician |
     office |
     visits |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        683       15.50       15.50
          1 |        481       10.92       26.42
          2 |        428        9.71       36.13
          3 |        420        9.53       45.67
          4 |        383        8.69       54.36
          5 |        338        7.67       62.03
          6 |        268        6.08       68.11
          7 |        217        4.93       73.04
          8 |        188        4.27       77.30
          9 |        171        3.88       81.18
         10 |        128        2.91       84.09
         11 |        115        2.61       86.70
         12 |         86        1.95       88.65
         13 |         73        1.66       90.31
         14 |         76        1.72       92.03
         15 |         53        1.20       93.24
         16 |         47        1.07       94.30
         17 |         48        1.09       95.39
         18 |         30        0.68       96.07
         19 |         24        0.54       96.62
         20 |         16        0.36       96.98
         21 |         18        0.41       97.39
         22 |         16        0.36       97.75
         23 |         10        0.23       97.98
         24 |         12        0.27       98.25
         25 |          3        0.07       98.32
         26 |          9        0.20       98.52
         27 |          7        0.16       98.68
         28 |          4        0.09       98.77
         29 |          3        0.07       98.84
         30 |          4        0.09       98.93
         31 |          4        0.09       99.02
         32 |          1        0.02       99.05
         33 |          1        0.02       99.07
         34 |          2        0.05       99.11
         35 |          1        0.02       99.14
         36 |          1        0.02       99.16
         37 |          3        0.07       99.23
         38 |          2        0.05       99.27
         39 |          5        0.11       99.39
         40 |          2        0.05       99.43
         41 |          1        0.02       99.46
         42 |          4        0.09       99.55
         43 |          2        0.05       99.59
         44 |          1        0.02       99.61
         47 |          1        0.02       99.64
         48 |          1        0.02       99.66
         49 |          1        0.02       99.68
         50 |          1        0.02       99.70
         51 |          1        0.02       99.73
         53 |          2        0.05       99.77
         55 |          1        0.02       99.80
         56 |          1        0.02       99.82
         58 |          2        0.05       99.86
         61 |          1        0.02       99.89
         63 |          1        0.02       99.91
         65 |          1        0.02       99.93
         66 |          1        0.02       99.95
         68 |          1        0.02       99.98
         89 |          1        0.02      100.00
------------+-----------------------------------
      Total |      4,406      100.00

. * OFP histogram
. * histogram OFP if OFP < 45, discrete fraction scale(1.2)
. 
. * Global for the regressors
. global XLIST EXCLHLTH POORHLTH NUMCHRON ADLDIFF NOREAST MIDWEST WEST AGE ///
>   BLACK MALE MARRIED SCHOOL FAMINC EMPLOYED PRIVINS MEDICAID

. 
. *********** 6.3.4 MODEL SELECTION AND COMPARISON (NB, Hurdle, FM) for Tables 6.3-6.5
. 
. * Poisson
. poisson OFP $XLIST, vce(robust) 

Iteration 0:   log pseudolikelihood = -18134.655  
Iteration 1:   log pseudolikelihood = -18134.567  
Iteration 2:   log pseudolikelihood = -18134.567  

Poisson regression                                Number of obs   =       4406
                                                  Wald chi2(16)   =     570.03
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -18134.567                 Pseudo R2       =     0.0868

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    EXCLHLTH |  -.3862208   .0786163    -4.91   0.000     -.540306   -.2321356
    POORHLTH |   .2873922   .0576105     4.99   0.000     .1744776    .4003068
    NUMCHRON |   .1639607   .0122684    13.36   0.000      .139915    .1880064
     ADLDIFF |   .0934088    .051097     1.83   0.068    -.0067395    .1935571
     NOREAST |   .1075677   .0492905     2.18   0.029       .01096    .2041754
     MIDWEST |  -.0105486   .0447331    -0.24   0.814    -.0982239    .0771267
        WEST |   .1238461   .0475824     2.60   0.009     .0305862     .217106
         AGE |  -.0552906   .0289719    -1.91   0.056    -.1120745    .0014933
       BLACK |  -.0655474   .0637323    -1.03   0.304    -.1904604    .0593656
        MALE |  -.0713668   .0379348    -1.88   0.060    -.1457176     .002984
     MARRIED |  -.0407636    .038426    -1.06   0.289    -.1160772    .0345499
      SCHOOL |   .0258206   .0055887     4.62   0.000     .0148668    .0367743
      FAMINC |  -.0023524   .0057808    -0.41   0.684    -.0136825    .0089776
    EMPLOYED |   .0527792   .0750458     0.70   0.482    -.0943078    .1998663
     PRIVINS |    .321541   .0513952     6.26   0.000     .2208082    .4222739
    MEDICAID |   .2886599   .0616569     4.68   0.000     .1678145    .4095052
       _cons |   1.296604   .2334117     5.56   0.000     .8391257    1.754083
------------------------------------------------------------------------------

. estimates store POISSON

. 
. * NB1
. nbreg OFP $XLIST, vce(robust) dispersion(constant) 

Fitting Poisson model:

Iteration 0:   log pseudolikelihood = -18134.655  
Iteration 1:   log pseudolikelihood = -18134.567  
Iteration 2:   log pseudolikelihood = -18134.567  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -14552.718  
Iteration 1:   log pseudolikelihood = -12647.886  
Iteration 2:   log pseudolikelihood = -12493.025  
Iteration 3:   log pseudolikelihood = -12492.829  
Iteration 4:   log pseudolikelihood = -12492.829  

Fitting full model:

Iteration 0:   log pseudolikelihood = -12492.829  
Iteration 1:   log pseudolikelihood = -12301.184  
Iteration 2:   log pseudolikelihood =     -12157  
Iteration 3:   log pseudolikelihood = -12156.203  
Iteration 4:   log pseudolikelihood = -12156.202  

Negative binomial regression                      Number of obs   =       4406
Dispersion           = constant                   Wald chi2(16)   =     694.92
Log pseudolikelihood = -12156.202                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    EXCLHLTH |  -.2679127   .0506053    -5.29   0.000    -.3670973   -.1687281
    POORHLTH |   .1890825   .0460892     4.10   0.000     .0987494    .2794156
    NUMCHRON |   .1774737   .0102697    17.28   0.000     .1573455     .197602
     ADLDIFF |   .0054215   .0392485     0.14   0.890    -.0715041    .0823471
     NOREAST |   .0715408   .0389436     1.84   0.066    -.0047872    .1478688
     MIDWEST |   .0138372   .0339726     0.41   0.684    -.0527478    .0804222
        WEST |   .1049489   .0384155     2.73   0.006     .0296559     .180242
         AGE |  -.0032939   .0233938    -0.14   0.888    -.0491448     .042557
       BLACK |  -.1275746   .0520345    -2.45   0.014    -.2295604   -.0255888
        MALE |  -.1231018   .0295699    -4.16   0.000    -.1810578   -.0651458
     MARRIED |   .0221482   .0308756     0.72   0.473    -.0383668    .0826632
      SCHOOL |   .0212676   .0043099     4.93   0.000     .0128203    .0297149
      FAMINC |   -.000249   .0046019    -0.05   0.957    -.0092685    .0087705
    EMPLOYED |  -.0180486   .0483787    -0.37   0.709     -.112869    .0767719
     PRIVINS |   .3364587   .0436197     7.71   0.000     .2509656    .4219518
    MEDICAID |   .3180563   .0580432     5.48   0.000     .2042938    .4318189
       _cons |    .949961   .1900152     5.00   0.000      .577538    1.322384
-------------+----------------------------------------------------------------
    /lndelta |   1.576208   .0405414                      1.496748    1.655668
-------------+----------------------------------------------------------------
       delta |   4.836581   .1960816                       4.46714    5.236575
------------------------------------------------------------------------------

. estimates store NB1

. scalar llNB1 = e(ll)

. scalar kNB1 = e(k)

. 
. * NB2
. nbreg OFP $XLIST, vce(robust)

Fitting Poisson model:

Iteration 0:   log pseudolikelihood = -18134.655  
Iteration 1:   log pseudolikelihood = -18134.567  
Iteration 2:   log pseudolikelihood = -18134.567  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -12492.848  
Iteration 1:   log pseudolikelihood = -12492.829  
Iteration 2:   log pseudolikelihood = -12492.829  

Fitting full model:

Iteration 0:   log pseudolikelihood =  -12234.27  
Iteration 1:   log pseudolikelihood = -12202.779  
Iteration 2:   log pseudolikelihood = -12202.168  
Iteration 3:   log pseudolikelihood = -12202.168  

Negative binomial regression                      Number of obs   =       4406
Dispersion           = mean                       Wald chi2(16)   =     539.90
Log pseudolikelihood = -12202.168                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    EXCLHLTH |  -.3845558   .0781452    -4.92   0.000    -.5377175   -.2313941
    POORHLTH |   .3226979   .0561814     5.74   0.000     .2125843    .4328115
    NUMCHRON |   .1897393    .013172    14.40   0.000     .1639228    .2155559
     ADLDIFF |   .0967679   .0506209     1.91   0.056    -.0024473    .1959832
     NOREAST |   .1112554   .0505925     2.20   0.028     .0120959    .2104148
     MIDWEST |  -.0011415   .0448927    -0.03   0.980    -.0891295    .0868466
        WEST |   .1368204   .0479385     2.85   0.004     .0428626    .2307782
         AGE |  -.0356419   .0310612    -1.15   0.251    -.0965208     .025237
       BLACK |  -.0661781    .066558    -0.99   0.320    -.1966295    .0642732
        MALE |  -.0750747   .0397817    -1.89   0.059    -.1530453     .002896
     MARRIED |  -.0355702   .0411729    -0.86   0.388    -.1162677    .0451272
      SCHOOL |   .0273927    .005449     5.03   0.000     .0167128    .0380726
      FAMINC |  -.0016692   .0055387    -0.30   0.763    -.0125248    .0091864
    EMPLOYED |   .0255671   .0677192     0.38   0.706      -.10716    .1582943
     PRIVINS |   .3458812   .0547448     6.32   0.000     .2385834    .4531791
    MEDICAID |   .2761624   .0670752     4.12   0.000     .1446975    .4076273
       _cons |   1.059449   .2630634     4.03   0.000     .5438547    1.575044
-------------+----------------------------------------------------------------
    /lnalpha |  -.1674192   .0333357                      -.232756   -.1020824
-------------+----------------------------------------------------------------
       alpha |    .845845   .0281969                      .7923469    .9029552
------------------------------------------------------------------------------

. estimates store NB2

. scalar llNB2 = e(ll)

. scalar kNB2 = e(k)

. 
. ****** HURDLE MODELS - FIRST COMPONENT logit or NB1 or NB2
. 
. generate DOFP = OFP > 0

. 
. * Hurdle first component: logit
. logit DOFP $XLIST, vce(robust)

Iteration 0:   log pseudolikelihood = -1900.3601  
Iteration 1:   log pseudolikelihood =  -1728.708  
Iteration 2:   log pseudolikelihood = -1710.6166  
Iteration 3:   log pseudolikelihood = -1710.5266  
Iteration 4:   log pseudolikelihood = -1710.5266  

Logistic regression                               Number of obs   =       4406
                                                  Wald chi2(16)   =     279.07
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -1710.5266                 Pseudo R2       =     0.0999

------------------------------------------------------------------------------
             |               Robust
        DOFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    EXCLHLTH |   -.328511   .1422489    -2.31   0.021    -.6073137   -.0497083
    POORHLTH |   .0708379   .1687321     0.42   0.675    -.2598709    .4015467
    NUMCHRON |    .556512   .0527686    10.55   0.000     .4530873    .6599366
     ADLDIFF |  -.1881657   .1299432    -1.45   0.148    -.4428498    .0665183
     NOREAST |   .1292212   .1250505     1.03   0.301    -.1158732    .3743157
     MIDWEST |   .1008883   .1146354     0.88   0.379    -.1237929    .3255695
        WEST |   .2016633   .1336443     1.51   0.131    -.0602747    .4636014
         AGE |   .1904976   .0811478     2.35   0.019     .0314509    .3495443
       BLACK |   -.326972   .1334663    -2.45   0.014    -.5885612   -.0653829
        MALE |  -.4644473     .09852    -4.71   0.000    -.6575429   -.2713517
     MARRIED |   .2472641   .1039523     2.38   0.017     .0435213    .4510068
      SCHOOL |   .0542073   .0131949     4.11   0.000     .0283458    .0800688
      FAMINC |   .0067446   .0184979     0.36   0.715    -.0295106    .0429998
    EMPLOYED |  -.0123197    .145099    -0.08   0.932    -.2967086    .2720692
     PRIVINS |   .7624604   .1173052     6.50   0.000     .5325464    .9923745
    MEDICAID |   .5535139   .1812261     3.05   0.002     .1983173    .9087106
       _cons |  -1.475312   .6464112    -2.28   0.022    -2.742254   -.2083689
------------------------------------------------------------------------------

. estimates store H1logit

. scalar llH1logit = e(ll)

. scalar kH1logit = e(k)

. scalar nH = e(N)

. 
. * Hurdle first component: NB1
. program lfNB1binary
  1.   version 10.1
  2.   args lnf theta1 a               // theta1=x'b, a=alpha, lnf=lnf(y)
  3.   tempvar mu p0
  4.   local y $ML_y1                  // Define y so program more readable
  5.   generate double `mu'  = exp(`theta1')
  6.   generate double `p0' = (1/(1+`a'))^(`mu'/`a')
  7.   quietly replace `lnf' = ln(`p0') if $ML_y1 == 0
  8.   quietly replace `lnf' = ln(1-`p0') if $ML_y1 == 1
  9. end

. ml model lf lfNB1binary (DOFP = $XLIST) (), vce(robust)

. ml maximize, nolog
(4406 missing values generated)
initial:       log pseudolikelihood =     -<inf>  (could not be evaluated)
feasible:      log pseudolikelihood =  -2047.454
rescale:       log pseudolikelihood = -1900.5194
rescale eq:    log pseudolikelihood = -1900.5194

                                                  Number of obs   =       4406
                                                  Wald chi2(16)   =     237.97
Log pseudolikelihood = -1723.7526                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
        DOFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
eq1          |
    EXCLHLTH |  -.1735103   .0722673    -2.40   0.016    -.3151516    -.031869
    POORHLTH |   .0204064   .0731079     0.28   0.780    -.1228824    .1636952
    NUMCHRON |    .206869   .0208221     9.94   0.000     .1660584    .2476796
     ADLDIFF |  -.1094521   .0581162    -1.88   0.060    -.2233577    .0044535
     NOREAST |    .061183   .0575746     1.06   0.288    -.0516612    .1740272
     MIDWEST |   .0515839   .0527429     0.98   0.328    -.0517903    .1549582
        WEST |    .117734   .0589905     2.00   0.046     .0021147    .2333534
         AGE |   .0615207   .0366497     1.68   0.093    -.0103113    .1333527
       BLACK |  -.1756703   .0670894    -2.62   0.009    -.3071631   -.0441776
        MALE |  -.2070004   .0451632    -4.58   0.000    -.2955186   -.1184822
     MARRIED |   .0970383    .048013     2.02   0.043     .0029346     .191142
      SCHOOL |   .0229889    .006056     3.80   0.000     .0111193    .0348585
      FAMINC |   .0033474   .0076281     0.44   0.661    -.0116033    .0182982
    EMPLOYED |  -.0316314   .0672774    -0.47   0.638    -.1634927    .1002299
     PRIVINS |   .3805973   .0583269     6.53   0.000     .2662786     .494916
    MEDICAID |    .277444   .0869749     3.19   0.001     .1069764    .4479116
       _cons |  -.2496048    .294187    -0.85   0.396    -.8262007    .3269912
-------------+----------------------------------------------------------------
eq2          |
       _cons |   1.000444   .0129819    77.06   0.000     .9750004    1.025888
------------------------------------------------------------------------------

. estimates store H1NB1

. scalar llH1NB1 = e(ll)

. scalar kH1NB1 = e(k)

. 
. * Hurdle first component: NB2
. program lfNB2binary
  1.   version 10.1
  2.   args lnf theta1 a               // theta1=x'b, a=alpha, lnf=lnf(y)
  3.   tempvar mu p0
  4.   local y $ML_y1                  // Define y so program more readable
  5.   generate double `mu'  = exp(`theta1')
  6.   generate double `p0' = (1/(1+`a'*`mu'))^(1/`a')
  7.   quietly replace `lnf' = ln(`p0') if $ML_y1 == 0
  8.   quietly replace `lnf' = ln(1-`p0') if $ML_y1 == 1
  9. end

. ml model lf lfNB2binary (DOFP = $XLIST) (), vce(robust)

. ml maximize, nolog
(4406 missing values generated)
initial:       log pseudolikelihood =     -<inf>  (could not be evaluated)
feasible:      log pseudolikelihood = -2151.5981
rescale:       log pseudolikelihood = -2021.8161
rescale eq:    log pseudolikelihood = -1978.5291
(7 missing values generated)
(9 missing values generated)
(13 missing values generated)
(19 missing values generated)
(26 missing values generated)

                                                  Number of obs   =       4406
                                                  Wald chi2(16)   =       9.83
Log pseudolikelihood = -1708.5461                 Prob > chi2     =     0.8756

------------------------------------------------------------------------------
             |               Robust
        DOFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
eq1          |
    EXCLHLTH |   -.628034   .3803345    -1.65   0.099    -1.373476     .117408
    POORHLTH |   .1488019    .344439     0.43   0.666    -.5262862      .82389
    NUMCHRON |   1.164465   .4986804     2.34   0.020     .1870697    2.141861
     ADLDIFF |  -.2973999   .2614204    -1.14   0.255    -.8097745    .2149747
     NOREAST |   .2504665   .2596285     0.96   0.335    -.2583961    .7593291
     MIDWEST |   .1959491   .2410242     0.81   0.416    -.2764497    .6683479
        WEST |   .3734146   .3094784     1.21   0.228    -.2331519    .9799811
         AGE |   .4152715   .2466855     1.68   0.092    -.0682232    .8987662
       BLACK |  -.5815625   .3121817    -1.86   0.062    -1.193427    .0303023
        MALE |  -.8978032   .4011254    -2.24   0.025    -1.683994   -.1116119
     MARRIED |   .5236183   .3242043     1.62   0.106    -.1118105    1.159047
      SCHOOL |   .1078683   .0504125     2.14   0.032     .0090617    .2066749
      FAMINC |   .0130891   .0390349     0.34   0.737    -.0634178     .089596
    EMPLOYED |   .0339144    .290824     0.12   0.907    -.5360901    .6039189
     PRIVINS |   1.410326     .53617     2.63   0.009     .3594523      2.4612
    MEDICAID |   .9886617   .4573735     2.16   0.031     .0922261    1.885097
       _cons |   -2.86773   1.681691    -1.71   0.088    -6.163784    .4283238
-------------+----------------------------------------------------------------
eq2          |
       _cons |   2.452479   1.112621     2.20   0.028     .2717811    4.633177
------------------------------------------------------------------------------

. estimates store H1NB2

. scalar llH1NB2 = e(ll)

. scalar kH1NB2 = e(k)

. 
. ****** HURDLE MODELS - SECOND COMPONENT NB1 or NB2
. 
. * Hurdle second component: NB1
. ztnb OFP $XLIST if OFP>0, dispersion(constant)  vce(robust)

Fitting Zero-truncated poisson model:

Iteration 0:   log pseudolikelihood = -14579.565  
Iteration 1:   log pseudolikelihood = -14579.287  
Iteration 2:   log pseudolikelihood = -14579.287  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -11831.171  
Iteration 1:   log pseudolikelihood = -10932.093  
Iteration 2:   log pseudolikelihood = -10603.329  
Iteration 3:   log pseudolikelihood = -10589.675  
Iteration 4:   log pseudolikelihood = -10589.642  
Iteration 5:   log pseudolikelihood = -10589.642  
(683 missing values generated)

Fitting full model:

Iteration 0:   log pseudolikelihood = -10589.642  
Iteration 1:   log pseudolikelihood = -10455.669  
Iteration 2:   log pseudolikelihood = -10402.952  
Iteration 3:   log pseudolikelihood = -10402.502  
Iteration 4:   log pseudolikelihood =   -10402.5  
Iteration 5:   log pseudolikelihood =   -10402.5  

Zero-truncated negative binomial regression       Number of obs   =       3723
Dispersion     = constant                         Wald chi2(16)   =     430.42
Log likelihood = -10402.5                         Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    EXCLHLTH |  -.4273102   .0944306    -4.53   0.000    -.6123908   -.2422296
    POORHLTH |   .2708583   .0512404     5.29   0.000      .170429    .3712875
    NUMCHRON |   .1533033   .0121155    12.65   0.000     .1295574    .1770492
     ADLDIFF |   .0812708   .0476659     1.71   0.088    -.0121527    .1746943
     NOREAST |   .0834631   .0506103     1.65   0.099    -.0157312    .1826574
     MIDWEST |  -.0168203   .0450092    -0.37   0.709    -.1050368    .0713961
        WEST |   .0963784   .0499589     1.93   0.054    -.0015392    .1942961
         AGE |  -.0604462   .0297356    -2.03   0.042    -.1187268   -.0021656
       BLACK |  -.0505329   .0657304    -0.77   0.442    -.1793622    .0782963
        MALE |  -.0478359   .0391429    -1.22   0.222    -.1245546    .0288827
     MARRIED |  -.0420995   .0400434    -1.05   0.293    -.1205832    .0363842
      SCHOOL |   .0182904   .0059409     3.08   0.002     .0066464    .0299343
      FAMINC |   -.001976   .0067402    -0.29   0.769    -.0151865    .0112345
    EMPLOYED |  -.0126104   .0708615    -0.18   0.859    -.1514964    .1262756
     PRIVINS |   .2467514   .0571132     4.32   0.000     .1348116    .3586912
    MEDICAID |   .3000174   .0672999     4.46   0.000     .1681121    .4319227
       _cons |   1.524488   .2401803     6.35   0.000     1.053743    1.995233
-------------+----------------------------------------------------------------
    /lndelta |    1.53823   .0547167                      1.430987    1.645473
-------------+----------------------------------------------------------------
       delta |   4.656342   .2547795                      4.182827     5.18346
------------------------------------------------------------------------------

. estimates store H2NB1

. scalar llH2NB1 = e(ll)

. scalar kH2NB1 = e(k)

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

Fitting Zero-truncated poisson model:

Iteration 0:   log pseudolikelihood = -14579.565  
Iteration 1:   log pseudolikelihood = -14579.287  
Iteration 2:   log pseudolikelihood = -14579.287  

Fitting constant-only model:

Iteration 0:   log pseudolikelihood = -10629.691  
Iteration 1:   log pseudolikelihood = -10591.459  
Iteration 2:   log pseudolikelihood = -10589.644  
Iteration 3:   log pseudolikelihood = -10589.642  
Iteration 4:   log pseudolikelihood = -10589.642  

Fitting full model:

Iteration 0:   log pseudolikelihood = -10421.041  
Iteration 1:   log pseudolikelihood = -10400.551  
Iteration 2:   log pseudolikelihood = -10399.965  
Iteration 3:   log pseudolikelihood = -10399.965  

Zero-truncated negative binomial regression       Number of obs   =       3723
Dispersion     = mean                             Wald chi2(16)   =     366.15
Log likelihood = -10399.965                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    EXCLHLTH |  -.3775072     .08729    -4.32   0.000    -.5485924    -.206422
    POORHLTH |    .332509    .056758     5.86   0.000     .2212654    .4437527
    NUMCHRON |   .1429373   .0134919    10.59   0.000     .1164936     .169381
     ADLDIFF |   .1290356   .0516041     2.50   0.012     .0278934    .2301778
     NOREAST |   .1040669   .0527816     1.97   0.049     .0006169    .2075169
     MIDWEST |  -.0163183   .0475077    -0.34   0.731    -.1094317     .076795
        WEST |   .1232471   .0504032     2.45   0.014     .0244586    .2220356
         AGE |  -.0753009   .0322667    -2.33   0.020    -.1385425   -.0120593
       BLACK |   .0016163   .0700154     0.02   0.982    -.1356115     .138844
        MALE |   .0041276   .0421946     0.10   0.922    -.0785722    .0868275
     MARRIED |  -.0920324   .0437363    -2.10   0.035    -.1777539    -.006311
      SCHOOL |   .0216107   .0056617     3.82   0.000     .0105139    .0327074
      FAMINC |  -.0022357   .0058904    -0.38   0.704    -.0137807    .0093093
    EMPLOYED |   .0296558   .0739422     0.40   0.688    -.1152683    .1745798
     PRIVINS |    .227151   .0566744     4.01   0.000     .1160712    .3382307
    MEDICAID |   .1847926   .0664584     2.78   0.005     .0545365    .3150487
       _cons |   1.630983   .2692161     6.06   0.000     1.103329    2.158636
-------------+----------------------------------------------------------------
    /lnalpha |  -.2959886   .0542084                     -.4022352    -.189742
-------------+----------------------------------------------------------------
       alpha |   .7437959     .04032                      .6688234    .8271725
------------------------------------------------------------------------------

. estimates store H2NB2

. scalar llH2NB2 = e(ll)

. scalar kH2NB2 = e(k)

. 
. * Combine two parts: NB1 and NB1
. scalar llHNB1 = llH1NB1 + llH2NB1

. scalar kHNB1 = kH1NB1 + kH2NB1

. scalar AICHNB1 = -2*llHNB1 + 2*kHNB1

. scalar BICHNB1 = -2*llHNB1 + ln(nH)*kHNB1

. 
. * Combine two parts: NB2 and NB2
. scalar llHNB2 = llH1NB2 + llH2NB2

. scalar kHNB2 = kH1NB2 + kH2NB2

. scalar AICHNB2 = -2*llHNB2 + 2*kHNB2

. scalar BICHNB2 = -2*llHNB2 + ln(nH)*kHNB2

. 
. * Combine two parts: logit and NB1
. scalar llHNB1log = llH1logit + llH2NB1

. scalar kHNB1log = kH1logit + kH2NB1

. scalar AICHNB1log = -2*llHNB1log + 2*kHNB1log

. scalar BICHNB1log = -2*llHNB1log + ln(nH)*kHNB1log

. 
. * Combine two parts: logit and NB2
. scalar llHNB2log = llH1logit + llH2NB2

. scalar kHNB2log = kH1logit + kH2NB2

. scalar AICHNB2log = -2*llHNB2log + 2*kHNB2log

. scalar BICHNB2log = -2*llHNB2log + ln(nH)*kHNB2log

. 
. ****** FINITE MIXTURE MODELS - constrained and unconstrained
. 
. **** NB1 Finite Mixtures Models
. 
. * Finite mixtures NB1 - 2 components unconstrained
. fmm OFP $XLIST, components(2) mixtureof(negbin1) vce(robust)

Fitting Negative Binomial-1 model:

Iteration 0:   log likelihood = -18134.655  
Iteration 1:   log likelihood = -18134.567  
Iteration 2:   log likelihood = -18134.567  

Iteration 0:   log likelihood = -14552.718  
Iteration 1:   log likelihood = -12647.886  
Iteration 2:   log likelihood = -12493.025  
Iteration 3:   log likelihood = -12492.829  
Iteration 4:   log likelihood = -12492.829  

Iteration 0:   log likelihood = -12492.829  
Iteration 1:   log likelihood = -12301.184  
Iteration 2:   log likelihood =     -12157  
Iteration 3:   log likelihood = -12156.203  
Iteration 4:   log likelihood = -12156.202  

Fitting 2 component Negative Binomial-1 model:

Iteration 0:   log pseudolikelihood =  -12156.74  (not concave)
Iteration 1:   log pseudolikelihood = -12155.694  (not concave)
Iteration 2:   log pseudolikelihood = -12134.293  (not concave)
Iteration 3:   log pseudolikelihood = -12108.437  (not concave)
Iteration 4:   log pseudolikelihood = -12100.205  
Iteration 5:   log pseudolikelihood = -12095.077  
Iteration 6:   log pseudolikelihood = -12093.661  
Iteration 7:   log pseudolikelihood = -12092.693  
Iteration 8:   log pseudolikelihood =  -12092.43  
Iteration 9:   log pseudolikelihood = -12092.429  
Iteration 10:  log pseudolikelihood = -12092.429  

2 component Negative Binomial-1 regression        Number of obs   =       4406
                                                  Wald chi2(32)   =     805.15
Log pseudolikelihood = -12092.429                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.2290118   .0595272    -3.85   0.000    -.3456829   -.1123407
    POORHLTH |   .1499097    .058625     2.56   0.011     .0350068    .2648126
    NUMCHRON |   .1836232   .0145712    12.60   0.000     .1550641    .2121823
     ADLDIFF |  -.0520085   .0510709    -1.02   0.309    -.1521055    .0480886
     NOREAST |   .0546492   .0542024     1.01   0.313    -.0515856    .1608839
     MIDWEST |   .0191861    .045583     0.42   0.674    -.0701549    .1085271
        WEST |   .0944858    .047379     1.99   0.046     .0016248    .1873469
         AGE |   .0148273   .0308493     0.48   0.631    -.0456361    .0752908
       BLACK |  -.1799111   .0898293    -2.00   0.045    -.3559734   -.0038489
        MALE |  -.1377495   .0363032    -3.79   0.000    -.2089023   -.0665966
     MARRIED |   .0513625    .037287     1.38   0.168    -.0217187    .1244436
      SCHOOL |   .0133302   .0067885     1.96   0.050     .0000249    .0266354
      FAMINC |   .0007834   .0052861     0.15   0.882    -.0095773     .011144
    EMPLOYED |  -.0807253   .0543835    -1.48   0.138    -.1873149    .0258643
     PRIVINS |   .3593702   .0802377     4.48   0.000     .2021073    .5166331
    MEDICAID |   .4204549   .1516158     2.77   0.006     .1232933    .7176165
       _cons |   .7733975   .2661744     2.91   0.004     .2517052     1.29509
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.8178674   .3848952    -2.12   0.034    -1.572248   -.0634866
    POORHLTH |    .718358   .3416314     2.10   0.035     .0487726    1.387943
    NUMCHRON |   .1908478   .0934393     2.04   0.041     .0077101    .3739855
     ADLDIFF |    .549827   .2893593     1.90   0.057    -.0173069    1.116961
     NOREAST |   .2279207   .4032265     0.57   0.572    -.5623887     1.01823
     MIDWEST |  -.0123035   .4114692    -0.03   0.976    -.8187683    .7941612
        WEST |   .2660744   .2891064     0.92   0.357    -.3005636    .8327125
         AGE |  -.1334189    .237275    -0.56   0.574    -.5984694    .3316316
       BLACK |   .2680242   .7090175     0.38   0.705    -1.121625    1.657673
        MALE |  -.0228589   .1936876    -0.12   0.906    -.4024796    .3567618
     MARRIED |   -.242328   .1950364    -1.24   0.214    -.6245924    .1399364
      SCHOOL |   .1023137   .0435288     2.35   0.019     .0169988    .1876287
      FAMINC |  -.0011579   .0128741    -0.09   0.928    -.0263908    .0240749
    EMPLOYED |   .5400458    .441916     1.22   0.222    -.3260937    1.406185
     PRIVINS |    .227208   .6916896     0.33   0.743    -1.128479    1.582895
    MEDICAID |  -.6163631   1.171503    -0.53   0.599    -2.912467    1.679741
       _cons |   1.554799   2.130245     0.73   0.465    -2.620405    5.730003
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.290933   .3660583     6.26   0.000     1.573471    3.008394
   /lndelta1 |   1.259071    .059816    21.05   0.000     1.141834    1.376308
   /lndelta2 |   2.441911   .4394107     5.56   0.000     1.580682     3.30314
------------------------------------------------------------------------------
      delta1 |   3.522148    .210681                      3.132507    3.960255
      delta2 |   11.49499    5.05102                      4.858268    27.19791
         pi1 |   .9081233   .0305422                      .8282779    .9529519
         pi2 |   .0918767   .0305422                      .0470481    .1717221
------------------------------------------------------------------------------

. estimates store FM2NB1

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
      FM2NB1 |   4406           .   -12092.43     37     24258.86    24495.31
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llFM2NB1 = e(ll)

. scalar kFM2NB1 = e(rank)

. 
. * Finite mixtures NB1 - 3 components unconstrained
. * This has convergence problems - stop at exactly 20 iterations
. fmm OFP $XLIST, components(3) mixtureof(negbin1) vce(robust) iter(20)

Fitting 3 component Negative Binomial-1 model:

Iteration 0:   log pseudolikelihood = -12092.432  (not concave)
Iteration 1:   log pseudolikelihood = -12087.407  (not concave)
Iteration 2:   log pseudolikelihood = -12085.612  (not concave)
Iteration 3:   log pseudolikelihood = -12082.804  (not concave)
Iteration 4:   log pseudolikelihood = -12075.188  (not concave)
Iteration 5:   log pseudolikelihood = -12069.149  (not concave)
Iteration 6:   log pseudolikelihood =  -12068.09  (not concave)
Iteration 7:   log pseudolikelihood = -12066.772  (not concave)
Iteration 8:   log pseudolikelihood = -12065.512  (not concave)
Iteration 9:   log pseudolikelihood =  -12060.52  (not concave)
Iteration 10:  log pseudolikelihood = -12058.683  (not concave)
Iteration 11:  log pseudolikelihood = -12058.254  (not concave)
Iteration 12:  log pseudolikelihood = -12056.618  (not concave)
Iteration 13:  log pseudolikelihood = -12055.883  (not concave)
Iteration 14:  log pseudolikelihood = -12054.919  (not concave)
Iteration 15:  log pseudolikelihood = -12054.383  (not concave)
Iteration 16:  log pseudolikelihood = -12054.071  (not concave)
Iteration 17:  log pseudolikelihood = -12053.823  (not concave)
Iteration 18:  log pseudolikelihood = -12053.742  (not concave)
Iteration 19:  log pseudolikelihood = -12053.661  (not concave)
Iteration 20:  log pseudolikelihood = -12050.104  (not concave)
convergence not achieved

3 component Negative Binomial-1 regression        Number of obs   =       4406
                                                  Wald chi2(48)   =    1247.47
Log pseudolikelihood = -12050.104                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.2847297   .0657908    -4.33   0.000    -.4136773   -.1557821
    POORHLTH |   .2644781   .0529759     4.99   0.000     .1606473    .3683089
    NUMCHRON |   .1799031    .014409    12.49   0.000     .1516619    .2081442
     ADLDIFF |    .053308   .0499298     1.07   0.286    -.0445526    .1511686
     NOREAST |   .1245906   .0505973     2.46   0.014     .0254217    .2237595
     MIDWEST |   .0493078   .0439044     1.12   0.261    -.0367432    .1353588
        WEST |      .0729   .0474079     1.54   0.124    -.0200178    .1658179
         AGE |    .011974   .0300999     0.40   0.691    -.0470208    .0709687
       BLACK |  -.0585806   .0654226    -0.90   0.371    -.1868066    .0696455
        MALE |   -.177515   .0380627    -4.66   0.000    -.2521166   -.1029134
     MARRIED |   .0728448   .0397754     1.83   0.067    -.0051135    .1508031
      SCHOOL |   .0151465   .0069541     2.18   0.029     .0015167    .0287764
      FAMINC |  -.0004394   .0057157    -0.08   0.939    -.0116419    .0107632
    EMPLOYED |  -.0286309   .0637433    -0.45   0.653    -.1535655    .0963037
     PRIVINS |   .3459514   .0595861     5.81   0.000     .2291648    .4627381
    MEDICAID |   .4240416   .0713109     5.95   0.000     .2842748    .5638083
       _cons |   .7426774   .2777734     2.67   0.008     .1982515    1.287103
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.9974141   .4282742    -2.33   0.020    -1.836816   -.1580121
    POORHLTH |   .5846596   .2651793     2.20   0.027     .0649177    1.104402
    NUMCHRON |   .1769607   .1041399     1.70   0.089    -.0271496    .3810711
     ADLDIFF |    .448495   .2080451     2.16   0.031     .0407342    .8562558
     NOREAST |   .2245126   .2605289     0.86   0.389    -.2861146    .7351398
     MIDWEST |  -.0505727   .3029227    -0.17   0.867    -.6442902    .5431448
        WEST |   .1484823   .2189396     0.68   0.498    -.2806314     .577596
         AGE |  -.1251731   .1927655    -0.65   0.516    -.5029865    .2526404
       BLACK |   .2637915    .358101     0.74   0.461    -.4380735    .9656565
        MALE |   .0554094    .194355     0.29   0.776    -.3255193    .4363381
     MARRIED |  -.2075961   .1736381    -1.20   0.232    -.5479205    .1327282
      SCHOOL |    .099339   .0401715     2.47   0.013     .0206043    .1780737
      FAMINC |  -.0042642   .0126222    -0.34   0.735    -.0290033    .0204749
    EMPLOYED |    .607846   .2500944     2.43   0.015       .11767    1.098022
     PRIVINS |   .3530138   .4199824     0.84   0.401    -.4701366    1.176164
    MEDICAID |  -.1285387   .3579497    -0.36   0.720    -.8301073    .5730299
       _cons |   1.676785   2.157238     0.78   0.437    -2.551324    5.904895
-------------+----------------------------------------------------------------
component3   |
    EXCLHLTH |   .3723387   .2164584     1.72   0.085     -.051912    .7965894
    POORHLTH |  -2.194719   .5271828    -4.16   0.000    -3.227978    -1.16146
    NUMCHRON |   .3508214   .0777601     4.51   0.000     .1984144    .5032283
     ADLDIFF |  -1.355868   .3826845    -3.54   0.000    -2.105916   -.6058207
     NOREAST |  -.5435457   .2149249    -2.53   0.011    -.9647908   -.1223006
     MIDWEST |  -.2251766   .2171605    -1.04   0.300    -.6508033      .20045
        WEST |   .4840844   .1972072     2.45   0.014     .0975655    .8706033
         AGE |   .0533227   .1025373     0.52   0.603    -.1476466    .2542921
       BLACK |   -3.25453   .7336345    -4.44   0.000    -4.692427   -1.816633
        MALE |   .3658342   .1861978     1.96   0.049     .0008932    .7307752
     MARRIED |  -.4666917   .2716674    -1.72   0.086      -.99915    .0657665
      SCHOOL |   -.004687   .0201037    -0.23   0.816    -.0440896    .0347155
      FAMINC |   .0136748   .0086725     1.58   0.115    -.0033229    .0306725
    EMPLOYED |  -.6308724   .3449775    -1.83   0.067    -1.307016     .045271
     PRIVINS |   .1938224   .1688086     1.15   0.251    -.1370363    .5246811
    MEDICAID |  -2.297179   .6981917    -3.29   0.001     -3.66561   -.9287486
       _cons |    .743128     .76738     0.97   0.333    -.7609092    2.247165
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.216945   .1806036    12.28   0.000     1.862969    2.570922
 /imlogitpi2 |  -.2940686   .4102834    -0.72   0.474    -1.098209    .5100721
   /lndelta1 |   1.233421   .0552554    22.32   0.000     1.125123     1.34172
   /lndelta2 |   2.347295   .3109255     7.55   0.000     1.737892    2.956698
   /lndelta3 |  -29.17698          .        .       .            .           .
------------------------------------------------------------------------------
Warning: convergence not achieved
      delta1 |   3.432954   .1896894                      3.080594    3.825617
      delta2 |   10.45725   3.251425                      5.685348    19.23436
      delta3 |   2.13e-13          .                             .           .
         pi1 |   .8402463    .027901                      .7777619    .8876992
         pi2 |   .0682161   .0248135                      .0329408    .1359559
         pi3 |   .0915376   .0149043                      .0623258    .1207495
------------------------------------------------------------------------------

. estimates store FM3NB1 

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
      FM3NB1 |   4406           .    -12050.1     55     24210.21     24561.7
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llFM3NB1 = e(ll)

. scalar kFM3NB1 = e(rank)

. 
. * Constrained Finite mixtures NB1 - 2 components only intercept varies
. local i 1

. foreach var of varlist $XLIST {
  2.   constraint `i' [component1]`var' = [component2]`var'
  3.   local i = `i' + 1
  4.   }

. fmm OFP $XLIST, components(2) mixtureof(negbin1) constraints(1/`i')

Fitting Negative Binomial-1 model:

Iteration 0:   log likelihood = -18134.655  
Iteration 1:   log likelihood = -18134.567  
Iteration 2:   log likelihood = -18134.567  

Iteration 0:   log likelihood = -14552.718  
Iteration 1:   log likelihood = -12647.886  
Iteration 2:   log likelihood = -12493.025  
Iteration 3:   log likelihood = -12492.829  
Iteration 4:   log likelihood = -12492.829  

Iteration 0:   log likelihood = -12492.829  
Iteration 1:   log likelihood = -12301.184  
Iteration 2:   log likelihood =     -12157  
Iteration 3:   log likelihood = -12156.203  
Iteration 4:   log likelihood = -12156.202  

Fitting 2 component Negative Binomial-1 model:

Iteration 0:   log likelihood =  -12156.74  (not concave)
Iteration 1:   log likelihood =  -12154.44  (not concave)
Iteration 2:   log likelihood = -12133.932  (not concave)
Iteration 3:   log likelihood = -12117.481  
Iteration 4:   log likelihood =  -12101.87  
Iteration 5:   log likelihood = -12098.326  
Iteration 6:   log likelihood = -12097.883  
Iteration 7:   log likelihood = -12097.851  
Iteration 8:   log likelihood =  -12097.85  

2 component Negative Binomial-1 regression        Number of obs   =       4406
                                                  Wald chi2(16)   =     787.57
Log likelihood =  -12097.85                       Prob > chi2     =     0.0000

 ( 1)  [component1]EXCLHLTH - [component2]EXCLHLTH = 0
 ( 2)  [component1]POORHLTH - [component2]POORHLTH = 0
 ( 3)  [component1]NUMCHRON - [component2]NUMCHRON = 0
 ( 4)  [component1]ADLDIFF - [component2]ADLDIFF = 0
 ( 5)  [component1]NOREAST - [component2]NOREAST = 0
 ( 6)  [component1]MIDWEST - [component2]MIDWEST = 0
 ( 7)  [component1]WEST - [component2]WEST = 0
 ( 8)  [component1]AGE - [component2]AGE = 0
 ( 9)  [component1]BLACK - [component2]BLACK = 0
 (10)  [component1]MALE - [component2]MALE = 0
 (11)  [component1]MARRIED - [component2]MARRIED = 0
 (12)  [component1]SCHOOL - [component2]SCHOOL = 0
 (13)  [component1]FAMINC - [component2]FAMINC = 0
 (14)  [component1]EMPLOYED - [component2]EMPLOYED = 0
 (15)  [component1]PRIVINS - [component2]PRIVINS = 0
 (16)  [component1]MEDICAID - [component2]MEDICAID = 0
------------------------------------------------------------------------------
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |   -.281483   .0570791    -4.93   0.000     -.393356     -.16961
    POORHLTH |   .2108138    .041379     5.09   0.000     .1297124    .2919152
    NUMCHRON |   .1804335   .0096188    18.76   0.000      .161581    .1992861
     ADLDIFF |   .0130707   .0364905     0.36   0.720    -.0584493    .0845907
     NOREAST |   .0758954   .0377644     2.01   0.044     .0018786    .1499122
     MIDWEST |   .0104492   .0343951     0.30   0.761    -.0569639    .0778623
        WEST |   .1054022   .0381062     2.77   0.006     .0307154     .180089
         AGE |   .0005364   .0226922     0.02   0.981    -.0439395    .0450123
       BLACK |  -.1273596   .0485914    -2.62   0.009     -.222597   -.0321223
        MALE |  -.1253071   .0296905    -4.22   0.000    -.1834995   -.0671148
     MARRIED |      .0187   .0308608     0.61   0.545    -.0417861    .0791862
      SCHOOL |   .0207761   .0041285     5.03   0.000     .0126843    .0288679
      FAMINC |   .0002684   .0046869     0.06   0.954    -.0089176    .0094545
    EMPLOYED |  -.0347508   .0473112    -0.73   0.463    -.1274789    .0579774
     PRIVINS |   .3281347   .0411701     7.97   0.000     .2474428    .4088265
    MEDICAID |   .3397552   .0534812     6.35   0.000      .234934    .4445764
       _cons |   .8875917   .1834918     4.84   0.000     .5279544    1.247229
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |   -.281483   .0570791    -4.93   0.000     -.393356     -.16961
    POORHLTH |   .2108138    .041379     5.09   0.000     .1297124    .2919152
    NUMCHRON |   .1804335   .0096188    18.76   0.000      .161581    .1992861
     ADLDIFF |   .0130707   .0364905     0.36   0.720    -.0584493    .0845907
     NOREAST |   .0758954   .0377644     2.01   0.044     .0018786    .1499122
     MIDWEST |   .0104492   .0343951     0.30   0.761    -.0569639    .0778623
        WEST |   .1054022   .0381062     2.77   0.006     .0307154     .180089
         AGE |   .0005364   .0226922     0.02   0.981    -.0439395    .0450123
       BLACK |  -.1273596   .0485914    -2.62   0.009     -.222597   -.0321223
        MALE |  -.1253071   .0296905    -4.22   0.000    -.1834995   -.0671148
     MARRIED |      .0187   .0308608     0.61   0.545    -.0417861    .0791862
      SCHOOL |   .0207761   .0041285     5.03   0.000     .0126843    .0288679
      FAMINC |   .0002684   .0046869     0.06   0.954    -.0089176    .0094545
    EMPLOYED |  -.0347508   .0473112    -0.73   0.463    -.1274789    .0579774
     PRIVINS |   .3281347   .0411701     7.97   0.000     .2474428    .4088265
    MEDICAID |   .3397552   .0534812     6.35   0.000      .234934    .4445764
       _cons |   1.071645   .2005703     5.34   0.000     .6785343    1.464756
-------------+----------------------------------------------------------------
 /imlogitpi1 |   1.531575    .307835     4.98   0.000     .9282298    2.134921
   /lndelta1 |   1.075926   .0859428    12.52   0.000     .9074815    1.244371
   /lndelta2 |   2.955879   .2237016    13.21   0.000     2.517432    3.394326
------------------------------------------------------------------------------
      delta1 |   2.932708   .2520452                      2.478074    3.470751
      delta2 |   19.21861   4.299233                      12.39672    29.79456
         pi1 |   .8222367   .0449942                       .716716    .8942513
         pi2 |   .1777633   .0449942                      .1057487     .283284
------------------------------------------------------------------------------

. estimates store CFM2NB1

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
     CFM2NB1 |   4406           .   -12097.85     21      24237.7    24371.91
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llCFM2NB1 = e(ll)

. * e(rank) gives number of parameters (e(k)) minus number of constraints
. scalar kCFM2NB1 = e(rank)

. 
. * Constrained Finite mixtures NB1 - 3 components only intercept varies
. * This needs to directly follow the constrained 2 components case
. * Note the constraints 1=2 are remembered so only need to add constraints that 2=3
. foreach var of varlist $XLIST {
  2.   constraint `i' [component2]`var' = [component3]`var'
  3.   local i = `i' + 1
  4.   }

. * This ultimately converges
. fmm OFP $XLIST, components(3) mixtureof(negbin1) constraints(1/`i') 

Fitting 3 component Negative Binomial-1 model:

Iteration 0:   log likelihood =  -12097.86  (not concave)
Iteration 1:   log likelihood = -12097.854  (not concave)
Iteration 2:   log likelihood = -12097.853  (not concave)
Iteration 3:   log likelihood = -12097.849  (not concave)
Iteration 4:   log likelihood = -12097.849  (not concave)
Iteration 5:   log likelihood = -12097.848  (not concave)
Iteration 6:   log likelihood = -12097.842  (not concave)
Iteration 7:   log likelihood = -12097.836  (not concave)
Iteration 8:   log likelihood = -12097.828  (not concave)
Iteration 9:   log likelihood = -12097.814  (not concave)
Iteration 10:  log likelihood = -12097.798  (not concave)
Iteration 11:  log likelihood = -12097.791  (not concave)
Iteration 12:  log likelihood = -12097.776  (not concave)
Iteration 13:  log likelihood = -12097.769  (not concave)
Iteration 14:  log likelihood = -12097.758  (not concave)
Iteration 15:  log likelihood = -12097.751  (not concave)
Iteration 16:  log likelihood = -12097.748  (not concave)
Iteration 17:  log likelihood = -12097.746  (not concave)
Iteration 18:  log likelihood = -12097.744  (not concave)
Iteration 19:  log likelihood = -12097.742  (not concave)
Iteration 20:  log likelihood = -12097.739  (not concave)
Iteration 21:  log likelihood = -12097.737  (not concave)
Iteration 22:  log likelihood = -12097.735  (not concave)
Iteration 23:  log likelihood = -12097.734  (not concave)
Iteration 24:  log likelihood = -12097.732  (not concave)
Iteration 25:  log likelihood =  -12097.73  (not concave)
Iteration 26:  log likelihood = -12097.729  (not concave)
Iteration 27:  log likelihood = -12097.727  (not concave)
Iteration 28:  log likelihood = -12097.725  (not concave)
Iteration 29:  log likelihood = -12097.724  (not concave)
Iteration 30:  log likelihood = -12097.722  (not concave)
Iteration 31:  log likelihood =  -12097.72  (not concave)
Iteration 32:  log likelihood = -12097.718  (not concave)
Iteration 33:  log likelihood = -12097.714  (not concave)
Iteration 34:  log likelihood = -12097.688  (not concave)
Iteration 35:  log likelihood = -12097.636  (not concave)
Iteration 36:  log likelihood = -12097.615  (not concave)
Iteration 37:  log likelihood = -12097.593  (not concave)
Iteration 38:  log likelihood = -12097.468  
Iteration 39:  log likelihood = -12097.122  
Iteration 40:  log likelihood = -12096.439  
Iteration 41:  log likelihood = -12096.131  
Iteration 42:  log likelihood =  -12095.88  (not concave)
Iteration 43:  log likelihood = -12095.867  
Iteration 44:  log likelihood = -12095.717  (not concave)
Iteration 45:  log likelihood = -12095.659  (not concave)
Iteration 46:  log likelihood = -12095.648  (not concave)
Iteration 47:  log likelihood = -12095.638  (not concave)
Iteration 48:  log likelihood =  -12095.63  
Iteration 49:  log likelihood = -12095.519  
Iteration 50:  log likelihood = -12095.484  
Iteration 51:  log likelihood = -12095.483  

3 component Negative Binomial-1 regression        Number of obs   =       4406
                                                  Wald chi2(16)   =     641.28
Log likelihood = -12095.483                       Prob > chi2     =     0.0000

 ( 1)  [component1]EXCLHLTH - [component2]EXCLHLTH = 0
 ( 2)  [component1]POORHLTH - [component2]POORHLTH = 0
 ( 3)  [component1]NUMCHRON - [component2]NUMCHRON = 0
 ( 4)  [component1]ADLDIFF - [component2]ADLDIFF = 0
 ( 5)  [component1]NOREAST - [component2]NOREAST = 0
 ( 6)  [component1]MIDWEST - [component2]MIDWEST = 0
 ( 7)  [component1]WEST - [component2]WEST = 0
 ( 8)  [component1]AGE - [component2]AGE = 0
 ( 9)  [component1]BLACK - [component2]BLACK = 0
 (10)  [component1]MALE - [component2]MALE = 0
 (11)  [component1]MARRIED - [component2]MARRIED = 0
 (12)  [component1]SCHOOL - [component2]SCHOOL = 0
 (13)  [component1]FAMINC - [component2]FAMINC = 0
 (14)  [component1]EMPLOYED - [component2]EMPLOYED = 0
 (15)  [component1]PRIVINS - [component2]PRIVINS = 0
 (16)  [component1]MEDICAID - [component2]MEDICAID = 0
 (17)  [component2]EXCLHLTH - [component3]EXCLHLTH = 0
 (18)  [component2]POORHLTH - [component3]POORHLTH = 0
 (19)  [component2]NUMCHRON - [component3]NUMCHRON = 0
 (20)  [component2]ADLDIFF - [component3]ADLDIFF = 0
 (21)  [component2]NOREAST - [component3]NOREAST = 0
 (22)  [component2]MIDWEST - [component3]MIDWEST = 0
 (23)  [component2]WEST - [component3]WEST = 0
 (24)  [component2]AGE - [component3]AGE = 0
 (25)  [component2]BLACK - [component3]BLACK = 0
 (26)  [component2]MALE - [component3]MALE = 0
 (27)  [component2]MARRIED - [component3]MARRIED = 0
 (28)  [component2]SCHOOL - [component3]SCHOOL = 0
 (29)  [component2]FAMINC - [component3]FAMINC = 0
 (30)  [component2]EMPLOYED - [component3]EMPLOYED = 0
 (31)  [component2]PRIVINS - [component3]PRIVINS = 0
 (32)  [component2]MEDICAID - [component3]MEDICAID = 0
------------------------------------------------------------------------------
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.2859587   .0584868    -4.89   0.000    -.4005907   -.1713268
    POORHLTH |   .2244097   .0445029     5.04   0.000     .1371855    .3116338
    NUMCHRON |   .1873671   .0102801    18.23   0.000     .1672185    .2075157
     ADLDIFF |    .020037   .0376594     0.53   0.595    -.0537741    .0938481
     NOREAST |   .0826042   .0392089     2.11   0.035     .0057561    .1594523
     MIDWEST |   .0108504   .0352983     0.31   0.759    -.0583331    .0800338
        WEST |   .1035372   .0397691     2.60   0.009     .0255912    .1814832
         AGE |    .001084   .0235608     0.05   0.963    -.0450943    .0472623
       BLACK |  -.1307365   .0502246    -2.60   0.009    -.2291749    -.032298
        MALE |  -.1271959    .030551    -4.16   0.000    -.1870747   -.0673171
     MARRIED |   .0192235   .0319836     0.60   0.548    -.0434633    .0819103
      SCHOOL |   .0222097   .0043064     5.16   0.000     .0137693    .0306501
      FAMINC |  -.0000323   .0048077    -0.01   0.995    -.0094552    .0093907
    EMPLOYED |  -.0292248   .0482797    -0.61   0.545    -.1238513    .0654016
     PRIVINS |   .3366376   .0431284     7.81   0.000     .2521076    .4211677
    MEDICAID |   .3541806   .0565374     6.26   0.000     .2433694    .4649918
       _cons |   .8267899   .1920252     4.31   0.000     .4504275    1.203152
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.2859587   .0584868    -4.89   0.000    -.4005907   -.1713268
    POORHLTH |   .2244097   .0445029     5.04   0.000     .1371855    .3116338
    NUMCHRON |   .1873671   .0102801    18.23   0.000     .1672185    .2075157
     ADLDIFF |    .020037   .0376594     0.53   0.595    -.0537741    .0938481
     NOREAST |   .0826042   .0392089     2.11   0.035     .0057561    .1594523
     MIDWEST |   .0108504   .0352983     0.31   0.759    -.0583331    .0800338
        WEST |   .1035372   .0397691     2.60   0.009     .0255912    .1814832
         AGE |    .001084   .0235608     0.05   0.963    -.0450943    .0472623
       BLACK |  -.1307365   .0502246    -2.60   0.009    -.2291749    -.032298
        MALE |  -.1271959    .030551    -4.16   0.000    -.1870747   -.0673171
     MARRIED |   .0192235   .0319836     0.60   0.548    -.0434633    .0819103
      SCHOOL |   .0222097   .0043064     5.16   0.000     .0137693    .0306501
      FAMINC |  -.0000323   .0048077    -0.01   0.995    -.0094552    .0093907
    EMPLOYED |  -.0292248   .0482797    -0.61   0.545    -.1238513    .0654016
     PRIVINS |   .3366376   .0431284     7.81   0.000     .2521076    .4211677
    MEDICAID |   .3541806   .0565374     6.26   0.000     .2433694    .4649918
       _cons |  -.6062152   1.018715    -0.60   0.552    -2.602861     1.39043
-------------+----------------------------------------------------------------
component3   |
    EXCLHLTH |  -.2859587   .0584868    -4.89   0.000    -.4005907   -.1713268
    POORHLTH |   .2244097   .0445029     5.04   0.000     .1371855    .3116338
    NUMCHRON |   .1873671   .0102801    18.23   0.000     .1672185    .2075157
     ADLDIFF |    .020037   .0376594     0.53   0.595    -.0537741    .0938481
     NOREAST |   .0826042   .0392089     2.11   0.035     .0057561    .1594523
     MIDWEST |   .0108504   .0352983     0.31   0.759    -.0583331    .0800338
        WEST |   .1035372   .0397691     2.60   0.009     .0255912    .1814832
         AGE |    .001084   .0235608     0.05   0.963    -.0450943    .0472623
       BLACK |  -.1307365   .0502246    -2.60   0.009    -.2291749    -.032298
        MALE |  -.1271959    .030551    -4.16   0.000    -.1870747   -.0673171
     MARRIED |   .0192235   .0319836     0.60   0.548    -.0434633    .0819103
      SCHOOL |   .0222097   .0043064     5.16   0.000     .0137693    .0306501
      FAMINC |  -.0000323   .0048077    -0.01   0.995    -.0094552    .0093907
    EMPLOYED |  -.0292248   .0482797    -0.61   0.545    -.1238513    .0654016
     PRIVINS |   .3366376   .0431284     7.81   0.000     .2521076    .4211677
    MEDICAID |   .3541806   .0565374     6.26   0.000     .2433694    .4649918
       _cons |   1.972971   .5695372     3.46   0.001     .8566988    3.089244
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.870311   .9256407     3.10   0.002     1.056088    4.684533
 /imlogitpi2 |   .3373018   1.114322     0.30   0.762     -1.84673    2.521333
   /lndelta1 |   1.138816   .0959347    11.87   0.000      .950787    1.326844
   /lndelta2 |   1.675134   .9262184     1.81   0.071    -.1402202    3.490489
   /lndelta3 |   2.618106   .3613286     7.25   0.000     1.909915    3.326297
------------------------------------------------------------------------------
      delta1 |   3.123067   .2996107                      2.587745     3.76913
      delta2 |   5.339513   4.945555                      .8691668    32.80199
      delta3 |   13.70973   4.953718                      6.752513    27.83507
         pi1 |   .8802034   .0704887                      .6646643    .9645851
         pi2 |   .0699055   .0527626                       .015088    .2694067
         pi3 |   .0498911   .0434282                     -.0352265    .1350087
------------------------------------------------------------------------------

. estimates store CFM3NB1

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
     CFM3NB1 |   4406           .   -12095.48     24     24238.97    24392.34
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llCFM3NB1 = e(ll)

. * e(rank) gives number of parameters (e(k)) minus number of constraints
. scalar kCFM3NB1 = e(rank)

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

Fitting Negative Binomial-2 model:

Iteration 0:   log likelihood = -18134.655  
Iteration 1:   log likelihood = -18134.567  
Iteration 2:   log likelihood = -18134.567  

Iteration 0:   log likelihood = -12492.848  
Iteration 1:   log likelihood = -12492.829  
Iteration 2:   log likelihood = -12492.829  

Iteration 0:   log likelihood =  -12234.27  
Iteration 1:   log likelihood = -12202.779  
Iteration 2:   log likelihood = -12202.168  
Iteration 3:   log likelihood = -12202.168  

Fitting 2 component Negative Binomial-2 model:

Iteration 0:   log pseudolikelihood =  -12202.32  (not concave)
Iteration 1:   log pseudolikelihood = -12198.906  (not concave)
Iteration 2:   log pseudolikelihood = -12159.509  (not concave)
Iteration 3:   log pseudolikelihood = -12150.843  (not concave)
Iteration 4:   log pseudolikelihood = -12146.777  (not concave)
Iteration 5:   log pseudolikelihood = -12145.177  (not concave)
Iteration 6:   log pseudolikelihood = -12144.146  
Iteration 7:   log pseudolikelihood = -12141.278  
Iteration 8:   log pseudolikelihood = -12140.438  
Iteration 9:   log pseudolikelihood = -12139.364  
Iteration 10:  log pseudolikelihood = -12139.312  
Iteration 11:  log pseudolikelihood = -12139.311  

2 component Negative Binomial-2 regression        Number of obs   =       4406
                                                  Wald chi2(32)   =     648.98
Log pseudolikelihood = -12139.311                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.3426896   .1047837    -3.27   0.001     -.548062   -.1373173
    POORHLTH |   .3005766   .0673126     4.47   0.000     .1686463    .4325069
    NUMCHRON |   .1959699   .0282356     6.94   0.000     .1406292    .2513106
     ADLDIFF |   .0244121   .0599872     0.41   0.684    -.0931606    .1419848
     NOREAST |   .0883721   .0646314     1.37   0.172    -.0383031    .2150472
     MIDWEST |  -.0161452   .0549346    -0.29   0.769    -.1238149    .0915246
        WEST |   .1293117   .0633766     2.04   0.041      .005096    .2535275
         AGE |   .0226357   .0451345     0.50   0.616    -.0658264    .1110978
       BLACK |  -.1354242   .1185305    -1.14   0.253    -.3677398    .0968914
        MALE |  -.1414463   .0656796    -2.15   0.031     -.270176   -.0127166
     MARRIED |   .0199709   .0590666     0.34   0.735    -.0957976    .1357394
      SCHOOL |   .0173049   .0113197     1.53   0.126    -.0048813    .0394911
      FAMINC |   .0037294   .0075404     0.49   0.621    -.0110495    .0185082
    EMPLOYED |  -.0954093    .086701    -1.10   0.271    -.2653401    .0745215
     PRIVINS |   .3976839   .1137834     3.50   0.000     .1746726    .6206952
    MEDICAID |   .4758504   .1411235     3.37   0.001     .1992535    .7524474
       _cons |   .6283805   .4994702     1.26   0.208    -.3505631    1.607324
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.4649237   .2834436    -1.64   0.101    -1.020463    .0906155
    POORHLTH |   .3486711   .1597575     2.18   0.029     .0355522      .66179
    NUMCHRON |   .1962416   .0696944     2.82   0.005      .059643    .3328402
     ADLDIFF |   .2066445   .1537203     1.34   0.179    -.0946418    .5079308
     NOREAST |     .19344   .1886035     1.03   0.305    -.1762161    .5630961
     MIDWEST |   .0576896   .1404966     0.41   0.681    -.2176786    .3330578
        WEST |   .1708078   .1433771     1.19   0.234    -.1102061    .4518218
         AGE |   -.169431   .1244261    -1.36   0.173    -.4133016    .0744397
       BLACK |   .0838284   .2329012     0.36   0.719    -.3726496    .5403063
        MALE |   .0744306   .1538221     0.48   0.628    -.2270552    .3759164
     MARRIED |  -.1727413   .1552317    -1.11   0.266    -.4769898    .1315071
      SCHOOL |   .0471951   .0265373     1.78   0.075     -.004817    .0992072
      FAMINC |  -.0120272   .0151732    -0.79   0.428     -.041766    .0177117
    EMPLOYED |    .240546   .1721045     1.40   0.162    -.0967726    .5778646
     PRIVINS |   .2476738   .2061784     1.20   0.230    -.1564283     .651776
    MEDICAID |  -.2692255   .2715047    -0.99   0.321    -.8013649    .2629139
       _cons |   2.022578   1.131613     1.79   0.074    -.1953437    4.240499
-------------+----------------------------------------------------------------
 /imlogitpi1 |   .9963767   .5049348     1.97   0.048     .0067227    1.986031
   /lnalpha1 |  -.7459393   .1657751    -4.50   0.000    -1.070853    -.421026
   /lnalpha2 |   .6905924   .3298288     2.09   0.036     .0441398    1.337045
------------------------------------------------------------------------------
      alpha1 |   .4742886   .0786253                      .3427162     .656373
      alpha2 |   1.994897   .6579744                      1.045128    3.807775
         pi1 |   .7303456   .0994423                      .5016807    .8793226
         pi2 |   .2696544   .0994423                      .1206774    .4983193
------------------------------------------------------------------------------

. estimates store FM2NB2

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
      FM2NB2 |   4406           .   -12139.31     37     24352.62    24589.08
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llFM2NB2 = e(ll)

. scalar kFM2NB2 = e(k)

. 
. * Finite mixtures NB2 - 3 components unconstrained
. * This convergence after about 35 iterations
. fmm OFP $XLIST, components(3) mixtureof(negbin2) vce(robust) iter(30)

Fitting 3 component Negative Binomial-2 model:

Iteration 0:   log pseudolikelihood = -12139.314  (not concave)
Iteration 1:   log pseudolikelihood = -12139.208  (not concave)
Iteration 2:   log pseudolikelihood =  -12139.17  (not concave)
Iteration 3:   log pseudolikelihood = -12132.621  (not concave)
Iteration 4:   log pseudolikelihood = -12127.701  (not concave)
Iteration 5:   log pseudolikelihood = -12123.302  (not concave)
Iteration 6:   log pseudolikelihood = -12121.701  (not concave)
Iteration 7:   log pseudolikelihood =  -12117.97  (not concave)
Iteration 8:   log pseudolikelihood = -12113.651  (not concave)
Iteration 9:   log pseudolikelihood = -12112.276  (not concave)
Iteration 10:  log pseudolikelihood = -12112.082  (not concave)
Iteration 11:  log pseudolikelihood = -12110.774  (not concave)
Iteration 12:  log pseudolikelihood = -12110.488  (not concave)
Iteration 13:  log pseudolikelihood = -12110.295  (not concave)
Iteration 14:  log pseudolikelihood = -12110.099  (not concave)
Iteration 15:  log pseudolikelihood = -12109.161  (not concave)
Iteration 16:  log pseudolikelihood = -12108.691  (not concave)
Iteration 17:  log pseudolikelihood = -12107.687  (not concave)
Iteration 18:  log pseudolikelihood = -12106.202  (not concave)
Iteration 19:  log pseudolikelihood =  -12105.49  (not concave)
Iteration 20:  log pseudolikelihood = -12104.647  (not concave)
Iteration 21:  log pseudolikelihood = -12103.392  (not concave)
Iteration 22:  log pseudolikelihood = -12102.167  (not concave)
Iteration 23:  log pseudolikelihood = -12101.143  
Iteration 24:  log pseudolikelihood = -12100.186  
Iteration 25:  log pseudolikelihood = -12092.703  (not concave)
Iteration 26:  log pseudolikelihood = -12086.945  (not concave)
Iteration 27:  log pseudolikelihood = -12086.223  (not concave)
Iteration 28:  log pseudolikelihood = -12085.366  (not concave)
Iteration 29:  log pseudolikelihood = -12084.429  
Iteration 30:  log pseudolikelihood = -12080.305  
convergence not achieved

3 component Negative Binomial-2 regression        Number of obs   =       4406
                                                  Wald chi2(48)   =     631.10
Log pseudolikelihood = -12080.305                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.3069728   .1201853    -2.55   0.011    -.5425316   -.0714139
    POORHLTH |   .2112318   .1337996     1.58   0.114    -.0510107    .4734743
    NUMCHRON |   .3152104   .0632571     4.98   0.000     .1912287    .4391921
     ADLDIFF |  -.0273817   .1061207    -0.26   0.796    -.2353745    .1806111
     NOREAST |   .0785365   .0956965     0.82   0.412    -.1090252    .2660982
     MIDWEST |   .0238574   .0867542     0.28   0.783    -.1461777    .1938925
        WEST |   .0403989   .0947387     0.43   0.670    -.1452856    .2260834
         AGE |   .0703012   .0662799     1.06   0.289    -.0596051    .2002074
       BLACK |   .0710501   .1477301     0.48   0.631    -.2184956    .3605958
        MALE |  -.2198397   .0862113    -2.55   0.011    -.3888107   -.0508688
     MARRIED |     .12712   .0990002     1.28   0.199    -.0669169     .321157
      SCHOOL |   .0328169   .0144766     2.27   0.023     .0044433    .0611905
      FAMINC |   -.001271   .0132979    -0.10   0.924    -.0273344    .0247924
    EMPLOYED |  -.0439764   .1123906    -0.39   0.696    -.2642579    .1763051
     PRIVINS |   .5692395   .1735835     3.28   0.001     .2290222    .9094569
    MEDICAID |   .7139406   .1979373     3.61   0.000     .3259906    1.101891
       _cons |  -.5777845   .8499702    -0.68   0.497    -2.243695    1.088126
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.4420629   .4146846    -1.07   0.286     -1.25483     .370704
    POORHLTH |   .1122814   .2588186     0.43   0.664    -.3949938    .6195565
    NUMCHRON |   .3232806   .1058804     3.05   0.002     .1157587    .5308024
     ADLDIFF |   .3661313   .1842962     1.99   0.047     .0049174    .7273453
     NOREAST |   .2096477   .2177568     0.96   0.336    -.2171479    .6364432
     MIDWEST |  -.1872171   .1960387    -0.96   0.340    -.5714458    .1970116
        WEST |   .1783576    .200998     0.89   0.375    -.2155913    .5723065
         AGE |  -.4451608   .1650422    -2.70   0.007    -.7686377    -.121684
       BLACK |  -2.834763   .8827678    -3.21   0.001    -4.564956   -1.104569
        MALE |  -.0783003   .2084911    -0.38   0.707    -.4869354    .3303347
     MARRIED |   -.240057    .210552    -1.14   0.254    -.6527313    .1726173
      SCHOOL |   .0665267   .0301083     2.21   0.027     .0075155    .1255378
      FAMINC |   -.003118   .0190446    -0.16   0.870    -.0404446    .0342087
    EMPLOYED |   .3395326   .2187126     1.55   0.121    -.0891362    .7682014
     PRIVINS |   .3006408   .3756528     0.80   0.424    -.4356252    1.036907
    MEDICAID |   -.802673   .4801247    -1.67   0.095      -1.7437     .138354
       _cons |   3.728895   1.692473     2.20   0.028     .4117091    7.046082
-------------+----------------------------------------------------------------
component3   |
    EXCLHLTH |  -.3890602   .1174845    -3.31   0.001    -.6193256   -.1587949
    POORHLTH |   .3818311   .0954857     4.00   0.000     .1946825    .5689797
    NUMCHRON |   .0091595   .0426411     0.21   0.830    -.0744156    .0927347
     ADLDIFF |   .0399851    .080342     0.50   0.619    -.1174822    .1974525
     NOREAST |   .1008982   .0872597     1.16   0.248    -.0701277     .271924
     MIDWEST |    .060597   .0865619     0.70   0.484    -.1090612    .2302552
        WEST |   .2029805   .0866995     2.34   0.019     .0330526    .3729083
         AGE |   .0229968   .0558171     0.41   0.680    -.0864027    .1323963
       BLACK |   .1982031   .1597422     1.24   0.215    -.1148857     .511292
        MALE |    .049132    .083003     0.59   0.554    -.1135508    .2118148
     MARRIED |  -.1204505   .0699406    -1.72   0.085    -.2575315    .0166305
      SCHOOL |    .005898   .0112979     0.52   0.602    -.0162455    .0280415
      FAMINC |    .001406   .0194766     0.07   0.942    -.0367675    .0395795
    EMPLOYED |   -.110756   .1173202    -0.94   0.345    -.3406994    .1191874
     PRIVINS |   .1458273   .0846204     1.72   0.085    -.0200256    .3116802
    MEDICAID |   .1005101   .0912081     1.10   0.270    -.0782544    .2792747
       _cons |   1.719513   .3856617     4.46   0.000     .9636298    2.475396
-------------+----------------------------------------------------------------
 /imlogitpi1 |   .7364091   .4181539     1.76   0.078    -.0831575    1.555976
 /imlogitpi2 |  -.4576738   .5716087    -0.80   0.423    -1.578006    .6626586
   /lnalpha1 |  -.8616757   .3185856    -2.70   0.007    -1.486092   -.2372594
   /lnalpha2 |   .7232871   .2710878     2.67   0.008     .1919648    1.254609
   /lnalpha3 |  -1.402518   .1821059    -7.70   0.000    -1.759439   -1.045597
------------------------------------------------------------------------------
Warning: convergence not achieved
      alpha1 |   .4224536   .1345876                      .2262552    .7887866
      alpha2 |   2.061197   .5587655                      1.211628    3.506468
      alpha3 |   .2459768   .0447938                      .1721414    .3514819
         pi1 |   .5612264   .0718498                      .4192809    .6938133
         pi2 |   .1700413   .0572417                      .0846872    .3120899
         pi3 |   .2687322    .084426                      .1032602    .4342042
------------------------------------------------------------------------------

. estimates store FM3NB2 

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
      FM3NB2 |   4406           .   -12080.31     56     24272.61    24630.49
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llFM3NB2 = e(ll)

. scalar kFM3NB2 = e(k)

. 
. * Constrained Finite mixtures NB2 - 2 components only intercept varies
. local i 1

. foreach var of varlist $XLIST {
  2.   constraint `i' [component1]`var' = [component2]`var'
  3.   local i = `i' + 1
  4.   }

. fmm OFP $XLIST, components(2) mixtureof(negbin2) constraints(1/`i')

Fitting Negative Binomial-2 model:

Iteration 0:   log likelihood = -18134.655  
Iteration 1:   log likelihood = -18134.567  
Iteration 2:   log likelihood = -18134.567  

Iteration 0:   log likelihood = -12492.848  
Iteration 1:   log likelihood = -12492.829  
Iteration 2:   log likelihood = -12492.829  

Iteration 0:   log likelihood =  -12234.27  
Iteration 1:   log likelihood = -12202.779  
Iteration 2:   log likelihood = -12202.168  
Iteration 3:   log likelihood = -12202.168  

Fitting 2 component Negative Binomial-2 model:
(note: constraint number 17 caused error r(303))

Iteration 0:   log likelihood =  -12202.32  (not concave)
Iteration 1:   log likelihood = -12200.226  (not concave)
Iteration 2:   log likelihood = -12161.598  (not concave)
Iteration 3:   log likelihood = -12152.604  
Iteration 4:   log likelihood = -12149.699  
Iteration 5:   log likelihood = -12148.819  
Iteration 6:   log likelihood = -12148.789  
Iteration 7:   log likelihood = -12148.789  

2 component Negative Binomial-2 regression        Number of obs   =       4406
                                                  Wald chi2(16)   =     575.44
Log likelihood = -12148.789                       Prob > chi2     =     0.0000

 ( 1)  [component1]EXCLHLTH - [component2]EXCLHLTH = 0
 ( 2)  [component1]POORHLTH - [component2]POORHLTH = 0
 ( 3)  [component1]NUMCHRON - [component2]NUMCHRON = 0
 ( 4)  [component1]ADLDIFF - [component2]ADLDIFF = 0
 ( 5)  [component1]NOREAST - [component2]NOREAST = 0
 ( 6)  [component1]MIDWEST - [component2]MIDWEST = 0
 ( 7)  [component1]WEST - [component2]WEST = 0
 ( 8)  [component1]AGE - [component2]AGE = 0
 ( 9)  [component1]BLACK - [component2]BLACK = 0
 (10)  [component1]MALE - [component2]MALE = 0
 (11)  [component1]MARRIED - [component2]MARRIED = 0
 (12)  [component1]SCHOOL - [component2]SCHOOL = 0
 (13)  [component1]FAMINC - [component2]FAMINC = 0
 (14)  [component1]EMPLOYED - [component2]EMPLOYED = 0
 (15)  [component1]PRIVINS - [component2]PRIVINS = 0
 (16)  [component1]MEDICAID - [component2]MEDICAID = 0
------------------------------------------------------------------------------
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.3743761   .0623097    -6.01   0.000     -.496501   -.2522513
    POORHLTH |   .3126258   .0496397     6.30   0.000     .2153338    .4099179
    NUMCHRON |   .1935047   .0126581    15.29   0.000     .1686953     .218314
     ADLDIFF |   .0690818   .0428187     1.61   0.107    -.0148413    .1530049
     NOREAST |   .0924278   .0438674     2.11   0.035     .0064493    .1784064
     MIDWEST |  -.0077268   .0402346    -0.19   0.848    -.0865851    .0711314
        WEST |    .133032   .0451132     2.95   0.003     .0446117    .2214522
         AGE |  -.0137971   .0271393    -0.51   0.611    -.0669891    .0393949
       BLACK |  -.0828304    .055285    -1.50   0.134     -.191187    .0255261
        MALE |  -.1033339   .0353879    -2.92   0.003     -.172693   -.0339749
     MARRIED |  -.0156072   .0364331    -0.43   0.668    -.0870147    .0558003
      SCHOOL |   .0243634   .0048534     5.02   0.000     .0148509    .0338759
      FAMINC |   .0002944   .0055077     0.05   0.957    -.0105006    .0110893
    EMPLOYED |  -.0214448   .0546587    -0.39   0.695    -.1285739    .0856842
     PRIVINS |    .352906   .0477607     7.39   0.000     .2592967    .4465153
    MEDICAID |   .3371142   .0643838     5.24   0.000     .2109244    .4633041
       _cons |   .8786717     .22084     3.98   0.000     .4458332     1.31151
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.3743761   .0623097    -6.01   0.000     -.496501   -.2522513
    POORHLTH |   .3126258   .0496397     6.30   0.000     .2153338    .4099179
    NUMCHRON |   .1935047   .0126581    15.29   0.000     .1686953     .218314
     ADLDIFF |   .0690818   .0428187     1.61   0.107    -.0148413    .1530049
     NOREAST |   .0924278   .0438674     2.11   0.035     .0064493    .1784064
     MIDWEST |  -.0077268   .0402346    -0.19   0.848    -.0865851    .0711314
        WEST |    .133032   .0451132     2.95   0.003     .0446117    .2214522
         AGE |  -.0137971   .0271393    -0.51   0.611    -.0669891    .0393949
       BLACK |  -.0828304    .055285    -1.50   0.134     -.191187    .0255261
        MALE |  -.1033339   .0353879    -2.92   0.003     -.172693   -.0339749
     MARRIED |  -.0156072   .0364331    -0.43   0.668    -.0870147    .0558003
      SCHOOL |   .0243634   .0048534     5.02   0.000     .0148509    .0338759
      FAMINC |   .0002944   .0055077     0.05   0.957    -.0105006    .0110893
    EMPLOYED |  -.0214448   .0546587    -0.39   0.695    -.1285739    .0856842
     PRIVINS |    .352906   .0477607     7.39   0.000     .2592967    .4465153
    MEDICAID |   .3371142   .0643838     5.24   0.000     .2109244    .4633041
       _cons |   1.073366   .2241211     4.79   0.000     .6340971    1.512636
-------------+----------------------------------------------------------------
 /imlogitpi1 |    1.19749   .3900064     3.07   0.002     .4330913    1.961888
   /lnalpha1 |  -.7059758   .1243765    -5.68   0.000    -.9497492   -.4622024
   /lnalpha2 |    .869542   .2064089     4.21   0.000     .4649879    1.274096
------------------------------------------------------------------------------
      alpha1 |   .4936267   .0613955                       .386838    .6298948
      alpha2 |   2.385818   .4924541                      1.591995    3.575468
         pi1 |   .7680779   .0694735                      .6066116    .8767371
         pi2 |   .2319221   .0694735                      .1232629    .3933884
------------------------------------------------------------------------------

. estimates store CFM2NB2

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
     CFM2NB2 |   4406           .   -12148.79     21     24339.58    24473.78
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llCFM2NB2 = e(ll)

. * e(rank) gives number of parameters (e(k)) minus number of constraints
. scalar kCFM2NB2 = e(rank)

. 
. * Constrained Finite mixtures NB2 - 3 components only intercept varies
. * This needs to directly follow the constrained 2 components case
. * Note the constraints 1=2 are remembered so only need to add constraints that 2=3
. foreach var of varlist $XLIST {
  2.   constraint `i' [component2]`var' = [component3]`var'
  3.   local i = `i' + 1
  4.   }

. fmm OFP $XLIST, components(3) mixtureof(negbin2) constraints(1/`i')

Fitting 3 component Negative Binomial-2 model:

Iteration 0:   log likelihood = -12148.794  (not concave)
Iteration 1:   log likelihood = -12148.785  (not concave)
Iteration 2:   log likelihood =  -12148.77  (not concave)
Iteration 3:   log likelihood =  -12148.59  (not concave)
Iteration 4:   log likelihood = -12148.443  (not concave)
Iteration 5:   log likelihood = -12148.345  (not concave)
Iteration 6:   log likelihood = -12148.262  (not concave)
Iteration 7:   log likelihood = -12148.176  (not concave)
Iteration 8:   log likelihood = -12148.081  (not concave)
Iteration 9:   log likelihood = -12147.901  (not concave)
Iteration 10:  log likelihood = -12147.264  (not concave)
Iteration 11:  log likelihood = -12146.729  (not concave)
Iteration 12:  log likelihood = -12146.184  (not concave)
Iteration 13:  log likelihood = -12145.584  (not concave)
Iteration 14:  log likelihood =  -12145.31  
Iteration 15:  log likelihood = -12144.985  
Iteration 16:  log likelihood = -12144.439  
Iteration 17:  log likelihood = -12144.342  
Iteration 18:  log likelihood = -12144.335  
Iteration 19:  log likelihood = -12144.333  
Iteration 20:  log likelihood = -12144.333  
Iteration 21:  log likelihood = -12144.333  
Iteration 22:  log likelihood = -12144.333  

3 component Negative Binomial-2 regression        Number of obs   =       4406
                                                  Wald chi2(16)   =     619.00
Log likelihood = -12144.333                       Prob > chi2     =     0.0000

 ( 1)  [component1]EXCLHLTH - [component2]EXCLHLTH = 0
 ( 2)  [component1]POORHLTH - [component2]POORHLTH = 0
 ( 3)  [component1]NUMCHRON - [component2]NUMCHRON = 0
 ( 4)  [component1]ADLDIFF - [component2]ADLDIFF = 0
 ( 5)  [component1]NOREAST - [component2]NOREAST = 0
 ( 6)  [component1]MIDWEST - [component2]MIDWEST = 0
 ( 7)  [component1]WEST - [component2]WEST = 0
 ( 8)  [component1]AGE - [component2]AGE = 0
 ( 9)  [component1]BLACK - [component2]BLACK = 0
 (10)  [component1]MALE - [component2]MALE = 0
 (11)  [component1]MARRIED - [component2]MARRIED = 0
 (12)  [component1]SCHOOL - [component2]SCHOOL = 0
 (13)  [component1]FAMINC - [component2]FAMINC = 0
 (14)  [component1]EMPLOYED - [component2]EMPLOYED = 0
 (15)  [component1]PRIVINS - [component2]PRIVINS = 0
 (16)  [component1]MEDICAID - [component2]MEDICAID = 0
 (17)  [component2]EXCLHLTH - [component3]EXCLHLTH = 0
 (18)  [component2]POORHLTH - [component3]POORHLTH = 0
 (19)  [component2]NUMCHRON - [component3]NUMCHRON = 0
 (20)  [component2]ADLDIFF - [component3]ADLDIFF = 0
 (21)  [component2]NOREAST - [component3]NOREAST = 0
 (22)  [component2]MIDWEST - [component3]MIDWEST = 0
 (23)  [component2]WEST - [component3]WEST = 0
 (24)  [component2]AGE - [component3]AGE = 0
 (25)  [component2]BLACK - [component3]BLACK = 0
 (26)  [component2]MALE - [component3]MALE = 0
 (27)  [component2]MARRIED - [component3]MARRIED = 0
 (28)  [component2]SCHOOL - [component3]SCHOOL = 0
 (29)  [component2]FAMINC - [component3]FAMINC = 0
 (30)  [component2]EMPLOYED - [component3]EMPLOYED = 0
 (31)  [component2]PRIVINS - [component3]PRIVINS = 0
 (32)  [component2]MEDICAID - [component3]MEDICAID = 0
------------------------------------------------------------------------------
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.3738447   .0613775    -6.09   0.000    -.4941425   -.2535469
    POORHLTH |   .3110358   .0505049     6.16   0.000     .2120481    .4100236
    NUMCHRON |   .1998143   .0125221    15.96   0.000     .1752714    .2243571
     ADLDIFF |   .0668725   .0430328     1.55   0.120    -.0174702    .1512153
     NOREAST |   .0950157   .0445374     2.13   0.033      .007724    .1823074
     MIDWEST |  -.0024811   .0395222    -0.06   0.950    -.0799432    .0749809
        WEST |   .1262491   .0446504     2.83   0.005      .038736    .2137623
         AGE |  -.0173924   .0268963    -0.65   0.518    -.0701082    .0353233
       BLACK |  -.0728597    .054605    -1.33   0.182    -.1798835    .0341641
        MALE |  -.1020928   .0352657    -2.89   0.004    -.1712124   -.0329732
     MARRIED |  -.0073032    .036324    -0.20   0.841     -.078497    .0638906
      SCHOOL |   .0258393   .0048672     5.31   0.000     .0162997    .0353788
      FAMINC |  -.0007272   .0055991    -0.13   0.897    -.0117012    .0102469
    EMPLOYED |  -.0145815   .0547655    -0.27   0.790      -.12192     .092757
     PRIVINS |   .3577015    .047715     7.50   0.000     .2641818    .4512212
    MEDICAID |    .346743   .0630647     5.50   0.000     .2231385    .4703475
       _cons |   .8173341   .2178241     3.75   0.000     .3904067    1.244262
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.3738447   .0613775    -6.09   0.000    -.4941425   -.2535469
    POORHLTH |   .3110358   .0505049     6.16   0.000     .2120481    .4100236
    NUMCHRON |   .1998143   .0125221    15.96   0.000     .1752714    .2243571
     ADLDIFF |   .0668725   .0430328     1.55   0.120    -.0174702    .1512153
     NOREAST |   .0950157   .0445374     2.13   0.033      .007724    .1823074
     MIDWEST |  -.0024811   .0395222    -0.06   0.950    -.0799432    .0749809
        WEST |   .1262491   .0446504     2.83   0.005      .038736    .2137623
         AGE |  -.0173924   .0268963    -0.65   0.518    -.0701082    .0353233
       BLACK |  -.0728597    .054605    -1.33   0.182    -.1798835    .0341641
        MALE |  -.1020928   .0352657    -2.89   0.004    -.1712124   -.0329732
     MARRIED |  -.0073032    .036324    -0.20   0.841     -.078497    .0638906
      SCHOOL |   .0258393   .0048672     5.31   0.000     .0162997    .0353788
      FAMINC |  -.0007272   .0055991    -0.13   0.897    -.0117012    .0102469
    EMPLOYED |  -.0145815   .0547655    -0.27   0.790      -.12192     .092757
     PRIVINS |   .3577015    .047715     7.50   0.000     .2641818    .4512212
    MEDICAID |    .346743   .0630647     5.50   0.000     .2231385    .4703475
       _cons |   1.002316   .2223712     4.51   0.000     .5664765    1.438156
-------------+----------------------------------------------------------------
component3   |
    EXCLHLTH |  -.3738447   .0613775    -6.09   0.000    -.4941425   -.2535469
    POORHLTH |   .3110358   .0505049     6.16   0.000     .2120481    .4100236
    NUMCHRON |   .1998143   .0125221    15.96   0.000     .1752714    .2243571
     ADLDIFF |   .0668725   .0430328     1.55   0.120    -.0174702    .1512153
     NOREAST |   .0950157   .0445374     2.13   0.033      .007724    .1823074
     MIDWEST |  -.0024811   .0395222    -0.06   0.950    -.0799432    .0749809
        WEST |   .1262491   .0446504     2.83   0.005      .038736    .2137623
         AGE |  -.0173924   .0268963    -0.65   0.518    -.0701082    .0353233
       BLACK |  -.0728597    .054605    -1.33   0.182    -.1798835    .0341641
        MALE |  -.1020928   .0352657    -2.89   0.004    -.1712124   -.0329732
     MARRIED |  -.0073032    .036324    -0.20   0.841     -.078497    .0638906
      SCHOOL |   .0258393   .0048672     5.31   0.000     .0162997    .0353788
      FAMINC |  -.0007272   .0055991    -0.13   0.897    -.0117012    .0102469
    EMPLOYED |  -.0145815   .0547655    -0.27   0.790      -.12192     .092757
     PRIVINS |   .3577015    .047715     7.50   0.000     .2641818    .4512212
    MEDICAID |    .346743   .0630647     5.50   0.000     .2231385    .4703475
       _cons |    2.03998   .2200978     9.27   0.000     1.608596    2.471363
-------------+----------------------------------------------------------------
 /imlogitpi1 |   3.349516   .3831715     8.74   0.000     2.598514    4.100518
 /imlogitpi2 |   2.121435   .4248021     4.99   0.000     1.288838    2.954031
   /lnalpha1 |   -.875997   .1291408    -6.78   0.000    -1.129108   -.6228857
   /lnalpha2 |   1.028545   .2012039     5.11   0.000     .6341922    1.422897
   /lnalpha3 |  -15.77926   597.1939    -0.03   0.979    -1186.258    1154.699
------------------------------------------------------------------------------
      alpha1 |   .4164466   .0537802                      .3233215    .5363943
      alpha2 |   2.796992   .5627656                      1.885498    4.149122
      alpha3 |   1.40e-07   .0000838                             0           .
         pi1 |   .7530374     .05288                      .6358911    .8418665
         pi2 |     .22053   .0516948                      .1356377    .3377904
         pi3 |   .0264326   .0095693                      .0076772     .045188
------------------------------------------------------------------------------

. estimates store CFM3NB2

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
     CFM3NB2 |   4406           .   -12144.33     24     24336.67    24490.04
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. scalar llCFM3NB2 = e(ll)

. * e(rank) gives number of parameters (e(k)) minus number of constraints
. scalar kCFM3NB2 = e(rank)

. 
. *** TABLE 6.3: OFP VISITS LIKELIHOOD RATIO TESTS 
. 
. *** This differs from book as Trivedi and Deb (1977) used different program
. 
. * NB1 likelihood ratio tests
. dis "NB1 vs NB1H          : " 2*(llHNB1-llNB1) "  DofF = " kHNB1log-kNB1
NB1 vs NB1H          : 59.899948  DofF = 17

. dis "NB1 vs CFM2 NB1      : " 2*(llCFM2NB1-llNB1) "  DofF = " kCFM2NB1-kNB1
NB1 vs CFM2 NB1      : 116.70417  DofF = 3

. dis "NB1 vs FM2 NB1       : " 2*(llFM2NB1-llNB1) "  DofF = " kFM2NB1-kNB1
NB1 vs FM2 NB1       : 127.54677  DofF = 19

. dis "CFM2 NB1 vs FM2 NB1  : " 2*(llFM2NB1-llCFM2NB1) "  DofF = " kFM2NB1-kCFM2NB1
CFM2 NB1 vs FM2 NB1  : 10.842605  DofF = 16

. dis "CFM2 NB1 vs CFM3 NB1 : " 2*(llCFM3NB1-llCFM2NB1) "  DofF = " kCFM3NB1-kCFM2NB1
CFM2 NB1 vs CFM3 NB1 : 4.7349458  DofF = 3

. dis "FM3 NB1 vs FM2 NB1   : " 2*(llFM3NB1-llFM2NB1) "  DofF = " kFM3NB1-kFM2NB1
FM3 NB1 vs FM2 NB1   : 84.650649  DofF = 18

. 
. * NB2 likelihood ratio tests
. dis "NB2 vs NB2H          : " 2*(llHNB2-llNB2) "  DofF = " kHNB2log-kNB2
NB2 vs NB2H          : 187.31303  DofF = 17

. dis "NB2 vs CFM2 NB2      : " 2*(llCFM2NB2-llNB2) "  DofF = " kCFM2NB2-kNB2
NB2 vs CFM2 NB2      : 106.75709  DofF = 3

. dis "NB2 vs FM2 NB2       : " 2*(llFM2NB2-llNB2) "  DofF = " kFM2NB2-kNB2
NB2 vs FM2 NB2       : 125.71262  DofF = 19

. dis "CFM2 NB2 vs FM2 NB2  : " 2*(llFM2NB2-llCFM2NB2) "  DofF = " kFM2NB2-kCFM2NB2
CFM2 NB2 vs FM2 NB2  : 18.955532  DofF = 16

. dis "CFM2 NB2 vs CFM3 NB2 : " 2*(llCFM3NB2-llCFM2NB2) "  DofF = " kCFM3NB2-kCFM2NB2
CFM2 NB2 vs CFM3 NB2 : 8.9127166  DofF = 3

. dis "FM3 NB2 vs FM2 NB2   : " 2*(llFM3NB2-llFM2NB2) "  DofF = " kFM3NB2-kFM2NB2
FM3 NB2 vs FM2 NB2   : 118.01239  DofF = 19

. 
. *** TABLE 6.4: OFP VISITS LL and AIC for various models
. 
. *** This differs from book as Trivedi and Deb (1977) used different program
. *** Also we do not calculate GoF tests here
. 
. ** TABLE 6.4: NB1 and NB2 Hurdle models - second row of table
. 
. display "Hurdle: NB1 / NB1    : k = " kHNB1 " and ll = " llHNB1 " and AIC = " AICHNB1 " and BIC = " BICHNB1 
Hurdle: NB1 / NB1    : k = 36 and ll = -12126.253 and AIC = 24324.505 and BIC = 24554.571

. display "Hurdle: NB2 / NB2    : k = " kHNB2 " and ll = " llHNB2 " and AIC = " AICHNB2 " and BIC = " BICHNB2
Hurdle: NB2 / NB2    : k = 36 and ll = -12108.511 and AIC = 24289.022 and BIC = 24519.088

. 
. * ASIDE: Instead use logit at first stage
. display "Hurdle: Logit / NB1  : k = " kHNB1log " and ll = " llHNB1log " and AIC = " AICHNB1log " and BIC = " BICHNB1log
Hurdle: Logit / NB1  : k = 35 and ll = -12113.027 and AIC = 24296.053 and BIC = 24519.728

. display "Hurdle: Logit / NB2  : k = " kHNB2log " and ll = " llHNB2log " and AIC = " AICHNB2log " and BIC = " BICHNB2log
Hurdle: Logit / NB2  : k = 35 and ll = -12110.492 and AIC = 24290.983 and BIC = 24514.658

. 
. ** TABLE 6.4: Remaining NB1 models
. 
. estimates table POISSON NB1 CFM2NB1 FM2NB1 CFM3NB1 FM3NB1, keep(EXCLHLTH) ///
>    b(%10.3f) t(%10.2f) stats(l ll aic bic N) equations(1) 

--------------------------------------------------------------------------------------------
    Variable |  POISSON        NB1        CFM2NB1       FM2NB1      CFM3NB1       FM3NB1    
-------------+------------------------------------------------------------------------------
    EXCLHLTH |     -0.386       -0.268       -0.281       -0.229       -0.286       -0.285  
             |      -4.91        -5.29        -4.93        -3.85        -4.89        -4.33  
-------------+------------------------------------------------------------------------------
           l |                                                                              
          ll | -18134.567   -12156.202   -12097.850   -12092.429   -12095.483   -12050.104  
         aic |  36303.133    24348.405    24237.701    24258.858    24238.966    24210.208  
         bic |  36411.775    24463.438    24371.906    24495.315    24392.343    24561.697  
           N |       4406         4406         4406         4406         4406         4406  
--------------------------------------------------------------------------------------------
                                                                                 legend: b/t

. 
. ** TABLE 6.4: Remaining NB2 models
. 
. estimates table POISSON NB2 CFM2NB2 FM2NB2 CFM3NB2 FM3NB2, keep(EXCLHLTH) ///
>    b(%10.3f) t(%10.2f) stats(l ll aic bic N) equations(1) 

--------------------------------------------------------------------------------------------
    Variable |  POISSON        NB2        CFM2NB2       FM2NB2      CFM3NB2       FM3NB2    
-------------+------------------------------------------------------------------------------
    EXCLHLTH |     -0.386       -0.385       -0.374       -0.343       -0.374       -0.307  
             |      -4.91        -4.92        -6.01        -3.27        -6.09        -2.55  
-------------+------------------------------------------------------------------------------
           l |                                                                              
          ll | -18134.567   -12202.168   -12148.789   -12139.311   -12144.333   -12080.305  
         aic |  36303.133    24440.335    24339.578    24352.623    24336.665    24272.610  
         bic |  36411.775    24555.368    24473.783    24589.079    24490.043    24630.491  
           N |       4406         4406         4406         4406         4406         4406  
--------------------------------------------------------------------------------------------
                                                                                 legend: b/t

. 
. ** Focus on probabilities and overdispersion parameters in FM
. estimates table CFM3NB1 FM3NB1 CFM3NB2 FM3NB2, keep (imlogitpi1:_cons imlogitpi2:_cons lnalpha1:_cons lnalpha2:_cons lnalpha1
> :_cons)

------------------------------------------------------------------
    Variable |  CFM3NB1       FM3NB1      CFM3NB2       FM3NB2    
-------------+----------------------------------------------------
imlogitpi1   |
       _cons |  2.8703108    2.2169451    3.3495159     .7364091  
-------------+----------------------------------------------------
imlogitpi2   |
       _cons |  .33730178   -.29406864    2.1214345   -.45767375  
-------------+----------------------------------------------------
lnalpha1     |
       _cons |                           -.87599699   -.86167567  
-------------+----------------------------------------------------
lnalpha2     |
       _cons |                            1.0285445    .72328708  
-------------+----------------------------------------------------
lnalpha1     |
       _cons |                           -.87599699   -.86167567  
------------------------------------------------------------------

. 
. *********** 6.3.8 HURDLE MODEL (Table 6.8)
. 
. *** TABLE 6.8: NB2 HURDLE ESTIMATES WITH LOGIT FIRST STAGE
. 
. * Could use earlier results
. * Simpler to use user-written addon command hnblogit
. hnblogit OFP $XLIST, vce(robust)

initial:       log pseudolikelihood = -20689.057
alternative:   log pseudolikelihood = -14973.253
rescale:       log pseudolikelihood = -12983.223
rescale eq:    log pseudolikelihood = -12845.236
Iteration 0:   log pseudolikelihood = -12845.236  (not concave)
Iteration 1:   log pseudolikelihood = -12402.134  
Iteration 2:   log pseudolikelihood = -12362.641  
Iteration 3:   log pseudolikelihood = -12114.183  
Iteration 4:   log pseudolikelihood =   -12110.5  
Iteration 5:   log pseudolikelihood = -12110.492  
Iteration 6:   log pseudolikelihood = -12110.492  

Negative Binomial-Logit Hurdle Regression         Number of obs   =       4406
                                                  Wald chi2(16)   =     279.07
Log pseudolikelihood = -12110.492                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
logit        |
    EXCLHLTH |   -.328511   .1422489    -2.31   0.021    -.6073137   -.0497083
    POORHLTH |   .0708379   .1687321     0.42   0.675    -.2598709    .4015468
    NUMCHRON |    .556512   .0527686    10.55   0.000     .4530874    .6599367
     ADLDIFF |  -.1881658   .1299432    -1.45   0.148    -.4428498    .0665183
     NOREAST |   .1292212   .1250505     1.03   0.301    -.1158732    .3743157
     MIDWEST |   .1008883   .1146354     0.88   0.379    -.1237929    .3255696
        WEST |   .2016634   .1336443     1.51   0.131    -.0602747    .4636014
         AGE |   .1904976   .0811478     2.35   0.019     .0314509    .3495443
       BLACK |  -.3269721   .1334663    -2.45   0.014    -.5885612   -.0653829
        MALE |  -.4644473     .09852    -4.71   0.000    -.6575429   -.2713517
     MARRIED |   .2472641   .1039523     2.38   0.017     .0435213    .4510069
      SCHOOL |   .0542073   .0131949     4.11   0.000     .0283458    .0800688
      FAMINC |   .0067446   .0184979     0.36   0.715    -.0295106    .0429998
    EMPLOYED |  -.0123197    .145099    -0.08   0.932    -.2967086    .2720692
     PRIVINS |   .7624605   .1173052     6.50   0.000     .5325465    .9923745
    MEDICAID |    .553514   .1812261     3.05   0.002     .1983173    .9087106
       _cons |  -1.475312   .6464113    -2.28   0.022    -2.742255   -.2083689
-------------+----------------------------------------------------------------
negbinomial  |
    EXCLHLTH |  -.3775071   .0872882    -4.32   0.000    -.5485887   -.2064254
    POORHLTH |   .3325089   .0567568     5.86   0.000     .2212676    .4437502
    NUMCHRON |   .1429372   .0134916    10.59   0.000     .1164941    .1693804
     ADLDIFF |   .1290355    .051603     2.50   0.012     .0278954    .2301756
     NOREAST |   .1040669   .0527805     1.97   0.049      .000619    .2075148
     MIDWEST |  -.0163184   .0475067    -0.34   0.731    -.1094298     .076793
        WEST |    .123247   .0504022     2.45   0.014     .0244605    .2220335
         AGE |  -.0753009    .032266    -2.33   0.020    -.1385412   -.0120606
       BLACK |   .0016163    .070014     0.02   0.982    -.1356086    .1388412
        MALE |   .0041276   .0421937     0.10   0.922    -.0785705    .0868257
     MARRIED |  -.0920324   .0437353    -2.10   0.035    -.1777521   -.0063127
      SCHOOL |   .0216107   .0056616     3.82   0.000     .0105142    .0327072
      FAMINC |  -.0022357   .0058903    -0.38   0.704    -.0137805    .0093091
    EMPLOYED |   .0296559   .0739406     0.40   0.688    -.1152651    .1745769
     PRIVINS |   .2271509   .0566732     4.01   0.000     .1160735    .3382283
    MEDICAID |   .1847927    .066457     2.78   0.005     .0545393    .3150461
       _cons |   1.630983   .2692104     6.06   0.000      1.10334    2.158626
-------------+----------------------------------------------------------------
    /lnalpha |  -.2959882   .0542073    -5.46   0.000    -.4022325   -.1897438
------------------------------------------------------------------------------
AIC Statistic =     5.505

. scalar llhnblogit = e(ll)

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |   4406           .   -12110.49     35     24290.98    24514.66
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. 
. *********** 6.3.5-6.3.7  DETAILED ANALYSIS OF UNCONSTRAINED FNM NB1 model with 2 components
. 
. preserve 

. 
. * TABLES 6.5, 6.6 and 6.7 recode the largest value of OFP from 89 to 70
. 
. replace OFP = 70 if OFP > 70
(1 real change made)

. 
. * See how NB1 loglikelihood changes as mentioned in text
. quietly nbreg OFP $XLIST, vce(robust) dispersion(constant)

. display "Fitted log-likelihood for NB1 = " e(ll) 
Fitted log-likelihood for NB1 = -12152.738

. 
. * Estimate FMM model model and save results
. fmm OFP $XLIST, components(2) mixtureof(negbin1) vce(robust)

Fitting Negative Binomial-1 model:

Iteration 0:   log likelihood = -18090.998  
Iteration 1:   log likelihood = -18090.913  
Iteration 2:   log likelihood = -18090.913  

Iteration 0:   log likelihood = -14539.129  
Iteration 1:   log likelihood = -12648.799  
Iteration 2:   log likelihood =  -12490.01  
Iteration 3:   log likelihood = -12489.804  
Iteration 4:   log likelihood = -12489.804  

Iteration 0:   log likelihood = -12489.804  
Iteration 1:   log likelihood = -12298.424  
Iteration 2:   log likelihood = -12153.535  
Iteration 3:   log likelihood = -12152.738  
Iteration 4:   log likelihood = -12152.738  

Fitting 2 component Negative Binomial-1 model:

Iteration 0:   log pseudolikelihood = -12153.274  (not concave)
Iteration 1:   log pseudolikelihood = -12152.052  (not concave)
Iteration 2:   log pseudolikelihood = -12119.599  (not concave)
Iteration 3:   log pseudolikelihood = -12101.578  
Iteration 4:   log pseudolikelihood = -12084.198  (not concave)
Iteration 5:   log pseudolikelihood = -12080.404  
Iteration 6:   log pseudolikelihood = -12079.653  
Iteration 7:   log pseudolikelihood = -12078.334  
Iteration 8:   log pseudolikelihood =  -12077.21  
Iteration 9:   log pseudolikelihood = -12076.934  
Iteration 10:  log pseudolikelihood =  -12076.91  
Iteration 11:  log pseudolikelihood = -12076.909  

2 component Negative Binomial-1 regression        Number of obs   =       4406
                                                  Wald chi2(32)   =     795.46
Log pseudolikelihood = -12076.909                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.2497655    .057929    -4.31   0.000    -.3633043   -.1362268
    POORHLTH |   .2338421    .065056     3.59   0.000     .1063347    .3613496
    NUMCHRON |   .1858892   .0127116    14.62   0.000      .160975    .2108034
     ADLDIFF |  -.0158776   .0431165    -0.37   0.713    -.1003844    .0686291
     NOREAST |   .0829703   .0483592     1.72   0.086    -.0118119    .1777526
     MIDWEST |   .0180267   .0395598     0.46   0.649    -.0595091    .0955626
        WEST |   .0892005   .0488985     1.82   0.068    -.0066388    .1850397
         AGE |   .0284182   .0266794     1.07   0.287    -.0238726    .0807089
       BLACK |  -.0792232   .0705989    -1.12   0.262    -.2175945     .059148
        MALE |  -.1360233   .0347308    -3.92   0.000    -.2040944   -.0679521
     MARRIED |   .0474489   .0354877     1.34   0.181    -.0221058    .1170036
      SCHOOL |   .0142692   .0052279     2.73   0.006     .0040226    .0245157
      FAMINC |  -.0003394   .0052844    -0.06   0.949    -.0106967    .0100179
    EMPLOYED |  -.0585768   .0561586    -1.04   0.297    -.1686457    .0514921
     PRIVINS |   .2542815     .05307     4.79   0.000     .1502663    .3582967
    MEDICAID |   .3528854   .0620136     5.69   0.000      .231341    .4744298
       _cons |   .7780131   .2235745     3.48   0.001     .3398151    1.216211
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.7513363   .7367241    -1.02   0.308    -2.195289    .6926165
    POORHLTH |    .039149     .65878     0.06   0.953    -1.252036    1.330334
    NUMCHRON |   .1388443    .104259     1.33   0.183    -.0654995    .3431882
     ADLDIFF |   .5458759   .2679258     2.04   0.042     .0207511    1.071001
     NOREAST |    .178225    .485191     0.37   0.713     -.772732    1.129182
     MIDWEST |   .0419492   .3572626     0.12   0.907    -.6582726     .742171
        WEST |   .2363191   .4852752     0.49   0.626    -.7148029    1.187441
         AGE |  -.6110602   .2475692    -2.47   0.014    -1.096287   -.1258335
       BLACK |  -1.064927   1.090272    -0.98   0.329    -3.201821    1.071967
        MALE |   .1204642   .2603865     0.46   0.644    -.3898839    .6308124
     MARRIED |  -.5129287    .331818    -1.55   0.122     -1.16328    .1374226
      SCHOOL |   .1517549   .0822947     1.84   0.065    -.0095398    .3130496
      FAMINC |   -.005429   .0200526    -0.27   0.787    -.0447314    .0338735
    EMPLOYED |   .3717573   .6895927     0.54   0.590    -.9798197    1.723334
     PRIVINS |   3.020036    2.69528     1.12   0.263    -2.262616    8.302688
    MEDICAID |  -3.147283   3.233294    -0.97   0.330    -9.484422    3.189856
       _cons |    1.86179   2.627607     0.71   0.479    -3.288225    7.011806
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.334341   .3467302     6.73   0.000     1.654762     3.01392
   /lndelta1 |   1.250592   .0810018    15.44   0.000     1.091831    1.409352
   /lndelta2 |   2.796696   .4079347     6.86   0.000     1.997159    3.596233
------------------------------------------------------------------------------
      delta1 |   3.492409   .2828914                      2.979725    4.093303
      delta2 |    16.3904   6.686215                      7.368091    36.46064
         pi1 |   .9116815   .0279181                      .8395336     .953199
         pi2 |   .0883185   .0279181                       .046801    .1604664
------------------------------------------------------------------------------

. estimates store FMMalt70

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
    FMMalt70 |   4406           .   -12076.91     37     24227.82    24464.27
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. 
. * Create fitted means and variances in the two components
. matrix theta = e(b)

. scalar delta1 = exp(theta[1,e(k)-1])

. scalar delta2 = exp(theta[1,e(k)])

. predict mu1, mean equation(component1) 

. predict mu2, mean equation(component2)

. generate mu1alt = mu1

. generate mu2alt = mu2

. generate var1 = mu1*(1+delta1)

. generate var2 = mu2*(1+delta2)

. predict p1, prior equation(component1) 

. predict posterior1, posterior equation(component1) 

. generate mufm = p1*mu1 + (1-p1)*mu2

. * The following differs from Table 6.5 - need to check
. generate varfm = p1*(mu1^2 + var1) + (1-p1)*(mu2^2 + var2) - mufm^2

. 
. * Create predicted probabilities for preferred 2-component NB1 finite mixture model
. * For 2-component NB2 estimate 2 component NB2 model and then 
. * change  generate ainvmu = mu1/delta1  to  ainvmu = 1/delta1
. * change  replace ainvmu = mu2/delta2   to  ainvmu = 1/delta2
. 
. global MAXCOUNT 20

. * First component
. generate mu = mu1

. generate ainvmu = mu1/delta1    // For NB1: (1/a)*mu   For NB2: use (1/a)

. generate pfit1sum = 0

. forvalues i = 0/$MAXCOUNT {
  2.    generate pfit1`i' = lngamma(`i'+ainvmu) - lngamma(ainvmu) - lnfactorial(`i') + ainvmu*ln(ainvmu/(ainvmu+mu)) + `i'*ln(m
> u/(ainvmu+mu))
  3.    quietly replace pfit1`i' = exp(pfit1`i')
  4.    quietly replace pfit1sum = pfit1sum + pfit1`i'
  5.    }

. * Second component
. replace mu = mu2
(4406 real changes made)

. replace ainvmu = mu2/delta2
(4406 real changes made)

. generate pfit2sum = 0

. forvalues i = 0/$MAXCOUNT {
  2.    generate pfit2`i' = lngamma(`i'+ainvmu) - lngamma(ainvmu) - lnfactorial(`i') + ainvmu*ln(ainvmu/(ainvmu+mu)) + `i'*ln(m
> u/(ainvmu+mu))
  3.    quietly replace pfit2`i' = exp(pfit2`i')
  4.    quietly replace pfit2sum = pfit2sum + pfit2`i'
  5.    }

. * Combined
. generate pfitsum = 0

. forvalues i = 0/$MAXCOUNT {
  2.    generate pfitfm`i' = p1*pfit1`i' + (1-p1)*pfit2`i'
  3.    }

. generate pfitfmsum = p1*pfit1sum + (1-p1)*pfit2sum

. generate pfitfmge10 = 1

. forvalues i = 0/9 {
  2.     replace pfitfmge10 = pfitfmge10 - pfitfm`i'
  3.    }
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)
(4406 real changes made)

. 
. *** TABLE 6.5: FITTED PROBABILITIES FROM THE TWO COMPONENT MODEL
. 
. display "Fitted probabilities from 2 component NB1 finite mixture model" 
Fitted probabilities from 2 component NB1 finite mixture model

. summarize pfitfm*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     pfitfm0 |      4406    .1503509    .0847528   .0010897   .5103663
     pfitfm1 |      4406    .1159523    .0409432   .0030036   .1832897
     pfitfm2 |      4406    .1053953    .0253215   .0033814   .1297264
     pfitfm3 |      4406    .0935062    .0159368   .0040264   .1054766
     pfitfm4 |      4406    .0815833    .0112362   .0056819   .0910873
-------------+--------------------------------------------------------
     pfitfm5 |      4406    .0703565     .010061   .0081193   .0813111
     pfitfm6 |      4406    .0601635    .0104913   .0111791   .0741069
     pfitfm7 |      4406    .0511216    .0111262   .0146903    .068548
     pfitfm8 |      4406    .0432274    .0114868   .0116213   .0640454
     pfitfm9 |      4406     .036414    .0115049   .0085459   .0603456
-------------+--------------------------------------------------------
    pfitfm10 |      4406    .0305839     .011233   .0063207   .0572259
    pfitfm11 |      4406    .0256282    .0107473   .0046969   .0544785
    pfitfm12 |      4406    .0214378    .0101183   .0035039   .0521853
    pfitfm13 |      4406    .0179095    .0094038   .0026226    .050112
    pfitfm14 |      4406    .0149486    .0086483   .0019686   .0480914
-------------+--------------------------------------------------------
    pfitfm15 |      4406    .0124709    .0078847   .0014814   .0463336
    pfitfm16 |      4406    .0104022    .0071366   .0011172   .0445443
    pfitfm17 |      4406    .0086781      .00642   .0008442   .0432813
    pfitfm18 |      4406    .0072433    .0057452   .0006391   .0422218
    pfitfm19 |      4406    .0060507    .0051185   .0004846    .040765
-------------+--------------------------------------------------------
    pfitfm20 |      4406    .0050603    .0045425    .000368   .0389894
   pfitfmsum |      4406    .9684846    .0340814   .5646738    .998804
  pfitfmge10 |      4406     .191929     .115718   .0252433    .847298

. 
. *** TABLE 6.6: FMM MODEL MEANS and VARIANCE in the TWO COMPONENTS
. 
. * Summary statistics
. summarize mu1 mu2 var1 var2 mufm varfm p1 posterior1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         mu1 |      4406    5.539224    2.145586   1.787157   21.25769
         mu2 |      4406    8.178798    8.572553    .000796   79.82777
        var1 |      4406    24.88446    9.638848    8.02864   95.49821
        var2 |      4406    142.2326    149.0801    .013842   1388.237
        mufm |      4406    5.772347    2.266985   1.632626   19.51864
-------------+--------------------------------------------------------
       varfm |      4406    41.35636    33.16822   7.623593   595.8615
          p1 |      4406    .9116815           0   .9116815   .9116815
  posterior1 |      4406    .9116827    .1324927   .0002258   .9999993

. 
. *** FIGURE 6.3: PREDICTED MEANS IN THE TWO COMPONENTS 
. 
. * Histogram of means
. quietly histogram mu1, width(2) name(_comp_1, replace) scale(1.5)

. quietly histogram mu2, width(2) name(_comp_2, replace) scale(1.5)

. graph combine _comp_1 _comp_2, iscale(0.7) ysize(3) xsize(6) xcommon

. quietly graph export racd06fig3.wmf, replace

. quietly graph export racd06fig3.eps, replace

. 
. *** TABLE 6.7: FMM MODEL ESTIMATES
. 
. * Tabulate results for earlier estimated model and save results
. estimates table FMMalt70, b(%10.3f) t(%10.2f) stats(l ll aic bic N) equations(1)

---------------------------
    Variable |  FMMalt70   
-------------+-------------
#1           |
    EXCLHLTH |     -0.250  
             |      -4.31  
    POORHLTH |      0.234  
             |       3.59  
    NUMCHRON |      0.186  
             |      14.62  
     ADLDIFF |     -0.016  
             |      -0.37  
     NOREAST |      0.083  
             |       1.72  
     MIDWEST |      0.018  
             |       0.46  
        WEST |      0.089  
             |       1.82  
         AGE |      0.028  
             |       1.07  
       BLACK |     -0.079  
             |      -1.12  
        MALE |     -0.136  
             |      -3.92  
     MARRIED |      0.047  
             |       1.34  
      SCHOOL |      0.014  
             |       2.73  
      FAMINC |     -0.000  
             |      -0.06  
    EMPLOYED |     -0.059  
             |      -1.04  
     PRIVINS |      0.254  
             |       4.79  
    MEDICAID |      0.353  
             |       5.69  
       _cons |      0.778  
             |       3.48  
-------------+-------------
component2   |
    EXCLHLTH |     -0.751  
             |      -1.02  
    POORHLTH |      0.039  
             |       0.06  
    NUMCHRON |      0.139  
             |       1.33  
     ADLDIFF |      0.546  
             |       2.04  
     NOREAST |      0.178  
             |       0.37  
     MIDWEST |      0.042  
             |       0.12  
        WEST |      0.236  
             |       0.49  
         AGE |     -0.611  
             |      -2.47  
       BLACK |     -1.065  
             |      -0.98  
        MALE |      0.120  
             |       0.46  
     MARRIED |     -0.513  
             |      -1.55  
      SCHOOL |      0.152  
             |       1.84  
      FAMINC |     -0.005  
             |      -0.27  
    EMPLOYED |      0.372  
             |       0.54  
     PRIVINS |      3.020  
             |       1.12  
    MEDICAID |     -3.147  
             |      -0.97  
       _cons |      1.862  
             |       0.71  
-------------+-------------
imlogitpi1   |
       _cons |      2.334  
             |       6.73  
-------------+-------------
lndelta1     |
       _cons |      1.251  
             |      15.44  
-------------+-------------
lndelta2     |
       _cons |      2.797  
             |       6.86  
-------------+-------------
Statistics   |             
           l |             
          ll | -12076.909  
         aic |  24227.818  
         bic |  24464.275  
           N |       4406  
---------------------------
                legend: b/t

. 
. ****** DIRECTIONAL GRADIENTS
. 
. restore 

. 
. * NB1 model
. nbreg OFP $XLIST, dispersion(constant)

Fitting Poisson model:

Iteration 0:   log likelihood = -18134.655  
Iteration 1:   log likelihood = -18134.567  
Iteration 2:   log likelihood = -18134.567  

Fitting constant-only model:

Iteration 0:   log likelihood = -14552.718  
Iteration 1:   log likelihood = -12647.886  
Iteration 2:   log likelihood = -12493.025  
Iteration 3:   log likelihood = -12492.829  
Iteration 4:   log likelihood = -12492.829  

Fitting full model:

Iteration 0:   log likelihood = -12492.829  
Iteration 1:   log likelihood = -12301.184  
Iteration 2:   log likelihood =     -12157  
Iteration 3:   log likelihood = -12156.203  
Iteration 4:   log likelihood = -12156.202  

Negative binomial regression                      Number of obs   =       4406
                                                  LR chi2(16)     =     673.25
Dispersion     = constant                         Prob > chi2     =     0.0000
Log likelihood = -12156.202                       Pseudo R2       =     0.0269

------------------------------------------------------------------------------
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    EXCLHLTH |  -.2679127   .0576981    -4.64   0.000    -.3809989   -.1548265
    POORHLTH |   .1890825   .0411083     4.60   0.000     .1085117    .2696533
    NUMCHRON |   .1774737   .0095852    18.52   0.000     .1586871    .1962604
     ADLDIFF |   .0054215   .0367353     0.15   0.883    -.0665783    .0774213
     NOREAST |   .0715408   .0377765     1.89   0.058    -.0024998    .1455814
     MIDWEST |   .0138372   .0346677     0.40   0.690    -.0541102    .0817846
        WEST |   .1049489   .0382474     2.74   0.006     .0299853    .1799125
         AGE |  -.0032939    .022647    -0.15   0.884    -.0476813    .0410935
       BLACK |  -.1275746   .0481892    -2.65   0.008    -.2220236   -.0331255
        MALE |  -.1231018   .0297265    -4.14   0.000    -.1813646    -.064839
     MARRIED |   .0221482   .0308539     0.72   0.473    -.0383244    .0826208
      SCHOOL |   .0212676   .0041187     5.16   0.000     .0131952    .0293401
      FAMINC |   -.000249   .0047198    -0.05   0.958    -.0094996    .0090016
    EMPLOYED |  -.0180486      .0472    -0.38   0.702    -.1105589    .0744617
     PRIVINS |   .3364587   .0407839     8.25   0.000     .2565237    .4163938
    MEDICAID |   .3180563   .0529574     6.01   0.000     .2142618    .4218509
       _cons |    .949961   .1819063     5.22   0.000     .5934312    1.306491
-------------+----------------------------------------------------------------
    /lndelta |   1.576208   .0311676                      1.515121    1.637295
-------------+----------------------------------------------------------------
       delta |   4.836581   .1507445                      4.549971    5.141246
------------------------------------------------------------------------------
Likelihood-ratio test of delta=0:  chibar2(01) = 1.2e+04 Prob>=chibar2 = 0.000

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

. scalar delta = exp(_b[/lndelta])

. generate psi = exb / delta

. scalar phi = ln(1+delta)

. 
. forvalues y=0/12 {
  2. generate f`y'_nb1 = exp(lngamma(`y'+psi) - lngamma(`y'+1) ///
>                    - lngamma(psi) + _b[/lndelta]*`y' - (`y'+psi)*phi)
  3. }

. drop exb psi

. 
. * FM model
. fmm OFP $XLIST, mix(negbin1) components(2)

Fitting Negative Binomial-1 model:

Iteration 0:   log likelihood = -18134.655  
Iteration 1:   log likelihood = -18134.567  
Iteration 2:   log likelihood = -18134.567  

Iteration 0:   log likelihood = -14552.718  
Iteration 1:   log likelihood = -12647.886  
Iteration 2:   log likelihood = -12493.025  
Iteration 3:   log likelihood = -12492.829  
Iteration 4:   log likelihood = -12492.829  

Iteration 0:   log likelihood = -12492.829  
Iteration 1:   log likelihood = -12301.184  
Iteration 2:   log likelihood =     -12157  
Iteration 3:   log likelihood = -12156.203  
Iteration 4:   log likelihood = -12156.202  

Fitting 2 component Negative Binomial-1 model:

Iteration 0:   log likelihood =  -12156.74  (not concave)
Iteration 1:   log likelihood = -12155.694  (not concave)
Iteration 2:   log likelihood = -12134.293  (not concave)
Iteration 3:   log likelihood = -12108.437  (not concave)
Iteration 4:   log likelihood = -12100.205  
Iteration 5:   log likelihood = -12095.077  
Iteration 6:   log likelihood = -12093.661  
Iteration 7:   log likelihood = -12092.693  
Iteration 8:   log likelihood =  -12092.43  
Iteration 9:   log likelihood = -12092.429  
Iteration 10:  log likelihood = -12092.429  

2 component Negative Binomial-1 regression        Number of obs   =       4406
                                                  Wald chi2(32)   =     813.60
Log likelihood = -12092.429                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.2290118   .0657969    -3.48   0.001    -.3579714   -.1000522
    POORHLTH |   .1499097   .0482609     3.11   0.002       .05532    .2444994
    NUMCHRON |   .1836232   .0115675    15.87   0.000     .1609514    .2062951
     ADLDIFF |  -.0520085   .0437403    -1.19   0.234    -.1377379     .033721
     NOREAST |   .0546492    .045218     1.21   0.227    -.0339765    .1432748
     MIDWEST |   .0191861   .0410324     0.47   0.640    -.0612359    .0996081
        WEST |   .0944858   .0442702     2.13   0.033     .0077179    .1812538
         AGE |   .0148273   .0272407     0.54   0.586    -.0385634     .068218
       BLACK |  -.1799111   .0630175    -2.85   0.004    -.3034232   -.0563991
        MALE |  -.1377495    .035128    -3.92   0.000    -.2065991   -.0688998
     MARRIED |   .0513625    .036238     1.42   0.156    -.0196628    .1223877
      SCHOOL |   .0133302   .0054999     2.42   0.015     .0025507    .0241097
      FAMINC |   .0007834   .0051657     0.15   0.879    -.0093412    .0109079
    EMPLOYED |  -.0807253   .0538157    -1.50   0.134    -.1862022    .0247516
     PRIVINS |   .3593702   .0538514     6.67   0.000     .2538233     .464917
    MEDICAID |   .4204549   .0826951     5.08   0.000     .2583755    .5825343
       _cons |   .7733975   .2262585     3.42   0.001      .329939    1.216856
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.8178674   .4061745    -2.01   0.044    -1.613955     -.02178
    POORHLTH |    .718358   .2390433     3.01   0.003     .2498417    1.186874
    NUMCHRON |   .1908478   .0762596     2.50   0.012     .0413818    .3403138
     ADLDIFF |    .549827   .1972346     2.79   0.005     .1632543    .9363997
     NOREAST |   .2279207   .2653733     0.86   0.390    -.2922015    .7480429
     MIDWEST |  -.0123035   .2647277    -0.05   0.963    -.5311603    .5065532
        WEST |   .2660744   .2394914     1.11   0.267    -.2033202     .735469
         AGE |  -.1334189   .1863378    -0.72   0.474    -.4986342    .2317964
       BLACK |   .2680242   .3900981     0.69   0.492    -.4965539    1.032602
        MALE |  -.0228589   .2018914    -0.11   0.910    -.4185587    .3728409
     MARRIED |   -.242328   .2003793    -1.21   0.227    -.6350642    .1504082
      SCHOOL |   .1023137   .0321577     3.18   0.001     .0392858    .1653416
      FAMINC |  -.0011579   .0223861    -0.05   0.959    -.0450338     .042718
    EMPLOYED |   .5400458    .257839     2.09   0.036     .0346906    1.045401
     PRIVINS |    .227208   .3724258     0.61   0.542    -.5027332    .9571493
    MEDICAID |  -.6163631   .5590777    -1.10   0.270    -1.712135     .479409
       _cons |   1.554799   1.597789     0.97   0.331     -1.57681    4.686408
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.290933   .3138519     7.30   0.000     1.675794    2.906071
   /lndelta1 |   1.259071   .0537703    23.42   0.000     1.153683    1.364459
   /lndelta2 |   2.441911   .2382819    10.25   0.000     1.974887    2.908935
------------------------------------------------------------------------------
      delta1 |   3.522148    .189387                      3.169847    3.913605
      delta2 |   11.49499   2.739047                      7.205806    18.33726
         pi1 |   .9081233   .0261864                      .8423468    .9481457
         pi2 |   .0918767   .0261864                      .0518543    .1576532
------------------------------------------------------------------------------

. predict exb1, eq(component1)

. predict exb2, eq(component2)

. sum exb1 exb2

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        exb1 |      4406    5.205164    1.934959   1.483609   19.76001
        exb2 |      4406    11.79034    10.14905     .64758   107.9005

. scalar delta1 = exp(_b[/lndelta1])

. scalar delta2 = exp(_b[/lndelta2])

. generate psi1 = exb1 / delta1

. generate psi2 = exb2 / delta2

. scalar phi1 = ln(1+delta1)

. scalar phi2 = ln(1+delta2)

. forvalues y=0/12 {
  2. generate f`y'_fmnb1 = e(pi1_est) * (exp(lngamma(`y'+psi1) - lngamma(`y'+1) ///
>        - lngamma(psi1) + _b[/lndelta1]*`y' - (`y'+psi1)*phi1)) ///
>        + e(pi2_est) * (exp(lngamma(`y'+psi2) - lngamma(`y'+1)  ///
>        - lngamma(psi2) + _b[/lndelta2]*`y' - (`y'+psi2)*phi2))
  3. }

. drop exb1 exb2 psi1 psi2

. 
. * Compute directional gradients
. forvalues y = 0/12 {
  2.         gen d`y' = f`y'_nb1 / f`y'_fmnb1 - 1
  3. }

. preserve

. collapse (mean) d0-d12

. gen i = _n

. reshape long d, i(i) j(y)
(note: j = 0 1 2 3 4 5 6 7 8 9 10 11 12)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                        1   ->      13
Number of variables                  14   ->       3
j variable (13 values)                    ->   y
xij variables:
                          d0 d1 ... d12   ->   d
-----------------------------------------------------------------------------

. 
. display "Directional gradients from 2 component NB1 finite mixture model"
Directional gradients from 2 component NB1 finite mixture model

. list d y

     +----------------+
     |         d    y |
     |----------------|
  1. |  .0937744    0 |
  2. |  .0042625    1 |
  3. | -.0400999    2 |
  4. | -.0575196    3 |
  5. | -.0600343    4 |
     |----------------|
  6. | -.0531821    5 |
  7. | -.0399194    6 |
  8. | -.0220267    7 |
  9. |  -.000694    8 |
 10. |  .0232024    9 |
     |----------------|
 11. |  .0489557   10 |
 12. |  .0759485   11 |
 13. |  .1036068   12 |
     +----------------+

. 
. *** FIGURE 6.2: OFP VISITS: DIRECTIONAL GRADIENTS
. twoway line d y, xlabel(0(1)12) yline(0)

. 
. restore

. 
. ******* SENSITIVITY TO OUTLIERS (end 6.3.6)
. 
. * Same model with original sample
. fmm OFP $XLIST, components(2) mixtureof(negbin1) vce(robust)

Fitting Negative Binomial-1 model:

Iteration 0:   log likelihood = -18134.655  
Iteration 1:   log likelihood = -18134.567  
Iteration 2:   log likelihood = -18134.567  

Iteration 0:   log likelihood = -14552.718  
Iteration 1:   log likelihood = -12647.886  
Iteration 2:   log likelihood = -12493.025  
Iteration 3:   log likelihood = -12492.829  
Iteration 4:   log likelihood = -12492.829  

Iteration 0:   log likelihood = -12492.829  
Iteration 1:   log likelihood = -12301.184  
Iteration 2:   log likelihood =     -12157  
Iteration 3:   log likelihood = -12156.203  
Iteration 4:   log likelihood = -12156.202  

Fitting 2 component Negative Binomial-1 model:

Iteration 0:   log pseudolikelihood =  -12156.74  (not concave)
Iteration 1:   log pseudolikelihood = -12155.694  (not concave)
Iteration 2:   log pseudolikelihood = -12134.293  (not concave)
Iteration 3:   log pseudolikelihood = -12108.437  (not concave)
Iteration 4:   log pseudolikelihood = -12100.205  
Iteration 5:   log pseudolikelihood = -12095.077  
Iteration 6:   log pseudolikelihood = -12093.661  
Iteration 7:   log pseudolikelihood = -12092.693  
Iteration 8:   log pseudolikelihood =  -12092.43  
Iteration 9:   log pseudolikelihood = -12092.429  
Iteration 10:  log pseudolikelihood = -12092.429  

2 component Negative Binomial-1 regression        Number of obs   =       4406
                                                  Wald chi2(32)   =     805.15
Log pseudolikelihood = -12092.429                 Prob > chi2     =     0.0000

------------------------------------------------------------------------------
             |               Robust
         OFP |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
component1   |
    EXCLHLTH |  -.2290118   .0595272    -3.85   0.000    -.3456829   -.1123407
    POORHLTH |   .1499097    .058625     2.56   0.011     .0350068    .2648126
    NUMCHRON |   .1836232   .0145712    12.60   0.000     .1550641    .2121823
     ADLDIFF |  -.0520085   .0510709    -1.02   0.309    -.1521055    .0480886
     NOREAST |   .0546492   .0542024     1.01   0.313    -.0515856    .1608839
     MIDWEST |   .0191861    .045583     0.42   0.674    -.0701549    .1085271
        WEST |   .0944858    .047379     1.99   0.046     .0016248    .1873469
         AGE |   .0148273   .0308493     0.48   0.631    -.0456361    .0752908
       BLACK |  -.1799111   .0898293    -2.00   0.045    -.3559734   -.0038489
        MALE |  -.1377495   .0363032    -3.79   0.000    -.2089023   -.0665966
     MARRIED |   .0513625    .037287     1.38   0.168    -.0217187    .1244436
      SCHOOL |   .0133302   .0067885     1.96   0.050     .0000249    .0266354
      FAMINC |   .0007834   .0052861     0.15   0.882    -.0095773     .011144
    EMPLOYED |  -.0807253   .0543835    -1.48   0.138    -.1873149    .0258643
     PRIVINS |   .3593702   .0802377     4.48   0.000     .2021073    .5166331
    MEDICAID |   .4204549   .1516158     2.77   0.006     .1232933    .7176165
       _cons |   .7733975   .2661744     2.91   0.004     .2517052     1.29509
-------------+----------------------------------------------------------------
component2   |
    EXCLHLTH |  -.8178674   .3848952    -2.12   0.034    -1.572248   -.0634866
    POORHLTH |    .718358   .3416314     2.10   0.035     .0487726    1.387943
    NUMCHRON |   .1908478   .0934393     2.04   0.041     .0077101    .3739855
     ADLDIFF |    .549827   .2893593     1.90   0.057    -.0173069    1.116961
     NOREAST |   .2279207   .4032265     0.57   0.572    -.5623887     1.01823
     MIDWEST |  -.0123035   .4114692    -0.03   0.976    -.8187683    .7941612
        WEST |   .2660744   .2891064     0.92   0.357    -.3005636    .8327125
         AGE |  -.1334189    .237275    -0.56   0.574    -.5984694    .3316316
       BLACK |   .2680242   .7090175     0.38   0.705    -1.121625    1.657673
        MALE |  -.0228589   .1936876    -0.12   0.906    -.4024796    .3567618
     MARRIED |   -.242328   .1950364    -1.24   0.214    -.6245924    .1399364
      SCHOOL |   .1023137   .0435288     2.35   0.019     .0169988    .1876287
      FAMINC |  -.0011579   .0128741    -0.09   0.928    -.0263908    .0240749
    EMPLOYED |   .5400458    .441916     1.22   0.222    -.3260937    1.406185
     PRIVINS |    .227208   .6916896     0.33   0.743    -1.128479    1.582895
    MEDICAID |  -.6163631   1.171503    -0.53   0.599    -2.912467    1.679741
       _cons |   1.554799   2.130245     0.73   0.465    -2.620405    5.730003
-------------+----------------------------------------------------------------
 /imlogitpi1 |   2.290933   .3660583     6.26   0.000     1.573471    3.008394
   /lndelta1 |   1.259071    .059816    21.05   0.000     1.141834    1.376308
   /lndelta2 |   2.441911   .4394107     5.56   0.000     1.580682     3.30314
------------------------------------------------------------------------------
      delta1 |   3.522148    .210681                      3.132507    3.960255
      delta2 |   11.49499    5.05102                      4.858268    27.19791
         pi1 |   .9081233   .0305422                      .8282779    .9529519
         pi2 |   .0918767   .0305422                      .0470481    .1717221
------------------------------------------------------------------------------

. estimates store FMMorig 

. predict mu1, eq(component1)

. predict mu2, eq(component2)

. 
. * Altered and then original
. * sum mu1alt mu2alt mu1 mu2 
. estimates table FMMalt70 FMMorig, b(%10.3f) t(%10.2f) stats(ll aic bic N k)

----------------------------------------
    Variable |  FMMalt70     FMMorig    
-------------+--------------------------
component1   |
    EXCLHLTH |     -0.250       -0.229  
             |      -4.31        -3.85  
    POORHLTH |      0.234        0.150  
             |       3.59         2.56  
    NUMCHRON |      0.186        0.184  
             |      14.62        12.60  
     ADLDIFF |     -0.016       -0.052  
             |      -0.37        -1.02  
     NOREAST |      0.083        0.055  
             |       1.72         1.01  
     MIDWEST |      0.018        0.019  
             |       0.46         0.42  
        WEST |      0.089        0.094  
             |       1.82         1.99  
         AGE |      0.028        0.015  
             |       1.07         0.48  
       BLACK |     -0.079       -0.180  
             |      -1.12        -2.00  
        MALE |     -0.136       -0.138  
             |      -3.92        -3.79  
     MARRIED |      0.047        0.051  
             |       1.34         1.38  
      SCHOOL |      0.014        0.013  
             |       2.73         1.96  
      FAMINC |     -0.000        0.001  
             |      -0.06         0.15  
    EMPLOYED |     -0.059       -0.081  
             |      -1.04        -1.48  
     PRIVINS |      0.254        0.359  
             |       4.79         4.48  
    MEDICAID |      0.353        0.420  
             |       5.69         2.77  
       _cons |      0.778        0.773  
             |       3.48         2.91  
-------------+--------------------------
component2   |
    EXCLHLTH |     -0.751       -0.818  
             |      -1.02        -2.12  
    POORHLTH |      0.039        0.718  
             |       0.06         2.10  
    NUMCHRON |      0.139        0.191  
             |       1.33         2.04  
     ADLDIFF |      0.546        0.550  
             |       2.04         1.90  
     NOREAST |      0.178        0.228  
             |       0.37         0.57  
     MIDWEST |      0.042       -0.012  
             |       0.12        -0.03  
        WEST |      0.236        0.266  
             |       0.49         0.92  
         AGE |     -0.611       -0.133  
             |      -2.47        -0.56  
       BLACK |     -1.065        0.268  
             |      -0.98         0.38  
        MALE |      0.120       -0.023  
             |       0.46        -0.12  
     MARRIED |     -0.513       -0.242  
             |      -1.55        -1.24  
      SCHOOL |      0.152        0.102  
             |       1.84         2.35  
      FAMINC |     -0.005       -0.001  
             |      -0.27        -0.09  
    EMPLOYED |      0.372        0.540  
             |       0.54         1.22  
     PRIVINS |      3.020        0.227  
             |       1.12         0.33  
    MEDICAID |     -3.147       -0.616  
             |      -0.97        -0.53  
       _cons |      1.862        1.555  
             |       0.71         0.73  
-------------+--------------------------
imlogitpi1   |
       _cons |      2.334        2.291  
             |       6.73         6.26  
-------------+--------------------------
lndelta1     |
       _cons |      1.251        1.259  
             |      15.44        21.05  
-------------+--------------------------
lndelta2     |
       _cons |      2.797        2.442  
             |       6.86         5.56  
-------------+--------------------------
Statistics   |                          
          ll | -12076.909   -12092.429  
         aic |  24227.818    24258.858  
         bic |  24464.275    24495.315  
           N |       4406         4406  
           k |     37.000       37.000  
----------------------------------------
                             legend: b/t

. 
. *** Also compare regular NB1 across the two samples (mentioned in text) and FMN-NB2
. 
. * Original sample - FMM-NB2 and regular NB1 
. quietly fmm OFP $XLIST, components(2) mixtureof(negbin2) vce(robust)

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |   4406           .   -12139.31     37     24352.62    24589.08
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. quietly nbreg OFP $XLIST, dispersion(constant) vce(robust) 

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |   4406   -12492.83    -12156.2     18      24348.4    24463.44
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. 
. * Altered sample - FMM-NB2 and regular NB1 dispersion(constant)
. preserve 

. replace OFP = 70 if OFP > 70
(1 real change made)

. quietly fmm OFP $XLIST, components(2) mixtureof(negbin2) vce(robust)

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |   4406           .   -12138.46     37     24350.93    24587.38
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. quietly nbreg OFP $XLIST, dispersion(constant) vce(robust) 

. estat ic

-----------------------------------------------------------------------------
       Model |    Obs    ll(null)   ll(model)     df          AIC         BIC
-------------+---------------------------------------------------------------
           . |   4406    -12489.8   -12152.74     18     24341.48    24456.51
-----------------------------------------------------------------------------
               Note:  N=Obs used in calculating BIC; see [R] BIC note

. restore

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

. exit, clear
