Statalist The Stata Listserver


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

st: Re: RE: Re: generating random variable


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: RE: Re: generating random variable
Date   Tue, 03 Apr 2007 15:12:52 -0400

The choice is random as coded -- that's why the code generates a random number and uses that in the sort. I guess you need a way to actually track where it was in the sort order to begin with..

expand 2
gen random=uniform()
gen choicenum=_n
bysort id bl set (random): gen byte choice=_n==_N

Now you can see that the choice is set randomly to one of the two values of choicenum in each set.

Michael

----- Original Message ----- From: "Mentzakis, Emmanouil" <[email protected]>
To: <[email protected]>
Sent: Tuesday, April 03, 2007 1:50 PM
Subject: st: RE: Re: generating random variable



Thank you Michael,

What you proposed creates what I want apart from the fact that it does
not have the random assignment.

However, I think that I kind of need that. What I am trying to do is to
create individuals' choices from a choice experiment. Each individual
faces 3 questions (sets), which themselves consist of two alternatives.
If I was to always assign the "one" of the "choice" variable in the
second alternative that would mean that the individuals always choose
that alternative, which sound strange.

I know that it does not really matter, how I assign it since this is
just an exercise with simulated data but I was wondering if you could
think of a way to make the choice random.

Thanks a lot
Manos

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