library(boot) y <- c(1,2.1,3.2,3.7,4.0,4.1,4.5,5.1,5.6,5.7,6.2,6.3,6.9,7.2,7.4,8.1,8.6) y n <- length(y) n thetahat = mean(y) thetahat Brep = 10000 # Bootstrap the sample mean sampmean <- function(y,i) mean(y[i]) bootmean <- boot(data=y,statistic=sampmean,R=Brep) bootmean boot.ci(bootmean,conf=.95,type=c("norm")) boot.ci(bootmean,conf=.95,type=c("perc")) boot.ci(bootmean,conf=.95,type=c("bca")) par(mfrow=c(2,1)) hist(bootmean$t,main="Bootstrap Sample Means") plot(ecdf(bootmean$t),main="Empirical CDF of Bootstrap Means")