R中的自举覆盖率 [英] Bootstrap coverage in R

查看:85
本文介绍了R中的自举覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

知道真实的平均值为895.0385时,我将估算均值的引导时间间隔的覆盖范围. 我有我的向量b<-c(300,300,200,250,600...)并进行了引导和输出间隔:

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)?

推荐答案

我前几天试图做一些类似的事情.我没有使用boot命令,而是使用了sample命令,但这可能会有所帮助.我也可能100%错了,我对R还不太好.

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)))
)

这篇关于R中的自举覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆