Statalist


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

st: RE: Using weights in a graph dot


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Using weights in a graph dot
Date   Thu, 3 Sep 2009 17:54:45 +0100

It's my understanding that -graph dot- uses weight information only in determining what numbers should be plotted. It does not vary the size of marker symbols regardless of what information you provide. 

If you want to proceed that way you would indeed need to use -twoway- to devise a plot. 

I've got to say that, despite your good intentions, this strikes me as a bad idea. What does proportional to size mean anyway? Some people want radius of symbol to represent size, some want area to represent size. There is much evidence that people can't decode areas accurately either way. Despite all that, Stata doesn't use either rule, and for good reasons. 

But then as you indicate if symbols really are proportional to size, then your largest should be 700 times bigger than your smallest! That can't be done while keeping everything legible and attractive. 

I suggest that a more informative strategy by far is to incorporate actual group numbers in the display. 

This graph is fairly silly, but the code shows simple technique that can be applied elsewhere. 

sysuse auto, clear
egen n = count(mpg), by(foreign)
egen what = concat(foreign n), decode p(" (")
replace what = what + ")"
graph dot (median) mpg, over(what)

Nick 
n.j.cox@durham.ac.uk 

Salome Dell-Kuster

i got stuck in a problem with the weights for a 'graph dot'.  And if I
may, I would like to ask you for help.

My plan was to create a 'graph dot' for several groups where the size of
the marker should represent the number of observations in the
corresponding group. I could find the weight-option in the help file and
tried several ways but without success (on the other hand, I was able to
do it the same way in a scatter plot, which is not as convenient for all
the other features of the graph). The ways I tried out was with _n
(system variable) and with a variable including the effectiv numbers of
observations and I also used proportions as another solution - but
nothing worked. 

My command: graph dot (median) diff_ga_aa [aweight=number], over(group1)
over(group2) 

One problem could be that the number of observations goes from about 2
to 1400 in the different groups.

Could you give me any hints how to solve this problem or recommend me a
book where I can find an example. 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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