Statalist


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

st: St: Re: graph over


From   "Allan Reese (Cefas)" <[email protected]>
To   <[email protected]>
Subject   st: St: Re: graph over
Date   Thu, 2 Apr 2009 10:23:18 +0100

There's a generic answer to this that I prefer to call lateral thinking
rather than a kludge.

The data comprises three variables:
   ESL percentage        - the Y var
   time of observation   - the X var
   school (categorical)  - the group var

Scatterplot Y against X shows the overall pattern, and Stata has an
option to label each point with its group.
However, it's not immediately obvious how to plot the groups with
different symbols: msymbol(varname) is not available [HINT to StataCorp
- it would be nice.]  Nor how to join the points for each group.

The solution is to restructure the data, and one option would be reshape
long->wide, making ESL+school variables.  This might be more appropriate
if the time points of observations in each school were equivalent, and
cross-correlations would be calculated.

My usual solution is to keep the original cases but divide the
observations for each group into separate variables.
You can do this by a series of

   gen ESL1 = ESL if school==1   // etc
or
   xi , noomit i.school|ESL
   recode _I* (0=.)
except that (in my Stata 9.2) generates the dummy main effect variables
as well, contrary to Manual [HINT to StataCorp - bug? Known?]

Then 
   scatter _IschoolX* time
plots each school with a different symbol (within system limits for no
of groups!).  Any other twoway plot with a varlist would be similar.

There are lots of graph problems that are best tackled by splitting one
variable into groups. 

R Allan Reese
Senior statistician, Cefas
The Nothe, Weymouth DT4 8UB 

Tel: +44 (0)1305 206614 -direct
Fax: +44 (0)1305 206601 

www.cefas.co.uk 



***********************************************************************************
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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index