I have a vector of numbers that I've uploaded here (.../code/MyData.Rdata) using dput.

I would like to get the bca ci so I've written this code:

my.mean <- function(dat, idx){
 return (mean(dat[idx], na.rm = TRUE))

boot.out<-boot(data=my.data, statistic = my.mean, R=1000)

But when I run the following I get this:

> boot.ci(boot.out)
Error in bca.ci(boot.out, conf, index[1L], L = L, t = t.o, t0 = t0.o,  : 
estimated adjustment 'a' is NA
In addition: Warning message:
In boot.ci(boot.out) : bootstrap variances needed for studentized intervals

Can someone help me figure out what is causing this error? Thank you for your help!

  • 3
    $\begingroup$ I have tried with R=10000 instead of R=1000 (and specifying type='bca' instead of type='all' since this is what you really want) and it works. So my conclusion would be that what is causing this error is not enough bootstrap replications... but I cannot say more... $\endgroup$
    – ocram
    Sep 24 '12 at 18:56

As you can see from your error message, boot.ci calls bca.ci. Because the boot.out object doesn't supply L, the empirical influence values for the statistic you're calculating on the data, bca.ci tries to calculate them using the empinf function, and then (as Michael says) it uses them to calculate the acceleration constant:

L <- empinf(boot.out, index = index, t = t.o, ...)
a <- sum(L^3)/(6 * sum(L^2)^1.5)

But with a small number of replications, empinf sometimes fails and returns a vector of NA values. The result is that you have no values for L, a can't be calculated, and you get your error. As ocram says, increasing the number of boostrap replications will fix this. Even doubling R to 2000 should probably do it.

  • 2
    $\begingroup$ +1 @Kieran Thanks! I am glad that my guess had some validity. You have the right answer from your knowledge of the R programs involved. so my answer is no longer needed. Someone either did not like me guessing or thought my answer should be a comment. For all those reasons it makes sense for me to delete it now. $\endgroup$ Sep 24 '12 at 21:46
  • 7
    $\begingroup$ For other who suffer the problem: According to stat.ethz.ch/pipermail/r-help/2011-February/269006.html the number of repetitions must be larger than the number of data rows. I was mildly suprsed that so many repetitions are necessary... $\endgroup$
    – BurninLeo
    Oct 11 '15 at 8:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.