# Bootstrap and confidence intervals for bootstrap

I've just begun learning about the bootstrap method and I'm not entirely sure that I've understood this perfectly right. The way that I have interpreted what my book says is that when we don't have enough data or can't recreate/replicate exact data which we have had previously we simply randomise new data based on the data that we already have and then calculate whatever it is that we need to calculate with it.

I don't really understand why this method works or even is preferred as a good method, I mean... why should you expect anything else than results that are similar to the old test when you're uniformly "reassembling" your data from previously known data?

This aside, I've constructed a function in R which does the bootstrapping of a matrix filled with certain data, my problem is now to create a confidence interval for it. My book only says "calculate the 95% quantiles of the bootstrap-mean" but does not give me any formula on how to do so.

• Does this Q&A stats.stackexchange.com/questions/19340/… help? – mdewey Nov 20 '16 at 12:17
• – Tim Jul 31 '17 at 21:09
• You probably want to look at the boot package with the boot function and the boot.ci function. It produces bootstrap confidence intervals by a few different methods. The percentile and bca methods are relatively more "current technology" than some computationally easier methods. – Sal Mangiafico Aug 2 '17 at 10:50

Suppose, we are drawing numbers from an unknown distribution ($i.i.d$). The first five draws happened to be $[6, 1, 3, 9, 8]$. Now as far as we know, each of these were equally likely to be drawn. So instead of the $8$ we might as well have drawn the $1$ again. Or we might have drawn the $6$ again. So as far as we know now, the following samples would have been equally likely:

$[6,1,3,9,1]$ and $[6,1,3,9,1]$ and $[6,1,3,9,3]$ and $\dots$

All these are bootstrap samples of our sample. For our limited knowledge of the true distribution, they are the best random samples we can construct now. Let's hope, we have a true sample of considerably greater size than $n = 5$. If any number comes up more then others, it is likely to have higher occuring in the true distribution and it is likely to appear more often in our bootstrap samples.

Bootstrapping is good, because except for the $i.i.d.$ part there are next to no assumptions to be made. The fact, that a large sample gives more insight into the distribution than a small sample is however not to be overcome by bootstrapping.

In R you can compute quantiles using the function quantile as in

> quantile(x=rnorm(10000),probs = c(0.025, 0.975))
2.5%     97.5%
-1.960686  1.950251