Bookmark and Share

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: st: Stacked histogram - empty bins


From   "David Radwin" <dradwin@mprinc.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Stacked histogram - empty bins
Date   Fri, 29 Jul 2011 09:09:00 -0700 (PDT)

This topic of comparing distributions using multiple histograms has
appeared before, usually in the form of showing overlapping histograms.
See, e.g., http://www.stata.com/statalist/archive/2008-09/msg01336.html ,
http://www.stata.com/statalist/archive/2003-05/msg00653.html, or a couple
of examples on http://www.survey-design.com.au/Stata%20Graphs.html . There
are also numerous cautions against using histograms at all and ideas (like
Nick Cox's earlier suggestions) for alternative graph types.

I have occasionally wished for a "line histogram" that would just show a
line for the top and sides of each histogram without the other lines
defining each bar, similar in appearance to Stata's -kdensity- but with
right angles only (approximately like -kdensity- with the option
-kernel(rectangular)-). If I were a better programmer, I would write such
a program myself.

In the meantime, one more suggestion (but not quite what you want) is
Austin Nichols's -bihist- or -byhist-, both available from SSC.

David
--
David Radwin
Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: Thursday, July 28, 2011 3:21 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: Stacked histogram - empty bins
> 
> Evidently your example is Australian, with VIC = Victoria, WA =
> Western Australia, ACT = Australian Capital Territory. At a guess,
> small numbers with ACT bite hardest here.
> 
> But those details don't matter. Whenever small frequencies are being
> shown, there is often an advantage in using -dotplot- or -stripplot-
> (SSC). (Although not originally intended as such, -stripplot- is now
> in broad terms a superset of -dotplot-.)
> 
> Alternatively, lay down first a histogram of everything, then a
> histogram of WA + VIC, then a histogram of VIC.
> 
> But I'd still try -stripplot- first.
> 
> This is one command:
> 
> twoway histogram admissiondate if inlist(state, "VIC", "WA", "ACT"),
> start (`startdate') width(7) freq
> ||
> histogram admissiondate if inlist(state, "VIC", "WA"),
> start (`startdate') width(7) freq
> ||
> histogram admissiondate if inlist(state, "VIC"),
> start (`startdate') width(7) freq
> 
> You will want to fiddle with legend, colours, bar widths, etc. See also
> 
> N. J. Cox. 2009.
> Stata tip 78: Going gray gracefully: Highlighting subsets and
> downplaying substrates
> Stata Journal 9(3): 499--503.
> 
> 
> On Wed, Jul 27, 2011 at 11:55 PM, Allen Cheng <acscheng@gmail.com>
wrote:
> > I am trying to make a stacked histogram to show an epidemic in
different
> > states by epidemiological week. I found Nick Cox's helpful
instructions
> in 2006
> > using the undocumented command twoway__histogram_gen
> >
> > The problem is that some weeks, some states do not have any cases, and
> this
> > makes a mess of trying to line up where rbar starts and ends. Is there
> any
> > way to "force" zeros into the weeks with no cases?
> >
> > The commands I have tried are
> >
> > twoway__histogram_gen admissiondate if state=="VIC", gen(freq_vic
x_vic)
> > start (`startdate') width(7) freq
> > twoway__histogram_gen admissiondate if state=="ACT", gen(freq_act
x_act)
> > start (`startdate') width(7) freq
> > twoway__histogram_gen admissiondate if state=="WA", gen(freq_wa x_wa)
> start
> > (`startdate') width(7) freq
> > gen freq1=freq_vic+freq_act
> > gen freq2=freq_vic+freq_act+freq_wa
> > tw (bar freq_vic x_vic if freq1<., ylab(r(0 .))) (rbar freq_vic freq1
> > x_act if freq1<.)
> > (rbar freq1 freq2 x_wa if freq2<.), xtitle(date) ytitle(number of
cases)

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