I build confidence bounds for estimating PDF of the empirical sample using bootstrapping:
data <- rnorm(1000)
d <- density(data)
boot <- replicate(100,
{ x <- sample(data, replace=TRUE);
density(x, from=min(d$x), to=max(d$x))$y})
CI <- apply(boot, 1, quantile, c(0.025,0.975) )
hist(data, freq=F, ylim=c(0,max(CI[2,])))
lines(d, lwd = 2)
lines(d$x, CI[1,], lty=2)
lines(d$x, CI[2,], lty=2)
I have questions:
- From what reasons I need to choose the number bootstrapping repeats?
- How can I use confidence bounds for the determination of the minimum required sample size?