I tried it out and Nick Winter's code works very well, and it seems as if
it is faster in my bootstrap than the whole svymean thing was. I don't
know anything about SSC though or how that compares.
Thanks for all your input.
Laura
On Wed, 23 Apr 2003, n j cox wrote:
> Nick Winter wrote:
>
> > I don't think there is a preprogrammed thing for this (although Nick Cox
> > may prove me wrong), but you can do this yourself fairly easily:
> >
> > . sort month
> > . by month: gen ET = sum(varname*wgt) / sum(wgt)
> > . by month: replace ET=ET[_N]
> >
> > Remembering that the weighted mean is simply the sum of the (variable
> > times the weight) divided by the sum of the weights. The second line
> > creates the "running" mean within month, the third line replaces the
> > weighted mean for all observations with the final one for each month,
> > which is the overall weightd mean for the month.
>
> This code is better than mine. I was starting from an FAQ with which
> I am familiar, not a good strategy compared with looking at the
> problem directly.
>
> David Kantor has a weighted mean -egen- function on SSC.
>
> However, will any of this code treating pweights properly?
>
> Nick
> [email protected]
>
>
>
> *
> * 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/
>
*
* 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/