Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: nested logit model


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: nested logit model
Date   Mon, 20 Feb 2006 16:27:53 -0000

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 
[email protected] 

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index