I am attempting to calculate BCa intervals through a code I made in R, but most of my data sets are coming back with skewed/unbalanced confidence intervals (CIs). For example, the estimated mean will be 37, and the CI will be 25 - 67, thus showing an unbalance of the interval around the mean. I had a colleague run the same data through SYSSTAT and he came back with different results. At this point I am considering just giving up on using R for this purpose but I am hoping someone here maybe can give some insight into what is causing this.

Here are the data sets which I am using and the code as well if someone would like to try it themselves.

http://www.filehosting.org/file/details/644747/Impala.csv http://www.filehosting.org/file/details/644750/2016%20-%20IM.csv

spoor<-read.csv("2016 - IM.csv")
boot4000 <- c()
for(i in 1:5000){
s <- sample(spoor$xs,n1,replace=T,prob = spoor$pro)
boot4000[i] <- mean(s)
data<-matrix(c(boot4000,allo$distance),nrow=5000,ncol = 2)


meanfun <- function(data, i){
m <- sample(data[i,2],size=1, replace=T)
xs<- sample(data[i,1],size=1, replace=T)

bo1 <- boot(data, statistic=meanfun, R=5000)
bo<-boot.ci(bo1, conf=0.95)


The idea behind the code is that I have a bootstrapped excel file which is "allo", and then I bootstrap the xs values and combine the values randomly from both bootstraps within a formula to obtain 5000 density estimates. The BCa is then supposed to create the CIs around my mean density estimate.


migrated from stackoverflow.com Feb 27 '17 at 7:31

This question came from our site for professional and enthusiast programmers.

  • 1
    $\begingroup$ Perhaps this belongs on Cross Validated because it requires a knowledge of BCa which you do not provide in the question itself so it's not really a programming question that's appropriate for Stack Overflow. $\endgroup$ – MrFlick Feb 26 '17 at 19:01
  • 1
    $\begingroup$ I'm confused why you'd expect a symmetric confidence intervall. $\endgroup$ – Roland Feb 26 '17 at 19:06
  • $\begingroup$ @Roland essentially it is because one of my profs told me that he noticed our confidence intervals varied in that his was much more symmetrical than the one i obtained. He said it should be fine unless it is a reoccurring theme (which it seems to be). So there is no problem with skews in the interval? Some results were far more skewed then the example I gave $\endgroup$ – Steve Ahlswede Feb 26 '17 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.