Function Repository Resource:

BootstrapStatistics

Source Notebook

Bootstrap a single statistic or a list of statistics

Contributed by: Katja Della Libera

ResourceFunction["BootstrapStatistics"][data,n]

returns a list of n bootstrapped datasets.

ResourceFunction["BootstrapStatistics"][data,n,func]

returns a list of the values of func applied to n bootstrapped datasets.

ResourceFunction["BootstrapStatistics"][data,n,funclist]

returns a list each function in funclist applied to n bootstrapped datasets.

Details and Options

Bootstrapping is a statistical method that resamples data with replacement to assess measures of accuracy

Examples

Basic Examples (2) 

Create five bootstrapped datasets by resampling from an original dataset:

In[1]:=
ResourceFunction["BootstrapStatistics"][{1, 2, 3, 4, 5, 6}, 5]
Out[1]=

Compute the Mean of a dataset:

In[2]:=
Mean[{1, 2, 3, 4, 5, 6}]
Out[2]=

Compare it to the means of ten bootstrapped samples:

In[3]:=
samplemeans = ResourceFunction["BootstrapStatistics"][{1, 2, 3, 4, 5, 6}, 100, Mean]
Out[3]=
In[4]:=
Histogram[samplemeans]
Out[4]=

Scope (1) 

Pass a list of functions to BootstrapStatistics to get a list of lists of results:

In[5]:=
ResourceFunction[
 "BootstrapStatistics"][{1, 2, 3, 4, 5, 6}, 5, {Mean, Median, StandardDeviation, Variance}]
Out[5]=

Applications (4) 

The example dataset "BuffaloSnow" shows snowfall records for Buffalo, New York:

In[6]:=
ExampleData[{"Statistics", "BuffaloSnow"}, "Description"]
Out[6]=

With traditional methods, we can only get one estimate for the mean snowfall:

In[7]:=
snowdata = ExampleData[{"Statistics", "BuffaloSnow"}];
Mean[snowdata]
Out[8]=

Using the bootstrap method, we can get a larger set giving us a better idea of how much this measure varies:

In[9]:=
snowmeans = ResourceFunction["BootstrapStatistics"][snowdata, 10000, Mean];
Histogram[snowmeans]
Out[10]=

We can use Quantile to find the 95% confidence interval:

In[11]:=
Quantile[snowmeans, {0.025, 0.975}]
Out[11]=

Version History

  • 1.0.0 – 13 January 2020

Related Resources

License Information