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


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: Stacked histogram - empty bins
Date   Sun, 31 Jul 2011 09:31:52 +0100

I can't reproduce this reported anomaly

. set obs 100
. gen date = ceil(10 * runiform())
. format date %d
. stripplot date
. stripplot date, stack
. gen group = _n > 50
. stripplot date, over(group)
. stripplot date, over(group) stack

-stripplot- is from SSC.

Nick


On Sun, Jul 31, 2011 at 1:52 AM, Allen Cheng <acscheng@gmail.com> wrote:
> Thanks for everyone for your replies. Yes, these are Australian data.
>
> "stripplot" (with the "stack" option) worked quite well and is clearer
> than a conventional histogram, with the added bonus of the "separate"
> option. To force the bins to start from a set date, I manually
> assigned then into bins. If you reduce the h and use square markers,
> it looks like a histogram.
>
> gen dategroup=(floor((admissiondate-`startdate')/7)*7)+`startdate'
> stripplot dategroup, over(state) stack width(7) h(.6) ms(S S S)
> xlabel(`startdate'(14)`currdate',format (%d) ang(45))
>
> I note that in stripplot without the stack option the x axis is
> automatically labelled in date format, but if you use the stack
> option, you have to specify the date format.
>
> Thanks again
> Allen Cheng
>
> On Thu, Jul 28, 2011 at 8:55 AM, 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)
>>
>> Thanks
>> Allen Cheng
>>
>
>
>
> --
> Allen Cheng
> Associate Professor in Infectious Diseases Epidemiology
> Department of Epidemiology and Preventive Medicine
> Monash University
>
> Infectious Diseases Physician
> Alfred Hospital
>
> Honorary Principal Research Fellow
> Menzies School of Health Research
> *
> *   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/
>

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