Bootstrap coverage in R

流过昼夜 提交于 2020-01-02 13:35:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!