[R] stratified bootstrap with boot

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed May 4 18:06:25 CEST 2005


You asked for a stratified bootstrap, not a stratified estimator.  This is 
explained in the reference (Davison & Hinkley).

On Wed, 4 May 2005, Richard Chandler wrote:

> Hello,
>
> I am new to R, and am having trouble getting the output I want from a
> stratified bootstrap. I didn't recieve a reply the first time I posted
> this question so I have tried to make it more clear. My data frame
> (denboot) is set up as follows:
>
>        SITE cswa parea treat
> 1      BeanA    3  1.20     m
> 2     BeanBC    3  1.05     m
> 3      BeanD    1  0.93     m
> 4     BlackB    1  1.01     m
> 5     Brooks    3  4.00     b
> 6      BullL    3  1.32     b
> 7      BullM    1  0.20     m
> 8      BullU    4  2.06     b
> ...
>
> #Here is my code:
>
> cswafun <- function(denboot, i) sum(cswa[i])/(sum(parea[i])
> attach(denboot)
> cswa.boot <- boot(denboot, cswafun, R = 10000, strata = treat)
>
> #Here is the output
>
> Call:
> boot(data = denboot, statistic = cswafun, R = 10000, strata = treat)
>
>
> Bootstrap Statistics :
>    original     bias    std. error
> t1* 1.109612 0.02641786   0.2032927
>
> #Can anyone tell me why I'm not getting two estimates of
> sum(cswa)/sum(parea), one for each #strata ('b' and 'm')? Any help
> would be appreciated. Thanks

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list