Statalist


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

st: RE: graphing a series of vectors (latent growth curve model estimate summaries)


From   "Stephen P. Jenkins" <stephenj@essex.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: graphing a series of vectors (latent growth curve model estimate summaries)
Date   Thu, 30 Oct 2008 09:45:11 -0000

> ------------------------------
> 
> Date: Wed, 29 Oct 2008 13:12:59 -0000
> From: "Nick Cox" <n.j.cox@durham.ac.uk>
> Subject: st: RE: graphing a series of vectors (latent growth 
> curve model estimate summaries)
> 
> . help twoway pcarrow 

... snip ... 

> In other words, you must construct x and y variables specifying the
> start of each arrow and similarly specifying the end of each arrow. 
 
> See also 
> 
> SJ-5-2  gr0015  . . . . . . . . Stata tip 21: The arrows of
outrageous fortune
>         . . . . . . . . . . . . . . . . . . . . . . . . . . . 
> . . .  N.J. Cox        Q2/05   SJ 5(2):282--284  (no commands)
>         tip for using graph twoway pcarrow for graphing changes over
time
> 
> That Tip is accessible to all under the three-year window. 


Nick's recommendation was spot on, and solved the problem. (Thanks too
to Austin Nichol's off-list suggestions.) I had looked at -twoway
pcarrow- but got deterred by the examples using either vertical or
horizontal arrows. And my -findit- and Statalist Archive searches must
have been using bad key words! In particular, I missed Nick's fine
Tip.

The issue was also clouded by data organisation issues.  -twoway
pcarrow- draws one arrow for each obs in the data, and so the data I
had needed tweaking before implementation. 

For the record, here is something that works. An extract from the data
set is as follows:

. list , sepby(age_start)

 
+---------------------------------------------------------------------
-+
     | age   wave     pcs   age_st~t   time   time2    pcs2   time1
pcs1 |
 
|---------------------------------------------------------------------
-|
  1. |  45      1   52.81         45     45      49   50.09      45
52.81 |
  2. |  45      2   52.13         45     46       .       .       .
. |
  3. |  45      3   51.45         45     47       .       .       .
. |
  4. |  45      4   50.77         45     48       .       .       .
. |
  5. |  45      5   50.09         45     49       .       .       .
. |
 
|---------------------------------------------------------------------
-|
  6. |  46      1    52.6         46     46      50   49.85      46
52.6 |
  7. |  46      2   51.91         46     47       .       .       .
. |
  8. |  46      3   51.23         46     48       .       .       .
. |
  9. |  46      4   50.54         46     49       .       .       .
. |
 10. |  46      5   49.85         46     50       .       .       .
. |

The variables age_start time, time1, time2, pcs1, pcs2 were created
from the original dta file (though in fact age_start is redundant in
this case; it's just that the varname is more meaningful). Observe
that the time2 and pcs2 variables are the values from the fifth wave
carried back to the row for wave 1. If the data had been in wide form
rather than long form, then this might not have been necessary.
(Alternatively -reshape wide- may be another way of reorganising the
data. I did not investigate this.)

Graphs in the required format are then produced using 
	
	graph twoway pcarrow pcs1 time1 pcs2 time2

More sophisticated graphs, such as in the Social Science and Medicine
article cited in my earlier post, could be created using overlays
(e.g. collections of vectors for different groups), and/or -graph
combine-

Anyway, I now have a happy colleague.  ... though having solved her
original problem, she wondered how to draw the arrowed lines if were
they quadratic rather than linear!  The answer -- confirmed by Nick
Cox off-list -- is that that would much harder. 


Stephen
-------------------------------------------------------------
Professor Stephen P. Jenkins <stephenj@essex.ac.uk>
Director, Institute for Social and Economic Research
University of Essex, Colchester CO4 3SQ, U.K.
Tel: +44 1206 873374.  Fax: +44 1206 873151.
http://www.iser.essex.ac.uk  
Survival Analysis using Stata:
http://www.iser.essex.ac.uk/teaching/degree/stephenj/ec968/ 
Downloadable papers and software: http://ideas.repec.org/e/pje7.html

Learn about the UK's new household panel survey, "Understanding
Society": http://www.understandingsociety.org.uk/



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