Statalist The Stata Listserver


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

st: RE: histogram


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: histogram
Date   Thu, 5 Apr 2007 11:25:17 +0100

Various people made suggestions about histograms or near-equivalents
such as dot plots and kernel density estimates. The latter appeal 
particularly because they can be superimposed. 

I think there is scope for other plots too. All the possibilities 
mentioned involve some arbitrariness, in choice of bin width (and 
origin), or in choice of kernel type and width. Also, looking
at the density function is good for seeing if the peak has shifted
but less direct in looking at the tails. My guess is that in 
this problem clinicians (and parents) would all be very interested
in extreme birthweights, with greatest risks for mortality or 
morbidity or greatest chances of different treatment or care needs. 

The alternatives I have in mind involve a quantile-based view. 
I fall back on the hoary old -mpg- example from the -auto- dataset. 

use auto, clear
help qqplot 

-qqplot- seems very demanding: it needs two variables. How can 
we can compare two groups? The answer is to fire up -separate-. 

separate mpg, by(foreign) veryshortlabel 
qqplot mpg? 

What is interesting here is not only there is a systematic
difference, but that it is more nearly multiplicative than 
additive. I think that it would be easier to miss that with
density views (to say nothing of t or Mann-Whitney!) 

You can try log scales 

qqplot mpg?, xsc(log) ysc(log)

or in this case, there is a natural alternative scale: 

gen gpm = 1 / mpg
separate gpm, by(foreign) 
qqplot gpm? 

Whenever the structure is that of (approximately) constant
differences or ratios between corresponding quantiles, 
sometimes you want to examine those directly. -cquantile- on 
SSC offers a tool here. See its help for detailed suggestions. 

An alternative is to show the quantile functions as such. 

help quantile 

shows that official Stata's -quantile- is very limited. 

findit qplot 

and install (unless you have done so previously). Then 

qqplot mpg, over(foreign) 

superimposes quantile traces. 

Nick 
[email protected] 

Ali Khashan

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

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