Bookmark and Share

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


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

Re: st: bootstrap weighted mean


From   Shuaizhang Feng <[email protected]>
To   [email protected]
Subject   Re: st: bootstrap weighted mean
Date   Thu, 3 Oct 2013 09:25:41 +0800

Dear all: thanks a lot for all the replies. It turned out that - set
trace on was tremendously helpful. After I drop ",detail" the code
works fine. many thanks for other suggestions too.    SZ

On Wed, Oct 2, 2013 at 7:49 PM, Stas Kolenikov <[email protected]> wrote:
> 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
>> ado file as follows:
>>
>> 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
>> between the two ado files seem small Thanks in advance.
>>
>> 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/
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index