Monday, February 20, 2006

st: RE: nested logit model

The Stata manual example somehow evokes the cuisine available in College Station, TX, modulo MadCows.

Richard Gates has already answered your main question. I just to comment on a detail as below. Another way to get these variables is with a loop:

forval i = 1/6 { gen kid`i' = (restaurant == `i') * kids }

Another way is by

separate kids, by(restaurant) gen(kid) mvencode `r(varlist)', mv(0)

Your code is fine and clear (and, notably, going to be no more efficient than either of the above). But other ways of doing it may be of interest to those who look at an example like this and think "Surely there is another way to do this!".

Nick n.j.cox@durham.ac.uk

Matthias Grueninger > 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

* * 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/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?