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 can not come out line with my code


From   Q X <[email protected]>
To   STATA List <[email protected]>
Subject   st: trajectory graph can not come out line with my code
Date   Wed, 1 Dec 2010 10:14:07 -0500

Hi there,
 
But on last command, "twoway () () (line x y)" there is no line connecting the dots on my graph. I can not figure out why it happens. My dataset is strongly balanced panel data with years 1960,1970,1980,1990,2000.I want to tract the pattern of population over these five year. So, the population growth rate are all distributed on 1970,1980,1990,2000. 
 
My code is as follows.
replace popgrowth=. if popgrowth>23
egen newid=group(geo_id2)
sum newid
drop  geo_id2
rename newid id
order id year
sort id popgrowth
egen popgrowthmean=mean(popgrowth),by(id)
list id popgrowth popgrowthmean in 1/10
sort id
quietly by id:replace popgrowthmean=. if (_n>1)
egen rankpopgrowth=rank(popgrowthmean)
local i=1
while `i'<=7{
    gen sub`i'=(rankpopgrowth==`i'*.1)
 sort id year
 quietly by id:replace sub`i'=sub`i'[1]
 gen pop1`i'=popgrowth if (sub`i')
 drop sub`i'
 local i=`i'+1
}
ksm popgrowth year,lowess gen(popgrowthsmth)
twoway (scatter popgrowth year) (scatter popgrowthsmth year) (line pop11-pop17 year)
 
 
I think the number of pattern of population growth may be seven. So, I set `i'<=7. But, I do not understand why wee need to generate rank of populationgrowthmean.
 
I appreciate for your help.
 
Best,
Cecilia 		 	   		  
*
*   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