How can I use pre bootstrapped data to obtain a BCa confidence interval?

非 Y 不嫁゛ 提交于 2019-12-19 11:21:55

问题


I have bootstrapped two variables (one which is already in the "Impala.csv" file) using a function which resamples and reports the mean for a sample the size of nrow(data) for 5000 repetitions. The code is as follows:

data<-read.csv("Impala.csv")
allo<-data$distance

data2<-read.csv("2010 - IM.csv")
pro<-data2$pro
n1<-nrow(data2)
boot4000 <- c()
for(i in 1:5000){
s <- sample(data2$xs,n1,replace=T,prob = data2$pro)
boot4000[i] <- mean(s)
}`

and then combine the two outputs in a formula, giving me 5000 new variables.

d<-(pi/2)*(boot4000*(1/allo))

Now I wish to find the BCa confidence intervals for this, but as I understand, the boot function will require me to make a new set of resamples, but I do not want this as the bootstrapping is complete. All I want now is a function which will take my bootstrapped data as is and determine the BCa confidence interval.

EDIT: http://www.filedropper.com/impala

http://www.filedropper.com/2010-im

Here are the data files I have used

Also, I have tried to create an object imitating a 'boot' object using the following

den<-as.matrix(d, ncol=1)
outs<-list(t0=mean(d), t=den, R=5000, L=3)
boot.ci(outs, type="bca")

This spits out the error:

Error in if (as.character(boot.out$call[1L]) == "tsboot") warning("BCa intervals not defined for time series bootstraps") else output <- c(output, : argument is of length zero

Thanks

UPDATE: I have solved the problem.

outs<-list(t0=mean(d), t=den, R=5000, sim="ordinary", stype="i", weights=rep(0.0002,5000), statistic=meanfun, data=d, call=boot(data=d, statistic = meanfun,R=5000), strata = rep(1,5000),attr="boot", seed=.Random.seed)

^This is how I made my object of class boot.out^

来源:https://stackoverflow.com/questions/41786693/how-can-i-use-pre-bootstrapped-data-to-obtain-a-bca-confidence-interval

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