Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Michael Barker <mdb96statalist@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Define nested logit with many choices |
Date | Wed, 14 Aug 2013 11:42:33 -0400 |
You can use the - levelsof - command to get a list of all restaurants in a given category: levelsof restaurant if rating==5, local(star5) separate( | ) gen star5 = restaurant==`star5' This gives you a list of restaurant numbers, not the actual names, which are just value labels. But nlogitgen works with actual values or value labels. An easier way would be to use the rating variable directly to define your categories: nlogitgen type = rating(high: 5 | 4 | 3, low: 2 | 1 | 0) By the way, if you make one group for each rating, you will just get back something equivalent to the original "rating" variable. Mike On Sat, Aug 3, 2013 at 5:23 PM, Mauricio Esteban Cuak <cuak2000@gmail.com> wrote: > Still looking for an answer to this, thanks! > > 2013/7/31 Mauricio Esteban Cuak <cuak2000@gmail.com>: >> Hi, >> >> I'm considering a problem with around 200 alternatives and around 4 >> nests each with, say, 50 alternatives. >> >> Consider the example in the help with the built-in dataset restaurant.dta >> >> ****** Begin Code ********** >> clear >> version 12 >> webuse restaurant.dta >> >> nlogitgen type = restaurant(fast: Freebirds | MamasPizza, family: >> CafeEccell | LosNortenos | WingsNmore, fancy: >> Christophers | MadCows) >> >> nlogit chosen cost distance rating || type: income kids, base(family) >> || restaurant:, noconst case(family_id) >> >> ****** End Code ************* >> >> Suppose however, that I want to define the nests by the variable >> "rating" (by which restaurants are classified), so that each nests >> contains all restaurants that have rating == x. >> In this particular case, it is easy to list all the restaurants that >> fit a certain rating, but what if I have (like in my case) 50 >> restaurants per rating level? >> >> I can manually input those restaurant names per category, but there >> must be an easier and less error prone way! >> Thanks for your time, >> >> ME >> * >> * 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/ > * > * 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/ * * 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/