[R] Bootstrap library(boot) "boot.ci" function

David Winsemius dwinsemius at comcast.net
Sat Jan 17 22:41:55 CET 2015

Moderator’s note; There were two messages from this person in the moderation queue and since they appeared identical in the moderation panel, I accepted accepted one and rejected the other. I’m now wondering (and have no way of checking) whether the OP sent a second non-HTML version and I rejected the wrong one, so I’m posting a version with the code parsed as I imagine it should have appeared:

> On Jan 17, 2015, at 12:27 PM, varin sacha <varinsacha at yahoo.fr> wrote:
> Hi dear R-experts,
> I want to compare the bootstrap percentile interval, the Z interval, the T interval, etc.So I use a function (I have modified a few things) I have found on stats.stackexchange.

simfun <- function(n=20) {x <- rnorm(n)  
  m.x <- mean(x)
  s.x <- sd(x)
  z <- m.x/(1/sqrt(n))
  t <- m.x/(s.x/sqrt(n))
  b <- replicate(1000, mean(sample(x, replace=TRUE)))
  c( t=abs(t) > qt(0.975,n-1),
     z=abs(z) > qnorm(0.975),
     z2 = abs(t) > qnorm(0.975), 
     b= (0 < quantile(b, 0.025)) | (0 > quantile(b, 0.975)))

out <- replicate(1000, simfun())

     t          z        z2     b.2.5%  0.045  0.052  0.061  0.070 

> I still have the bootstrap percentile interval. Now, starting from this function here above, I would like to calculate all the other intervals (t-studentized, BCa, etc.) using the boot package and the boot.ci function (type="all"). How can I do ?
> Thanks for your help.
> Best,
> SV
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, USA

More information about the R-help mailing list