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/