Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re: st: detonator plot with three grouping variables
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: Re: st: detonator plot with three grouping variables
Date
Fri, 10 May 2013 12:46:17 +0100
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
[email protected]
On 10 May 2013 11:32, Seed, Paul <[email protected]> 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/