# Does bagging use all the data?

When using Bootstrap Aggregating (known as bagging), does all of the data get used, or is it possible for some of the data never to make it into the bagging samples and thereby getting excluded from whatever statistical procedure that is being used.

Say you have some data $\{(y_i, x_i)\}$ with $i=1,\ldots,n$. A bootstrap sample is when you sample from the data above with replacement, and your sample is the same size as your original data set.

On an individual bootstrap sample, let's call it $(y^*_i,x^*_i), i=1,\ldots n$, the number of times a certain row of data shows up is a binomial random variable with parameters $n$ and $1/n$. The probability it does not show up in ONE bootstrap sample is $(n-1)/n$. Let's call that number $\theta$. Then if you have $B$ bootstrap samples, and you use independence, you get the probability of a row of data never being used in ANY of the $B$ samples to be $\theta^B$.

To answer your question, there is always some probability that a row of data does not get used. But this probability gets very small when you increase $B$.

• So does all the data have to get used....? Jan 27 '16 at 22:54
• @RustyStatistician. You use sampling with replacement. There is a chance that some observations never fall into boosted sample. Jan 27 '16 at 22:55
• @StatsStudent thanks! That's all I wanted to know. Jan 27 '16 at 22:55
• Note that limit (1-1/n)^n as n->infinity = 1/e . Hence, for a large dataset of n items, if you sample as it size you will get ~ 36%
– DaL
Jan 28 '16 at 10:08
• Yeah, $B$ shouldn't depend on this probability. You're probably after better predictions. That's a different question @EngrStudent Jan 28 '16 at 14:34