2

I would estimate the coverage of the bootstrap interval for the mean knowing that the true average is 895.0385. I have my vector b<-c(300,300,200,250,600...) and I make bootstrap and output interval:

mean.fun <- function(dat, idx) mean(dat[idx], na.rm = TRUE) boot.out <- boot(b, mean.fun, R=999) boot.ci(boot.out) 

But how I can replicate this in order to obtain the coverage probability (how many times it contained the true average)?

2
  • Look into the?replicate function. Commented Dec 5, 2012 at 12:11
  • B <- 999 muH0 <-895.0385 N <- 52 DV<- sample2 sdH0 <- 1318.027 getM <- function(orgDV, idx) { bsM <- mean(orgDV[idx]) bsS2M <- (((N-1) / N) * var(orgDV[idx])) / N c(bsM, bsS2M) } bOut <- boot(DV, statistic=getM, R=B) boots <- t(replicate(B, getM(DV, sample(seq(along=DV), replace=TRUE)))) I can replicate the boot but for replicate boot.ci? Commented Dec 5, 2012 at 12:38

1 Answer 1

1

I was trying to do something a bit like this a bit ago. I didn't use the boot command I used the sample command but this might help. I also might be 100% wrong, I am not very good with R yet.

mean.fun <- function(dat, idx) mean(dat[idx], na.rm = TRUE) bootoutput <- data.frame( bootoutput = replicate(10000, boot.ci(boot(b, mean.fun, R=999))) ) 
Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, I misclciked that and by the time I saw I couldn't find a way to remove it via an edit. =/