[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Clive Nicholas" <[email protected]> |

To |
[email protected] |

Subject |
Re: st: bootstrap weighted mean |

Date |
Wed, 12 Jan 2005 01:05:40 -0000 (GMT) |

Scott Merryman wrote: > I know that Stata's -bootstrap- command will not calculate a bootstrap > weighted mean: > > . bootstrap "sum loss_ratio [aw= premium]" r(mean), rep(100) > weights not allowed > > However, is it possible to get around this by making repeated calls to > -bsample-? > Will the following -simulate- program work or is it committing a sin and > only > returning garbage? > > program bst_mean, rclass > syntax varlist ,[ weight(string)] > preserve > bsample > sum `varlist' [`weight'] > return scalar mean = r(mean) > restore > end I ran this code successfully. > simulate "bst_mean loss_ratio, weight(aw =premium)" mean= r(mean), > rep(100) Using survey data that I accessed from the 1999 European Election Study (available on request), I ran your -simulate- command in order to bootstrap the weighted-mean proportions of Catholic respondents in the United Kingdom sample of the 1999 EES (N=977). In total, 128 of the UK respondents declared themselves as Catholic. . sum catholic Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- catholic | 977 .1310133 .3375877 0 1 . simulate "bst_mean catholic, weight(aw=weight)" mean= r(mean), rep(100) command: bst_mean catholic , weight(aw=weight) statistic: mean = r(mean) . sum mean Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- mean | 100 .1317976 .0121484 .1043396 .1758897 It looks as if your code hits the target: I obtain a bootstrapped weighted- mean estimated proportion of declared Catholics in the survey of 13.18%. Compared to the survey estimate of 13.10% (95% CI: 10.80% and 15.56%), this is hard to quibble with. Generating 1000 replications, I get: . sum mean Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- mean | 1000 .1333621 .011228 .0922785 .1683495 or, an estimated 13.34% of declared Catholics in the sample (95% CI: 11.14% and 15.54%). It would be even better if -pweight-s could be included in this, but I accept that this may be computationally difficult. I hope this helps. CLIVE NICHOLAS |t: 0(044)7903 397793 Politics |e: [email protected] Newcastle University |http://www.ncl.ac.uk/geps * * 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/

**Follow-Ups**:**RE: st: bootstrap weighted mean***From:*"Scott Merryman" <[email protected]>

**References**:

- Prev by Date:
**st: Re: model specification of poisson and xtpoisson** - Next by Date:
**st: RE: Variable/vector outer product?** - Previous by thread:
**st: bootstrap weighted mean** - Next by thread:
**RE: st: bootstrap weighted mean** - Index(es):

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