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]

st: Stacked histogram - empty bins


From   Allen Cheng <[email protected]>
To   [email protected]
Subject   st: Stacked histogram - empty bins
Date   Thu, 28 Jul 2011 08:55:27 +1000

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)

Thanks
Allen Cheng
*
*   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