1
boot.ci()
を使用して、マルチステージブートストラップのBCa信頼区間を計算したいと思います。例はNon-parametric bootstrapping on the highest level of clustered data using boot() function from {boot} in R で、boot
コマンドを使用しています。階層ブートストラップからの信頼区間
# creating example df
rho <- 0.4
dat <- expand.grid(
trial=factor(1:5),
subject=factor(1:3)
)
sig <- rho * tcrossprod(model.matrix(~ 0 + subject, dat))
diag(sig) <- 1
set.seed(17); dat$value <- chol(sig) %*% rnorm(15, 0, 1)
# function for resampling
resamp.mean <- function(dat,
indices,
cluster = c('subject', 'trial'),
replace = TRUE){
cls <- sample(unique(dat[[cluster[1]]]), replace=replace)
sub <- lapply(cls, function(b) subset(dat, dat[[cluster[1]]]==b))
sub <- do.call(rbind, sub)
mean(sub$value)
}
dat.boot <- boot(dat, resamp.mean, 4) # produces and estimated statistic
boot.ci(data.boot) # produces errors
どのように私はboot
出力にboot.ci
を使用できますか?
@coffeeinjunkyありがとう!問題が非常に懐古的だったときにコードを評価するのに多大な時間を費やしたことをばかげて感じません! –
うれしい私は助けることができます。 – coffeinjunky