Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: detonator plot with three grouping variables


From   Ronnie Babigumira <rb.glists@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: detonator plot with three grouping variables
Date   Mon, 13 May 2013 15:26:58 +0200

Many thanks to all who contributed to this thread, you suggestions/answers were most helpful.

Best regards

Ronnie
-- 
010100100110111101101110011011100110100101100101

On May 10, 2013, at 1:46 PM, Nick Cox <njcoxstata@gmail.com> wrote:

> Thanks for the confirmation on the coinage of "detonator plot".
> Whoever coined "dynamite plot" was quite possibly inspired by the same
> kind of movie experience.
> 
> Your detailed code is very welcome for showing real possibilities. As
> the author of -stripplot- (SSC) I can add a footnote.
> 
> It is true that -stripplot- does not support more than one -over()-
> option, but it does support -by()- and that can serve a similar
> purpose. Thus producing separate -stripplot-s can be avoided to a
> large extent. In place of the closing loop here is some alternative
> code
> 
> egen group = group(lwst foreign), label
> 
> #delimit ;
> stripplot price, over(rep_78_) bar(mean(ms(smx) msize(huge) )
> msize(vhuge) level(68))
>                         vertical centre jitter(2) boffset(0)
>                         ylabel(0(5000)20000, ang(h)) by(group, note("")) ;
> 
> Nick
> njcoxstata@gmail.com
> 
> 
> On 10 May 2013 11:32, Seed, Paul <paul.seed@kcl.ac.uk> wrote:
>> As far as I know, "detonator plots" is my coinage;
>> as they look more like the old-fashioned
>> detonators with T-shaped plungers that you sometimes saw in
>> silent movie melodramas.
>> 
>> Reminiscing aside, there has been an emphasis recently (as Nick mentions)
>> on showing actual values as well as error bars.  The code below shows how to do
>> this using -stripplot-, with the auto data
>> 
>> ****************** Begin example code ****************
>> clear
>> sysuse auto
>> 
>> * With mean & SE
>> #delim ;
>> stripplot mpg, over( foreign) bar(mean(ms(smx) msize(huge) ) msize(vhuge) level(68)) vertical centre jitter(2) boffset(0);
>> #delim cr
>> more
>> 
>> * With mean & 95% CI
>> #delim ;
>> stripplot mpg, over( foreign) bar(mean(ms(smx) msize(huge) ) msize(vhuge) level(95)) vertical centre jitter(2) boffset(0);
>> #delim cr
>> more
>> 
>> * With median quartiles & 95% RR
>> #delim ;
>> stripplot mpg, over( foreign) vertical centre jitter(2) box pctile(97.5);
>> #delim cr
>> more
>> 
>> * Ronnie Babigumira wrote:
>> * What I would like to do is add error bars to this plot
>> egen lwst = fill(1,2,1,2)
>> clonevar rep_78_ = rep78
>> recode rep_78_ (1 2 = 3)
>> label define rep_78_  3  "1-3"
>> label values rep_78_  rep_78_
>> 
>> graph drop _all
>> 
>> graph bar price, over(lwst) over(foreign) over(rep_78_) name(old_graph)
>> 
>> * stripplot price, over(lwst) over(foreign) over(rep78) bar(mean(ms(smx) msize(huge) ) msize(vhuge) level(68)) vertical centre jitter(2) boffset(0)
>> * fails, as stripplot takes only one -over()- option
>> 
>> * His basic graph is
>> * stripplot price if lwst == `l' & foreign ==`f' , over(rep78) bar(mean(ms(smx) msize(huge) ) msize(vhuge) level(68)) vertical centre jitter(2) boffset(0)
>> 
>> * This needs to be repeated for all values of lwst and foreign and then joined together
>> 
>> 
>> levelsof lwst, local( lwst)
>> levelsof foreign, local(foreign)
>> local g_all
>> foreach l of local lwst {
>>        local g_`l'
>>        foreach f of local foreign {
>>                local yscale
>>                #delim ;
>>                stripplot price if lwst == `l' & foreign ==`f'
>>                        , over(rep_78_) bar(mean(ms(smx) msize(huge) ) msize(vhuge) level(68))
>>                        vertical centre jitter(2) boffset(0) name(g_`l'_`f')
>>                        ylabel(0(5000)20000) b1title("Foreign == `f'") `yscale'
>>                ;
>>                #delim cr
>> 
>>                local yscale yscale(off)
>>                local g_`l' `g_`l''  g_`l'_`f'
>>        }
>>        graph combine `g_`l'', name(g_`l') rows(1) ycommon b1title("lwst == `l'")
>>        more
>>        graph drop `g_`l''
>>        local g_all `g_all' g_`l'
>> }
>> graph combine `g_all', name(g_all) rows(1)
>> more
> *
> *   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/


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index