【发布时间】:2017-06-28 17:28:03
【问题描述】:
library(boot)
set.seed(3)
run2 <- structure(list(X = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
beta1 = c(1.40597500087168, 1.41848914211916, 1.42962301367006,
1.42029917323066, 1.4289966153492, 1.42596562840805, 1.42680678397731,
1.41425063435813, 1.40927087463386, 1.41364428128251)), .Names = c("X",
"beta1"), class = "data.frame", row.names = 11:20)
#my boostrap mean
> b11 = mean(sample(run2$beta1, 10000, replace = TRUE)); b11
[1] 1.419424
boot.beta1 <- function(d, i){
d2 <- d[i, ]
return(d2$beta1)
}
> bootbeta1 <- boot(run2, boot.beta1, R = 10000)
> boot.ci(bootbeta1, type = c("norm"))
BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 10000 bootstrap replicates
CALL :
boot.ci(boot.out = bootbeta1, type = c("norm"))
Intervals :
Level Normal
95% ( 1.377, 1.408 )
Calculations and Intervals on Original Scale
我的增强平均值是 1.419,但这超出了 95% CI?我该如何解决这个问题?
【问题讨论】:
-
@alistaire 对此感到抱歉。我已经更新了我的帖子。
-
我认为您可能刚刚围绕
beta1向量中的第一个值构建了一个 CI(基于我对boot.ci中“索引”参数的描述的阅读)。您试图围绕什么统计数据构建 CI? -
我很确定你希望
boot.beta1 <- function(d, i){; return(mean(d[i, "beta1"])); }作为你的函数。也就是说,您从 boostrap 复制中返回感兴趣的统计数据。