-
Notifications
You must be signed in to change notification settings - Fork 27
/
README.md
134 lines (89 loc) · 4.14 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Bootstrap.jl: Statistical Bootstrapping
## Motivation
Bootstrapping is a widely applicable technique for statistical estimation.
![img](docs/src/assets/logo.png)
## Functionality
- Bootstrapping statistics with different resampling methods:
- Random resampling with replacement (`BasicSampling`)
- Antithetic resampling, introducing negative correlation between samples (`AntitheticSampling`)
- Balanced random resampling, reducing bias (`BalancedSampling`)
- Exact resampling, iterating through all unique resamples (`ExactSampling`):
deterministic bootstrap, suited for small samples sizes
- Resampling of residuals in generalized linear models (`ResidualSampling`, `WildSampling`)
- Maximum Entropy bootstrapping for dependent and non-stationary datasets (`MaximumEntropySampling`)
- Confidence intervals:
- Basic (`BasicConfInt`)
- Percentile (`PercentileConfInt`)
- Normal distribution (`NormalConfInt`)
- Studendized (`StudentConfInt`)
- Bias-corrected and accelerated (BCa) (`BCaConfInt`)
## Installation
The `Bootstrap` package is part of the Julia ecosphere and the latest release
version can be installed with
```julia
using Pkg
Pkg.add("Bootstrap")
```
More details on packages and how to manage them can be found in the [package
section](https://docs.julialang.org/en/v1/stdlib/Pkg/) of the Julia
documentation.
## Examples
This example illustrates the basic usage and cornerstone functions of the package.
More elaborate cases are covered in the documentation notebooks.
```julia
using Bootstrap
```
Our observations in `some_data` are sampled from a standard normal distribution.
```julia
some_data = randn(100);
```
Let's bootstrap the standard deviation (`std`) of our data, based on 1000
resamples and with different bootstrapping approaches.
```julia
using Statistics # the `std` methods live here
n_boot = 1000
## basic bootstrap
bs1 = bootstrap(std, some_data, BasicSampling(n_boot))
## balanced bootstrap
bs2 = bootstrap(std, some_data, BalancedSampling(n_boot))
```
We can explore the properties of the bootstrapped samples, for example, the
estimated bias and standard error of our statistic.
```julia
bias(bs1)
stderror(bs1)
```
Furthermore, we can estimate confidence intervals (CIs) for our statistic of
interest, based on the bootstrapped samples. `confint` returns a `Tuple` of `Tuples`,
where each `Tuple` is of the form `(statistic_value, upper_confidence_bound, lower_confidence_bound)`.
A confidence interval is returned for each variable in the bootstrap model.
```julia
## calculate 95% confidence intervals
cil = 0.95;
## basic CI
bci1 = confint(bs1, BasicConfInt(cil));
## percentile CI
bci2 = confint(bs1, PercentileConfInt(cil));
## BCa CI
bci3 = confint(bs1, BCaConfInt(cil));
## Normal CI
bci4 = confint(bs1, NormalConfInt(cil));
```
## References
The [bootstrapping wikipedia article](https://en.wikipedia.org/wiki/Bootstrapping_(statistics))
is a comprehensive introduction into the topic. An extensive description of the
bootstrap is the focus of the book *Davison and Hinkley (1997):
[Bootstrap Methods and Their Application](http://statwww.epfl.ch/davison/BMA/)*.
Most of the methodology covered in the book is implemented in the
[boot](https://cran.r-project.org/web/packages/boot/index.html) package for the
[R programming language](https://www.r-project.org/). [More references](docs/src/references.md)
are listed in the documentation for further reading.
## Contributions and Feedback
Contributions of any kind are very welcome. Please feel free to open pull
requests or issues if you have suggestions for changes, ideas or questions.
## Package Status
[![Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliangehring.github.io/Bootstrap.jl/stable)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.596080.svg)](https://doi.org/10.5281/zenodo.596080)
![Testing](https://github.com/juliangehring/Bootstrap.jl/workflows/Testing/badge.svg)
[![Coverage](https://codecov.io/gh/juliangehring/Bootstrap.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/juliangehring/Bootstrap.jl)
The package uses [semantic versioning](https://semver.org/).