Since the question mentioned boot.ci
, I thought I would try to replicate the results of @knrumsey with the boot
package.
A couple of notes. I copied my general code for using boot.ci
with a function from here (with the caveat that I am the author of the code).
The results are similar to those of @knrumsey.
I don't know whatcan't confirm that the difference is between'perc' and 'bca' methods are the accelerated intervalssame as those used in the original answer and the bias-corrected accelerated intervals that boot.ci
uses.
set.seed(42)
n <- 30 #Sample size
x <- round(runif(n, 0, 100))
library(boot)
Function = function(input, index){
Input = input[index]
Result = var(Input)/mean(Input)^2 - 1/mean(Input)
return(Result)}
Boot = boot(x, Function, R=10000)
hist(Boot$t[,1])
boot.ci(Boot, conf = 0.95, type = "perc")
### BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
### Based on 10000 bootstrap replicates
###
### Intervals :
### Level Percentile
### 95% ( 0.1021, 0.3521 )
boot.ci(Boot, conf = 0.95, type = "bca")
### BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
### Based on 10000 bootstrap replicates
###
### Intervals :
### Level BCa
### 95% ( 0.1181, 0.3906 )