Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Boxplot with median *and* mean not possible?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Boxplot with median *and* mean not possible?
Date   Wed, 4 Jun 2003 20:21:35 +0100

Ernest Berkhout
> 
> is it possible to create a boxplot in which not only the 
> median is plotted, 
> but also the mean? It appears to me that momentarily this 
> option is not 
> available, am i overlooking something? More experienced 
> users could create 
> such a graph with twoway-overlaying a rcap, a rbar and two 
> scatters but of 
> course it would be more elegant to have it as an option in 
> <graph boxplot> 

Sounds a very good idea to me. 

The only device which springs to mind -- other 
than superimposing -yline(<mean>)- or something
similar -- is to construct a variable identically 
equal to the mean and then put the boxes side by side: 

egen mean = mean(mpg), by(foreign) 
graph box mpg mean, over(foreign) 

but that isn't nearly as neat as could be desired. 

Working backwards, this question prompted me 
to add a -mean- option to -eqprhistogram- (previously 
posted on SSC). In many circumstances, that histogram
shows more information than a box plot. However, 
it doesn't lend itself to side-by-side 
comparison of different variables or groups 
which is a main virtue of boxplots. N.B. I'm 
keeping the code to myself while making other 
additions. 

Nick 
[email protected] 

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