Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Unique Randomization within groups


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Unique Randomization within groups
Date   Thu, 31 Jan 2013 14:07:39 +0100

With your code you have drawn random numbers with replacement, what
you want is to draw without replacement, see:
http://blog.stata.com/2012/08/03/using-statas-random-number-generators-part-2-drawing-without-replacement/

Hope this helps,
Maarten

On Thu, Jan 31, 2013 at 1:14 PM, Jonah Rexer <[email protected]> wrote:
> Hello,
>
> I am doing a randomization among 3 groups (2 treatment and 1 control) for a
> micro experiment.
> Our sample is small, N=99 with the unit being a cluster (a group of 2-3
> respondents).
> I have merged clusters to assign each a random number. But instead of
> stratifying, since our sample is so small, I have organized each cluster
> into a group of 3 clusters (so 33 groups, each with 3 clusters) based on
> our stratification variables.
>
> What I want to do is assign a random integer, 1-3, within each group. I've
> used the command:
>
> set seed 4109
>
> bysort cluster_group : gen random1=floor((3-1+1)*runiform()+1)
>
> The problem is that this doesn't give me a unique number. Within each
> group, i need one observation (cluster) to be 1, one to be 2, and one to be
> 3. This is why I used bysort, but it doesn't seem to be making any
> difference. Is there any way to ensure that the number assigned is unique
> within the group?
> Thanks,
>
> Jonah Rexer
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index