Statalist


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

st: Randomly assigning values with a specific distribution


From   Dorothy Bridges <dbstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Randomly assigning values with a specific distribution
Date   Mon, 5 Oct 2009 08:50:01 -0400

Dear Statalist:

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().

Thanks,
Dorothy
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index