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]

st: bootstrap weighted mean


From   Shuaizhang Feng <[email protected]>
To   [email protected]
Subject   st: bootstrap weighted mean
Date   Wed, 2 Oct 2013 10:40:52 +0800

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/


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