0
votes

I would like to produce confidence intervals for proportions using the boot package if possible. I have a vector and I would like to set a threshold and then calculate the proportions below the specified level. After that I would like to use the bootstrap function in the boot package to calculate the confidence intervals for the proportions. Simple example of what I have so far:

library(boot)

vec <- abs(rnorm(1000)*10) #generate example vector

data_to_tb <- vec

tb <- function(data) {
  sum(data < 10, na.rm = FALSE)/length(data) #function for generating the proportion
}

tb(data_to_tb)

boot(data = data_to_tb, statistic = tb, R = 999)
quantile(boot.out$t, c(.025,.975))

However, I get this error message:

> boot(data = data_to_tb, statistic = tb, R = 999)
Error in statistic(data, original, ...) : unused argument (original)

I can not get it to work though, help appreciated

1

1 Answers

0
votes

Your problem is your function tb - it needs two arguments. From the help file ?boot

statistic A function which when applied to data returns a vector containing the statistic(s) of interest. When sim = "parametric", the first argument to statistic must be the data. For each replicate a simulated dataset returned by ran.gen will be passed. In all other cases statistic must take at least two arguments.