Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Scatterplot grouped data- advice to neophytes (was Scatter plot help.)


From   "Allan Reese (Cefas)" <[email protected]>
To   <[email protected]>
Subject   st: Scatterplot grouped data- advice to neophytes (was Scatter plot help.)
Date   Tue, 4 Jan 2011 10:14:46 -0000

On Jan 2, 2011, at 10:23 PM, Richard C. Feiock asked how to make:
>> Scatter plot of Y and X1 with dichotomous X2 (if X2=1 married, the
>> red-colored marker, if X2=0 non-married, the green marker) and with
>> continuous X3 (the size of marker is proportional to the value of X3)

On Sun, 2 Jan 2011 22:36:48 -0800 Nick Sanders <[email protected]>
gave an answer:
> twoway scatter Home Auto if Married == 1 [w = Income], mcolor(red) ||
scatter Home Auto if Married == 2 [w = Income], mcolor(green)

Under "more than one way to skin a cat" dept, it's worth adding that
many graph designs in Stata are best achieved with a restructuring of
the data.  As an alternative to overlaid plots (|| notation), you can
split the Y variable into separate variables for each group (with
missing values).  This makes it easier to check that all values are
accounted for, or to plot subsets of the group variable.

separate Home, by(Married)
scatter Home* Auto [w=Income], mcolor(red green blue) 

Groups to appear on the plot can be selected by an if clause as in
Nick's example, but this loses the equivalence of the group number and
plotted series.  An alternative is to make the unwanted groups plot
invisibly. 

scatter Home* Auto [w=Income], msymbol(oh th i) mcolor(red green blue)

Generating separate variables is also good for setting different
attributes for "normal" and "outlier" points, adding labels to just a
few points (eg end of series).

Incidentally, I empathise with Richard's query as there does not seem a
clear link in the documentation from marker_options and msize as a
scatterplot option to marker-size as defined by a covariate through the
weights.

Allan


***********************************************************************************
This email and any attachments are intended for the named recipient only.  Its unauthorised use, distribution, disclosure, storage or copying is not permitted.  If you have received it in error, please destroy all copies and notify the sender.  In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent.  All emails may be subject to monitoring.
***********************************************************************************


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index