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 on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: overlaid histograms


From   André Ferreira Coelho <andre.f.coelho2011@novasbe.pt>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: overlaid histograms
Date   Tue, 20 Nov 2012 21:19:07 +0100

Hello, 

 
I am trying to generate some overlay histograms for my research thesis
containing only values within a given range. 

I wrote: 


graph twoway histogram var1 [if], options || histogram var2 [if], options

restraining variables domain in [if] or using inrange function.


Although, by doing this I am excluding all the values that are outside the
range I have defined which will bias the true heights for each bin. 

I tried to use instead the following for instance (found at
http://www.stata-journal.com/sjpdf.html?articlenum=gr0014):


twoway__histogram_gen var1 [if], bin(40) gen(h1 x1)

twoway__histogram_gen var2 [if], bin(40) gen(h2 x2) 

twoway (bar h1 x1 if inrange(x1,-20,20), barw(1) fcolor(none)
lcolor(edkblue)) (bar h2 x2 if inrange(x2,-20,20), barw(1) fcolor(none)
lcolor(cranberry)) 


Which is supposed to return an overlaied histogram with the right
densities, in this case.  

Nonethless, the variables generated x1, x2, h1 and h2 contain only few
observations (approximately equal to zero) and the corresponding plot is
empty. 

Do you have any suggestion how should I fix this in order to obtain
overlaid histograms without disregarding values outside the interval I want
to consider? 


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