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

Subject |
RE: st: egen "mean weight" |

Date |
Sun, 4 Sep 2005 16:30:56 +0100 |

I don't know why -egenmore- is being singled out here. The bigger issue is that -egen- does not take weights as such, so that use of -egen- with weights requires some work-around, for example the use of an option, as in -egen, xtile()- on -egenmore-. That creates an obligation to say which kinds of weights are supported. As far as -egenmore- is concerned, the whole package is pretty much an ad hoc accumulation of programs found to be needed by their authors. People should feel free to look at it and recognise oversights everywhere. Theme, direction and planning are non-existent. The original question was discussed in an FAQ a few years ago: FAQ . . Calculating variables containing weighted group summary statistics . . . . . . . . . . . . . . . . . . . . . N. J. Cox and S. P. Jenkins 1/03 I want to calculate a variable containing weighted group summary statistics, but I do not want to collapse the data and egen does not support weights. How can I do this? http://www.stata.com/support/faqs/data/weighted.html In that FAQ, we strongly commend the kind of approach from first principles well explained here by Austin. Nick n.j.cox@durham.ac.uk austin nichols > It seems to me an oversight that -ssc install egenmore- does not > already give you this capability, especially since the xtile function > in that package allows weights when dividing your sample into > quantiles. But it is easy enough, and good practice, to construct > weighted means from first principles--you really never have to use > egen, it's just a shortcut. > . bys iid: gen double spop=sum(pop) > . bys iid: replace spop=spop[_N] > . gen double wtdwage=wage*pop/spop > . bys iid: gen double meanwage=sum(wtdwage) > . bys iid: replace meanwage=meanwage[_N] > . drop spop wtdwage > . compress meanwage Jorge Tuesta > > Is it posible to create a average weight variable using "egen"? > > I normally write: > > egen mwage=mean(wage), by(iid) > > but i would like "mean weight" (using [fweight=pop], for > example) not > > simple mean. Is it posible? * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: RE: Panel Data Problem** - Next by Date:
**RE: st: Calculating the e^b using listcoef** - Previous by thread:
**Re: st: egen "mean weight"** - Next by thread:
**st: stata8 update** - Index(es):

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