Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: bootstrap weighted mean

 From Stas Kolenikov <[email protected]> To "[email protected]" <[email protected]> Subject Re: st: bootstrap weighted mean Date Wed, 2 Oct 2013 06:49:23 -0500

```So why exactly do you want to do this? This is Stata's -ratio-
command, and what you are doing is achievable with -bootstrap :
ratio-. If you need to incorporate weights, you can use -bsweights- /
-bs4rw- combo (the first is mine, the second is Jeff Pitblado's).

-- Stas Kolenikov, PhD, PStat (ASA, SSC)
-- Senior Survey Statistician, Abt SRBI
-- Opinions stated in this email are mine only, and do not reflect the
position of my employer
-- http://stas.kolenikov.name

On Tue, Oct 1, 2013 at 9:40 PM, Shuaizhang Feng
<[email protected]> wrote:
> Dear list:
>
> I was trying to bootstrap standard errors for the mean of two
> variables. When I do so for simple means, i use the following ado
> file.
>
> program myratio, rclass
>          summarize `1'
>           local a1 = r(mean)
>           summarize `2'
>           local a2 = r(mean)
>  return scalar ratio = `a1'/`a2'
> end
>
> and then do the following:
>
> .bootstrap r(ratio), reps(100) saving(cratio, replace): myratio u1 u2, detail
>
> and this gives the results as expected.
>
> however, when i wanted to do ratio of weighted means, i modified the
>
> program myratio_w, rclass
>       summarize `1'[iw=`3']
>           local a1 = r(mean)
>       summarize `2'[iw=`3']
>           local a2 = r(mean)
>  return scalar ratio = `a1'/`a2'
> end
>
>
> and then use:
>
> bootstrap r(ratio), reps(100) saving(cratio, replace): myratio_w u1 u2
> weight, detail
>
> then stata does not work properly and gives me the following message:
>
> invalid syntax
> an error occurred when bootstrap executed myratio_w
> r(198);
>
>
> I am wondering if anyone from the list can help me out. the difference
>
> SZ
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```