Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# RE: Re: st: detonator plot with three grouping variables

 From "Seed, Paul" To "statalist@hsphsun2.harvard.edu" Subject RE: Re: st: detonator plot with three grouping variables Date Fri, 10 May 2013 10:32:50 +0000

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

**************** End example code ***************

Paul T Seed, Senior Lecturer in Medical Statistics,
Division of Women's Health, King's College London
Women's Health Academic Centre, King's Health Partners
(+44) (0) 20 7188 3642.

> Date: Thu, 9 May 2013 11:49:03 +0100
> From: Nick Cox <njcoxstata@gmail.com>
> Subject: Re: st: detonator plot with three grouping variables
>
> I agree strongly with David.
>
> I think I heard the term "detonator plots" from Stata user and
> Statalist member Paul Seed at a users' meeting several years ago. He
> may care to comment on whether it's his coinage.
>
> Independently of that, and echoing David, it's my impression that the
> term "dynamite plot" is more common.
>
> Naturally what you call the beast is not central here, but it is
> germane in so far as searching for "dynamite plot" on the internet
> yields good discussions such as
>
> http://biostat.mc.vanderbilt.edu/twiki/pub/Main/TatsukiRcode/Poster3.pd
> f
>
> The key issues are (to me)
>
> 1. Such plots omit detail which you should care about showing (when
> it's your data) or examining (always).
>
> 2. The visual signal strongly emphasises mean values relative to zero,
> by the solid or thick bars, and plays down uncertainty, shown by the
> intervals. Comparison with zero can be an important comparison, but
> it's often not of scientific interest or concern.
>
> - -stripplot- (SSC) which allows error bars to be shown with raw data.
>
> In terms of what Ronnie wants to do in Stata, his question is
> puzzling, because the UCLA FAQ he cites explains in detail that -graph
> bar- is a dead end here and you must switch to -twoway bar-.
>
> Nick
> njcoxstata@gmail.com
>
> On 9 May 2013 04:47, David Hoaglin <dchoaglin@gmail.com> wrote:
> > Ronnie,
> >
> > A good first step would be to omit the bars entirely.  Freeman et al.
> > (2008) discuss that type of plot under the name "dynamite plunger
> > plot" in their chapter "How to display data badly."  The bars take up
> > space to no good purpose.  A more effective plot would show the
> > estimates with error bars or confidence intervals (and an explanation
> > of whether the intervals are error bars or confidence intervals).
> >
> > David Hoaglin
> >
> > Freeman JV, Walters SJ, Campbell MJ (2008). How to Display Data.  BMJ
> Books.
> >
> > On Wed, May 8, 2013 at 5:49 PM, Ronnie Babigumira
> <rb.glists@gmail.com> wrote:
>
> >> I am trying to create a detonator plot like the one in this example
> http://www.ats.ucla.edu/stat/stata/faq/barcap.htm only I have 3 levels.
> Here is an example using the accessible auto data
> >>
> >> sysuse auto, clear
> >> egen lwst = fill(1,2,1,2)
> >> recode rep78 (1 2 = 3)
> >>
> >> What I would like to do is add error bars to this plot
> >>
> >> graph bar price, over(lwst) over(foreign) over(rep78)
> >>
> >> Any help is much appreciated
> >>

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