Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: nested logit model


From   [email protected] (Richard Gates)
To   [email protected]
Subject   Re: st: nested logit model
Date   Mon, 20 Feb 2006 09:49:36 -0600

Matthias inquired about a -nlogit- model specification:

> I have some problems with the estimations of a nested logit model with
> stata (version 9).
> 
> In contrast to the example in the stata documentation, I want to use some
> (individual-specific variables)
> at both levels of my nested logit model. Unfortunately, stata omits some
> values (standard
> errors, p-values...) of some coefficient as soon as I use the same
> explanatory variables
> on two instead of one level.
> 
> The example from the stata guide works like this:
> 
> webuse restaurant
> nlogitgen type=restaurant(fast:Freebirds|MamasPizza, family:
> CafeEccell|LosNortenos|WingsNmore, fancy: Christophers|MadCows)
> gen incFast=(type==1)*income
> gen incFancy=(type==3)*income
> gen kidFast=(type==1)*kids
> gen kidFancy=(type==3)*kids
> 
> nlogit chosen(restaurant=cost rating distance) (type=incFast incFancy
> kidFast kidFancy), group(family_id) nolog
> 
> 
> If I try to extend the stata example by using one of the
> individual-specific variables (kids) on both level, I get problems:
> 
> gen kid1=(restaurant==1)*kids
> gen kid2=(restaurant==2)*kids
> gen kid3=(restaurant==3)*kids
> gen kid4=(restaurant==4)*kids
> gen kid5=(restaurant==5)*kids
> gen kid6=(restaurant==6)*kids
> 
> nlogit chosen(restaurant=cost rating distance kid1-kid6) (type=incFast
> incFancy kidFast kidFancy), group(family_id) nolog
> 
> With this model specification I do not get standard errors and p-values for
> the variables kidFast and kidFancy.
> 
> - Does someone know how it is possible to estimate a nested logit model in
> stata with the same explanatory variable on different variables?
> 

The problem here is that the kidFast variable is the same a kid1 + kid2

. gen int kid11 = kid1+kid2

. di reldif(kid11, kidFast)
0

so the model is over specified.  Try dropping kid2 from the model
and I believe you will also need to drop one of the kid# variables 
from the family branch from the model. Below I dropped kid5 from
the family branch.

. nlogit chosen(restaurant=cost rating distance kid1 kid3 kid4 kid6) 
> (type=incFast incFancy kidFast kidFancy),
>  group(family_id) tech(nr) shownrtol

tree structure specified for the nested logit model

        top --> bottom

        type    restaurant  
--------------------------
        fast     Freebirds  
                MamasPizza  
      family    CafeEccell  
                LosNorte~s  
                WingsNmore  
       fancy    Christop~s  
                   MadCows  

initial:       log likelihood = -540.55268
rescale:       log likelihood = -512.70444
rescale eq:    log likelihood = -506.52097
Iteration 0:   log likelihood = -506.52097  (not concave)
Iteration 1:   log likelihood = -495.08828  (not concave)
Iteration 2:   log likelihood = -488.63901  (not concave)
Iteration 3:   log likelihood =  -485.4273  (not concave)
Iteration 4:   log likelihood = -484.46353  (not concave)
Iteration 5:   log likelihood = -483.74091  (not concave)
Iteration 6:   log likelihood = -483.46418  (not concave)
Iteration 7:   log likelihood = -483.29151  (not concave)
Iteration 8:   log likelihood = -483.20039  
Iteration 9:   log likelihood = -483.01382  
Iteration 10:  log likelihood = -483.01106  
Iteration 11:  log likelihood =  -483.0108  
Iteration 12:  log likelihood =  -483.0108  
               g inv(H) g'    =  3.797e-12

Nested logit regression
Levels             =          2                 Number of obs      =      2100
Dependent variable =     chosen                 LR chi2(14)        =  201.5245
Log likelihood     =  -483.0108                 Prob > chi2        =    0.0000

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
restaurant   |
        cost |   -.085732   .0345972    -2.48   0.013    -.1535412   -.0179228
      rating |   .3749732   .1581017     2.37   0.018     .0650996    .6848468
    distance |  -.1554523   .0510703    -3.04   0.002    -.2555482   -.0553564
        kid1 |   .0362515   .1055775     0.34   0.731    -.1706766    .2431795
        kid3 |   .0273874   .0526962     0.52   0.603    -.0758953    .1306701
        kid4 |  -.0687169   .0699435    -0.98   0.326    -.2058037    .0683699
        kid6 |   .1127797   .1138542     0.99   0.322    -.1103704    .3359298
-------------+----------------------------------------------------------------
type         |
     incFast |  -.0279577   .0115713    -2.42   0.016    -.0506371   -.0052783
    incFancy |   .0450274   .0088896     5.07   0.000     .0276041    .0624506
     kidFast |  -.1929279   .3185084    -0.61   0.545    -.8171929    .4313372
    kidFancy |   -.534186   .2317833    -2.30   0.021     -.988473    -.079899
-------------+----------------------------------------------------------------
(incl. value |
 parameters) |
type         |
       /fast |   5.830438   2.651674     2.20   0.028     .6332521    11.02762
     /family |   1.970546   1.459654     1.35   0.177     -.890323    4.831415
      /fancy |   2.039541   .9848676     2.07   0.038     .1092357    3.969846
------------------------------------------------------------------------------
LR test of homoskedasticity (iv = 1): chi2(3)=    8.67    Prob > chi2 = 0.0341
------------------------------------------------------------------------------


-Rich
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index