# BlockBootstrap.jl

Statistical block bootstrap library for Julia. Created by William Davis and Maggie Avery.

BlockBootstrap.jl is a Julia package for calculating and bootstrapping uncertainties statistics on time-series data.

# Theory

The theory used in this package is based off the book “Resampling methods for dependent data” by S.N. Lahiri, 2003, Springer.

Details of theory to be added.

# Using the package

There are many notebook example of how to use the package in the ./notebooks/ directory.

### Short example

This example is mostly from ./notebooks/BootstrapSDE.ipynb. For a time-series observation, such as a realization of the Ornstein-Uhlenbeck stochastic differential equation,

$du&space;=&space;-\alpha&space;u&space;dt&space;+&space;\beta&space;dW_t.$

This solution will look something like the figure below.

Say we want to estimate the parameter $\alpha$ from the realization, and we also want to find the incertainties on that estimation. Define a function handle that returns the statistic of choice (in this example it is slopeStatisticSet(), and pass it to the block bootstrapping function bootstrapStatistic().

## Calculate the statistic and bootstrap the uncertainties
# Settings
inputData = U;
statisticHandle = slopeStatisticSet;
bootstrapSampleHandle = CBBsample;
blockLength = 1500;
NbootstrapReplicates = 200;

fullDataEstimate, replicateEstimate, resampleIndexBB, resampleDataBB = bootstrapStatistic(
inputData, statisticHandle, bootstrapSampleHandle, blockLength, NbootstrapReplicates);


Settings are defined as functions to the argument bootstrapStatistic(), see the header of the function for descriptions. The output resampleIndexBB shows how the time indices have been resampled, e.g. see the figure below.

The output fullDataEstimate is the estimate of the statistics, and replicateEstimate is a vector of the statistics for bootstrap replicants, e.g. see the figure below.