Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Variable has replicate levels in nested logit


From   Raluca Prelipceanu <[email protected]>
To   [email protected]
Subject   st: Variable has replicate levels in nested logit
Date   Tue, 4 Dec 2012 15:18:17 +0100

I  run the following nlogit and get the error: variable has replicate
levels at the end. Could you help me with this matter?

Thank you.


expand 4
(1347111 observations created)

. sort  familyid

. gen alt=mod(_n, 4)

. gen nomig=(alt==1)

. gen sotmig=(alt==2)

. gen sotiemig=(alt==3)

. gen bothmig=(alt==4)

. ta  coupmig

    coupmig |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |  1,774,208       98.78       98.78
          1 |     15,260        0.85       99.63
          2 |      2,376        0.13       99.76
          3 |      4,304        0.24      100.00
------------+-----------------------------------
      Total |  1,796,148      100.00

. gen coupmig2=1 if coupmig==0
(21940 missing values generated)

. replace coupmig2=2 if coupmig==1
(15260 real changes made)

. replace coupmig2=3 if coupmig==2
(2376 real changes made)

. replace coupmig2=4 if coupmig==3
(4304 real changes made)

. gen choice=(coupmig2==alt)

. replace alt=4 if alt==0
(449037 real changes made)

. ta alt

        alt |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |    449,037       25.00       25.00
          2 |    449,037       25.00       50.00
          3 |    449,037       25.00       75.00
          4 |    449,037       25.00      100.00
------------+-----------------------------------
      Total |  1,796,148      100.00

. gen choice=(coupmig2==alt)

. ta choice

     choice |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |  1,347,147       75.00       75.00
          1 |    449,001       25.00      100.00
------------+-----------------------------------
      Total |  1,796,148      100.00

. nlogitgen typedeg=coupmig2(nomig:1, somemig:2|3|4)
new variable typedeg is generated with 2 groups
label list lb_typedeg
lb_typedeg:
           1 nomig
           2 somemig

. nlogittree coupmig2 type, choice(choice)

tree structure specified for the nested logit model

 typedeg    N        coupmig2    N      k
---------------------------------------------
 nomig   1774208 --- 1        1774208 443538
 somemig   21940 --- 2          15260   3802
                  |- 3           2376    591
                  +- 4           4304   1070
---------------------------------------------
                       total  1796148 449001

k = number of times alternative is chosen
N = number of observations at each level
nlogit choice sot_age sot_education hychild hschild  || type: rural
windex ||coupmig2: nwomenduty acrate, noconstant
>  case( ro02a_dwnum)
note: 24218 cases (197748 obs) dropped due to no positive outcome or
multiple positive outcomes per case
variable coupmig2 has replicate levels
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index