在R中引导。在评估所有复制之前退出boot()函数
我使用boot::boot函数来执行引导。 如果静态估计足够稳定,我正在实现一个算法来停止引导过程。这将有助于节省计算时间 但是我找不到一种方法来退出boot()函数循环 下面是一些伪代码:在R中引导。在评估所有复制之前退出boot()函数,r,loops,R,Loops,我使用boot::boot函数来执行引导。 如果静态估计足够稳定,我正在实现一个算法来停止引导过程。这将有助于节省计算时间 但是我找不到一种方法来退出boot()函数循环 下面是一些伪代码: my.boot <- function(data, R = NULL, auto.stop = T, statistic.fun) { # Wrapper over the usual boot() function if (is.null(R)) R = 10000 # Default n
my.boot <- function(data, R = NULL, auto.stop = T, statistic.fun) { # Wrapper over the usual boot() function
if (is.null(R)) R = 10000 # Default number of replicas if not set
bt <- boot(data, function(data, i){
estimates <- statistic.fun(data, i)
if(auto.stop == T) {
if(are.estimates.stable(estimates)) { # Example function that test if the estimates are stable enough
exit.boot.loop() # The function I'm looking for
}
}
return(estimates)
})
return(bt)
}
my.boot我们可以看看您的代码吗?为什么不直接运行一定数量的引导呢?像R=999>boot.means=numeric(R)>for(1:R中的i){+boot.sample=sample(cara,100,replace=T)+boot.means[i]=mean(boot.sample)+}>quantile(boot.means,c(.025,.975))
我重写了这个问题并添加了一些伪代码。我之所以使用boot()函数,是因为与自制的bootstrap相比,它提供了一些额外的优势,例如,易于计算置信区间