Statalist


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

Re: st: creating two groups with identical distribution of one variable


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: creating two groups with identical distribution of one variable
Date   Wed, 14 Oct 2009 21:48:34 +0000 (GMT)

--- On Wed, 14/10/09, Michael McCulloch wrote:
> Using the following simulation, I create two groups: #1 =
> mean age 50, #2 = mean age 60.
> I'm seeking some guidance on how to create variable
> newgroup, such that newgroup A and B will have equal age
> distribution.

What about this:

*-------------- begin example --------------------
clear
set obs 1000
gen group=1
replace group=2 in 501/1000
gen id=_n
set seed 12358
gen age = 50+10 * invnorm(uniform()) if group==1
replace age = 60+10 * invnorm(uniform()) if group==2
hist age, by(group)
gen newgroup = runiform() < .5
table newgroup, c(mean age)
*---------------- end example ----------------------

Hope this helps,
Maarten

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

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



      

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