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]

From |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: trajectory graph can not come out line with my code |

Date |
Wed, 1 Dec 2010 15:23:48 +0000 |

I don't understand either why you need to calculate ranks. I imagine you don't. That is just what someone else did for their purposes. This shows the perils of copying code that you don't completely understand, although in some sense almost everybody does precisely that some of the time. My eye is drawn to the condition (rankpopgrowth==`i'*.1) Within a loop i = 1/7 you are testing whether rankpopgrowth is, so far as Stata is concerned, exactly equal to 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7. Very likely there are no such values. Also, this kind of computation seems to be assuming that Stata is being run on a computer that deep down works with decimal, but that is not the case. Computers work with binary. For further reading, type . search precision in Stata. In any case, look at the data you think you are plotting using e.g. -list- or -edit-. My guess is that you have lots of missing values. Nick n.j.cox@durham.ac.uk Cecilia 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. * * 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/

**Follow-Ups**:**RE: st: RE: trajectory graph can not come out line with my code***From:*Cecilia Ann <xqcecilia@msn.com>

**References**:**st: trajectory graph can not come out line with my code***From:*Q X <xqcecilia@msn.com>

- Prev by Date:
**st: notes and labels and saving datasets** - Next by Date:
**st: ereturn display with robust** - Previous by thread:
**st: trajectory graph can not come out line with my code** - Next by thread:
**RE: st: RE: trajectory graph can not come out line with my code** - Index(es):