Statalist


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

Re: AW: AW: AW: AW: st: Re: graph question


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: AW: AW: AW: AW: st: Re: graph question
Date   Mon, 20 Apr 2009 13:22:42 +0000 (GMT)

--- On Mon, 20/4/09, Martin Weiss wrote:

> Let me think about combining those two w/o overlapping...

What about this:

*---------------- begin example ---------------------
clear*

qui{
//create data
set obs 600

gen arm= cond(_n<301,0,1)
lab def arms 0 "control" 1 "experimental"
la val arm arms

egen float interval = fill(0 1 3 6 9 12 0 1 3 6 9 12)
egen float measurement = seq(), from(1) to(50) block(6)

//fictional value of measurement (no systematic diff btw control and experimental group)
gen mymeasurement=rchi2(3)
}

//check
mean mymeasurement, over(arm interval)

//collapse
collapse (mean) mean=mymeasurement (semean) semean=mymeasurement, by(arm interval)
gen lb= mean-invnormal(0.975)*semean
gen ub= mean+invnormal(0.975)*semean


gen interval2 = cond(arm == 1, interval + .25, interval - .25)
twoway bar mean interval2, barwidth(.4) || ///
       rcap lb ub interval2,               ///
       xlabel(0 1 3 6 9 12)                ///
       xmlabel( -.25 "c"   .25 "e"         ///
                 .75 "c"  1.25 "e"         ///
                2.75 "c"  3.25 "e"         ///
                5.75 "c"  6.25 "e"         ///
                8.75 "c"  9.25 "e"         ///
               11.75 "c" 12.25 "e" )       ///
       legend(off)
*------------------- end example -------------------

Hope this helps,
Maarten

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

http://home.fsw.vu.nl/m.buis/
-----------------------------------------





      

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