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   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Three-way (or more) histograms in Stata
Date   Tue, 9 Oct 2012 15:03:56 +0100

There is scope to go

. twoway histogram ..., recast(line)

Alternatively, as recently mentioned more than once on this list,  you
can fire up -twoway__histogram_gen-
to generate variables, then plot the results over each other.

SJ-5-2  gr0014  . . . . . . . Stata tip 20: Generating histogram bin variables
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . D. A. Harrison
        Q2/05   SJ 5(2):280--281                                 (no commands)
        tip illustrating the use of twoway__histogram_gen for
        creation of complex histograms and other graphs or tables

I wouldn't go either way personally. I would consider using -kdensity-
to generate different densities, then superimpose, or look at a
quantile plot using -qplot- (SJ).

On Tue, Oct 9, 2012 at 2:45 PM, 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?
>

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