Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: histogram


From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   Re: st: histogram
Date   Wed, 4 Apr 2007 09:28:34 -0700 (PDT)

-kdensity- is another option.

. twoway (kdensity weight if foreign==1) (kdensity weight if
foreign==0), legend(lab(1 "Foreign") lab(2 "Domestic"))

Friedrich

--- Svend Juul <[email protected]> wrote:
> Ali wrote:
> I need to see the effect of a binary exposure variable on the
> distribution of
> birthweight. I expect that there is a shift in the ditribution and
> want to show
> this shift by producing a histogram which shows the distribution of
> exposed and
> unexposed seperately but on the same plot. Is there a code that can
> do this in
> Stata?
> 
> ----------------------------------------------------------
> To be precise: I think you ask for two PLOTS (histograms) on the
> same GRAPH,
> i.e. in the same coordinate system. Let's use the auto dataset,
> although it
> is about carweights, not babyweights.
>  
> Friedrichs suggestion:
>  
>    sysuse auto , clear
>    histogram weight , by(foreign)
>  
> I don't think that is what you wanted, but we may come closer by
> putting the
> two graphs in one column:
>  
>    histogram weight , by(foreign , col(1))
>  
> I would improve it, (1) by removing a rather useless note, (2) by
> controlling
> the bins, and (3) by displaying frequency rather than density:
>  
>    histogram weight , frequency start(1500) width(500) by(foreign ,
> col(1) note(""))
>  
> If you really want the two groups within the same coordinate
> system, I don't
> see how -histogram- can do it, but we can make -graph bar- do this:
>  
>    egen weightgr = cut(weight) , at(1500(500)5000)
>    generate x=1
>    graph bar (sum) x , over(foreign) over(weightgr) asyvars
>  
> I don't think it is better than the histogram solution. But there
> is another
> good solution with -dotplot- (it is described in the [R] manual):
>  
>    dotplot weight , over(foreign) center
>  
> Hope this helps
> Svend
>  
> ________________________________________________________ 
>  
> Svend Juul
> Institut for Folkesundhed, Afdeling for Epidemiologi
> (Institute of Public Health, Department of Epidemiology)
> Vennelyst Boulevard 6 
> DK-8000 Aarhus C,  Denmark 
> Phone, work:  +45 8942 6090 
> Phone, home:  +45 8693 7796 
> Fax:          +45 8613 1580 
> E-mail:       [email protected] 
> _________________________________________________________ 






 
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index