Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

 From Lanlan Wang To statalist@hsphsun2.harvard.edu Subject st: about nlogit model Date Thu, 5 Apr 2012 20:37:09 +0800

```Dear all,

I am stuck with nested logit model and don't know whether it is a
command or database problem.

I try to look at which factors may have relationship with individual
choices of the transportation mode in their home-to-work trips.
Transportation modes in the data include: car, walk, bicycle, bus,
subway, and other. Based on these alternatives, the structure of the
decision tree looks like:

/\
/  \
/    \
car   /\
/  \
(walk, bicycle, bus, subway, other)

The factors which may have relationship with individual mode choice
are classified into four types:
1) whether the individual owns a car (owncar)
2) trip-related factors (such as trip distance, travel cost, etc.)
3) individual and family characteristics (age, gender, per capita income, etc.)
4) accessibility factors (such as how many bus stops around the
origination and destination places, distance to the closest subway
stations, etc.)

The data structure is like:

TripID   Mode    decision    owncar       cost       tripdistance    age
1            1             0               1         103
20.5            37
1            2             1               1         20
20.5            37
1            3             0               1         87
20.5            37
1            4             0               1         32
20.5            37
1            5             0               1         67
20.5            37
1            6             0               1         54
20.5            37
2            1             0               0         77             12
23
2            2             0               0         12             12
23
2            3             1               0         50             12
23
2            4             0               0         32             12
23
2            5             0               0         40             12
23
2            6             0               0         42             12
23
3            1             0               0         40             9
46

I used stata 12 and program is:

nlogitgen tree = mode(car:2, nonauto:1|3|4|5|6)
nlogittree mode tree, choice(decision)

tree            N             mode          N        k
---------------------------------------
car              37169 ---  2            35215  6350
nonauot    223014 ---  1            35215  5759
|- 3            35215 11766
|- 4            35215  4549
|- 5            35215  5332
|- 6            35215  1459
---------------------------------------
total          211290 35215

----------------------------------------
constraint 1 [car_tau]_cons=1
nlogit decision cost tripdistance individual-family-characteristics
accessibility-factors || tree:
owncar, base(nonauto) || mode:, case(tripid) constraints(1)
-----------------------------------------------
stata gave me the following information:

-------------------------------------------------------
"note: 1 case (210106 obs) dropped due to no positive outcome or
multiple positive outcomes per case
no cases remain after removing invalid observations"
-------------------------------------------------------

I double checked the "case", and for each case, there is only one mode
selected (and the value of (choice) for other mode alternatives is
equal to zero).

I don’t know what I’m doing wrong. Can anyone help me please?

Thank you very much,

lanlan

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```