Statalist


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

Re: st: Randomly assigning values with a specific distribution


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Randomly assigning values with a specific distribution
Date   Mon, 5 Oct 2009 12:58:42 +0000 (GMT)

--- On Mon, 5/10/09, Dorothy Bridges wrote:
> I would like to create a random variable taking five
> different values
> whose distribution mirrors that of another variable. 
> In other words,
> I have one variable whose distribution is, say:
> 
> value      %
> x1         40
> x2         10
> x3         30
> x4         5
> x5         15
> 
> ... and I want to create another variable with the same
> values and distribution, but randomly assigned.  Something
> like
> gen randomvar =
> mydist() instead of uniform().

See: Maarten L. Buis (2007) Stata tip 48: Discrete uses for 
uniform() The Stata Journal Vol. 7 No. 3, pp. 434-435.

A pre-publication draft can be downloaded from:
http://www.maartenbuis.nl/publications/discrete.html

You can also buy a book full with 76 stata-tips:
http://www.stata.com/bookstore/tips2.html

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


Send instant messages to your online friends http://uk.messenger.yahoo.com 

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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