# BCa confidence intervals skewed/unbalanced around the mean

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.

allo<-read.csv("Impala.csv")
pro<-spoor$pro n1<-nrow(spoor) 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)
den<-as.matrix((pi/2)*(xs*(1/m)))
return(den)
}

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

bo\$t


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.comFeb 27 '17 at 7:31

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

• 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. – MrFlick Feb 26 '17 at 19:01
• I'm confused why you'd expect a symmetric confidence intervall. – Roland Feb 26 '17 at 19:06
• @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 – Steve Ahlswede Feb 26 '17 at 19:10