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

From |
Cindy Gao <cindy.gao@ymail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: ranking with weights |

Date |
Tue, 2 Dec 2008 19:16:16 +0000 (GMT) |

Thanks for your reply. The observations (analytic units) are households. Expenditure is the monthly expenditure of household. This is household survey data. The weights are frequency weights, to weight the sample to the whole country. The weights are likely to vary across for example regions, to compensate for oversampling or undersampling. Basically I need to rank all households according to their expenditure, from lowest to highest. But, I must take account of the weightings. If for example there are 2 households with the same expenditure, they must be ranked the same and this rank must take account of weightings. If there were no ties (households with same expenditure), I could achieve mission by generating a variable "rank", like -g rank=sum(weight)-. The problem comes because of ties. If i could -expand- my dataset using weights, then i could simply say -egen rank =rank(expenditure)- ; the problem is that dataset is too large for this. thanks, Cindy ----- Original Message ---- From: Steven Samuels <sjhsamuels@earthlink.net> To: statalist@hsphsun2.harvard.edu Sent: Tuesday, 2 December, 2008 18:53:40 Subject: Re: st: ranking with weights Cindy, What are the analytic units (people? regions?). What are the "weights"? What is "expenditure"? How is it measured. What do you mean that some regions are "less sampled" than others. It's not clear, for example, if this is a sample, and if so, of what? So, please describe the study design in detail. Last question: what is the purpose of the ranking? -Steve On Dec 2, 2008, at 12:54 PM, Cindy Gao wrote: > Hello > > I am trying to find a way to rank weighted data (since the egen function -rank- does not work with weights). A simple way would be order the data in terms of variable that I have interest in (monthly expenditure) and then create a new variable like -g rank1=sum(weight)-. But, there is problem. Some of my observations are "tied" as they have the same level of expenditure. Using the simple method I mention means that some observations are ranked above others even though they have same level of expenditure. This is a problem as the weights are large so you find that 2 observations are ranked with bug gap in between even though same level of expenditure. It is even bigger problem because the weights might be correlated with some other variables I am interested in (like region, since some regions are less sampled than other). I also try multiplying the expenditure ranking by the weight, but this gives wrong results (for example they do not add up to weighted > total). Can anyone help? In other words, I would like for all observations with same expenditure to have same rank, which I assume would be some average of all the weighted observations having that same expenditure.. I include a sample dataset below: > > expenditure weighting rank rank1 weighted_rank > 10 341 1 341 341 > 12 1065 2.5 1406 ??? > 12 98 2.5 1504 > 15 254 4 1758 > ....... > > thanks, > > Cindy > > > > > > > * > * 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/ * * 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/ * * 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: ranking with weights***From:*Steven Samuels <sjhsamuels@earthlink.net>

**RE: st: ranking with weights***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: ranking with weights***From:*Cindy Gao <cindy.gao@ymail.com>

**Re: st: ranking with weights***From:*Steven Samuels <sjhsamuels@earthlink.net>

- Prev by Date:
**st: duration models-random dates as covariates** - Next by Date:
**RE: st: ranking with weights** - Previous by thread:
**Re: st: ranking with weights** - Next by thread:
**RE: st: ranking with weights** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |