I have some trouble in calculating a confidence interval with bootstrap method using R. Here is a minimal example that I get stuck.
library(simpleboot) set.seed(123) random <- data.frame(x=runif(10), y=runif(10)) pi <- function(df){4*length(subset(df, x^2 + y^2 < 1)$x)/length(df$x)} pi.boot <- one.boot(random, pi, 1000) # I got an error here I got an error which says
Error in
[.data.frame(x, idx) : undefined columns selected
Would you help me to find out what is wrong with it? Thank you.
pi. Try breaking things down into an absolutely minimal reproducible example to work out which part ofpiisn't working. Then if you haven't worked out the error by then, it'll be in a good form for posting on Stack Overflow. On the other hand, asking folk to debug your entire code because you haven't tried finding where the error is can be considered a bit lazy, but moreover it's unhelpful to future readers - if someone does have a issue with bootstraps they don't want to see a Q about subsetting in their search