|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: creating two groups with identical distribution of one variable
From |
Michael McCulloch <[email protected]> |
To |
Statalist Statalist <[email protected]> |
Subject |
st: creating two groups with identical distribution of one variable |
Date |
Wed, 14 Oct 2009 13:41:09 -0700 |
Hello Statalist folks,
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.
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)
Michael McCulloch
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel: 415-407-1357
fax: 206-338-2391
[email protected]
*
* 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/