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

# st: help with nested logit

 From Raluca Prelipceanu To statalist@hsphsun2.harvard.edu Subject st: help with nested logit Date Mon, 3 Dec 2012 11:09:31 +0100

```Hello,

I am having trouble estimating a nested logit model. I have a variable
taking values from 1 to 5. I have a first level choice between paid
work vs. unpaid work and then if I choose paid I can choose 2, 3, 4,
5. Unpaid is 1. I create my variable choice, but then when I look at
my tree structure there is something very odd. For option 5 I get k=0.
Is it normal or did I do something wrong when I built my variable? The
example follows.

Thank you very much for your help.

Raluca

ta newmig

newmig |      Freq.     Percent        Cum.
------------+-----------------------------------
1 |     82,805       33.78       33.78
2 |    141,665       57.79       91.57
3 |     16,645        6.79       98.36
4 |      2,150        0.88       99.24
5 |      1,865        0.76      100.00
------------+-----------------------------------
Total |    245,130      100.00
expand 5
(196104 observations created)

. sort id

. gen alt=mod(_n, 5)

. replace alt=1 if alt==0

. gen nw= (alt==1)

. gen wnm=(alt==2)

. gen wms=(alt==3)

. gen wml=(alt==4)

. gen wab=(alt==5)

. gen choice=(newmig==alt)

. nlogitgen type=newmig(unpaid:1, paid:2|3|4|5)
new variable type is generated with 2 groups
label list lb_type
lb_type:
1 unpaid
2 paid

. nlogittree newmig type, choice(choice)

tree structure specified for the nested logit model

type     N        newmig   N      k
---------------------------------------
unpaid  82805 --- 1       82805 33122
paid   162325 --- 2      141665 28333
|- 3       16645  3329
|- 4        2150   430
+- 5        1865     0
---------------------------------------
total  245130 65214

k = number of times alternative is chosen
N = number of observations at each level
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```