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: trajectory graph


From   Q X <xu.qi.102@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: trajectory graph
Date   Tue, 30 Nov 2010 19:14:44 -0500

Hi there,

I need help with trajectory graph in panel data.

I am trying to plot trajectory graph on population pattern in panel
data. The file I found on website tells something about trajectory
graphing(I paste the command below). But I still can not understand
the programming since the commands are without data. Could you please
give me more materials and suggestions on the topic for me to study?

In addition, what is the “rank” used for?

I appreciate for your help.

Best wishes,
Qi



Command on website:
*trajectory2.do file for Stata 10.0
use cd4.dta, clear
egen newid=group(id)
sum newid
drop id
rename newid id
gen timedays=round(time*365.25,1)
sort id timedays
egen cd4mean = mean(count), by(id)
list id count cd4mean in 1/10
sort id
quietly by id: replace cd4mean=. if (_n > 1)
egen rnk=rank(cd4mean)
local i = 1
while `i' <= 7{
     gen sub`i' =(rnk == `i'*25)
     sort id timedays
     quietly by id: replace sub`i'=sub`i'[1]
     gen cd4l`i' = count if (sub`i')
     drop sub`i'
     local i=`i'+1
}
ksm count timedays, lowess gen(cd4smth) nograph
twoway (scatter count timedays) (scatter cd4smth timedays) (line
cd4l1-cd4l7 timedays)

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