Statalist


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

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


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: AW: creating two groups with identical distribution of one variable
Date   Thu, 15 Oct 2009 14:46:13 +0200

<> 

Well, I am not 100% sure what your intention is (does the code that you
showed have any real bearing on what follows for the creation of groups "A"
and "B"?). Still, as Maarten said last night:


*************
clear

set obs 1000
gen id=_n
gen byte group= /* 
*/ (id<=500)+(id>500)*2

set seed 12358
gen age= /* 
*/ 50+10*(group==2)+ /* 
*/ 10*invnorm(uniform())

hist age, by(group)

gen byte newgroup= /* 
*/ (runiform()<.5)
la def gr 0 "A" 1 "B"
la val newgroup gr

table newgroup,  /* 
*/ c(freq mean age sd age)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Michael
McCulloch
Gesendet: Mittwoch, 14. Oktober 2009 22:57
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: AW: creating two groups with identical distribution of one
variable

Sorry Martin, yes I intended to say equal to each other, as in:

"I'm seeking some guidance on how to create variable newgroup,  such  
that newgroup A and B will be equal to each other in age distribution."



On Oct 14, 2009, at 1:46 PM, Martin Weiss wrote:

>
> <>
>
> " such that newgroup A and B will have equal age distribution"
>
>
>
> What do you mean? "Equal" to what? To each other or to groups "1"  
> and "2"?
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Michael
> McCulloch
> Gesendet: Mittwoch, 14. Oktober 2009 22:41
> An: Statalist Statalist
> Betreff: st: creating two groups with identical distribution of one  
> variable
>
> 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
> mm@pinestreetfoundation.org
>
>
>
>
>
>
> *
> *   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/
>
>
> *
> *   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/



Michael McCulloch
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391
mm@pinestreetfoundation.org









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


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