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: Three-way (or more) histograms in Stata


From   William Buchanan <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Three-way (or more) histograms in Stata
Date   Tue, 9 Oct 2012 07:08:54 -0700

Hi Tim,

Did you consider -kdensity-? You can overlay multiple plots using -tw- with it as well.

HTH,
Billy

Sent from my iPhone

On Oct 9, 2012, at 6:45, Tim Evans <[email protected]> wrote:

> Hi all,
> 
> I am trying to generate histograms (in Stata 11.2) with age distributions for three categories overlaid in the same graph for different periods. Essentially I want to visually check whether the age distribution of the cohort in an age group changes between periods, and whether the distribution of sub groups of the population also change. 
> 
> I started off with -histogram- because this nicely collapses my patient level data, without me having to do this manually. However, while I found twoway to be an option to increase the number of series plotted on the graph, I guess what I'm really after are line plots which would allow transparency between the series.
> 
> I'm using the followinhg code to present single categories of interest (but for each level in my age group) and use the -by()- to present all periods on one combined graph (separate for each age group)
> 
> levelsof age_grp, local(levels)
> foreach l of local levels {
> histogram Age_At_Diag if age_grp==`l' & yydx!=., discrete percent /*
> */ yscale(range(20)) /* 
> */ ylabel(0(5)20 , gmax  angle(horizontal) format(%3.0f)) /*
> */ xtitle("Age at diagnosis") /*
> */ by(period, row(1) note("Graphs by period of diagnosis in `: label (age_grp) `l'' age group") /*
> */ t1title("Age distribution by diagnosis period",  size(medsmall)) legend(off)) /*
> */ name(graph`l', replace) 
> graph export Age_grp_distribution_`: label (age_grp) `l''.png, replace
> 
> }
> 
> 
> My questions are: 
> 
> Can I ask -histogram- to plot lines rather than bars?
> Can -histogram- (with lines if possible) plot more than 2 series of data
> 
> If -histogram- will not do this, what is a better method of doing this?
> 
> Best wishes
> 
> Tim
> _DISCLAIMER:
> This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.
> 
> 
> *
> *   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/

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index