问题
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)?
回答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)))
)
来源:https://stackoverflow.com/questions/13726315/bootstrap-coverage-in-r