[R] Percentile bootstrap for the median : error message

varin sacha v@r|n@@ch@ @end|ng |rom y@hoo@|r
Sat Jan 8 18:04:21 CET 2022


Dear R-experts,

Here below my R code for the percentile bootstrap confidence intervals with an error message. 
Is there a way to make my R code work ?
Many thanks for your help and time.

############################################
library(boot)

s=rnorm(100000,0,1)
(m<-median(s)) 

N <- 100
n<-5
out <- replicate(N, {

dat<-data.frame(sample(s,size=n))
med<-function(d,i) {
median(d[i, ])
}

  boot.out <- boot(data = dat, statistic = med, R = 10000)

  boot.ci(boot.out, type = "per")$per[, 4:5]

})

mean(out[1, ] < m & m < out[2, ])
############################################



More information about the R-help mailing list