Skip to content

Commit 63195e1

Browse files
reverted
1 parent 87d2a64 commit 63195e1

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed
Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,36 @@
11
<h1 align="center" style="border-botom: none">
22
<b>
3-
🐍 A block resampling method used for weakly-dependent stationary time-series data 🐍
3+
🐍 Automatic calibration of the stationary bootstrap algorithm 🐍
44
</b>
55
</h1>
66

7-
Methodology proposed in the 1994 paper by [Politis & Romano](https://www.researchgate.net/publication/254287565_The_Stationary_Bootstrap).
7+
</br>
88

99
## Problem
10-
When using non-parametric tools to generate counterfactual scenarios or empirical distributions, bootstrapping methods proved to be a powerful and easy-to-use tools. However, the bootstrap in its simplest implementation assumes a time-series in which observations are independent. In a lot of applications this is not the case.
1110

12-
An example of this is interest rate modelling when business cycles need to be considered. The presence of business cycles makes the time-series weakly time dependent. To account for this property, block-resampling techniques are used.
11+
Implementation of a stationary bootstrap method for weakly dependent stationary data requires the selection of the average block length as input. This can be time-consuming and introduce a degree of subjectivity into the implementation.
1312

1413
## Solution
1514

16-
Stationary bootstrap is a block-resampling technique that relaxes the assumption in a classical bootstrap where the sampling block has a fixed-length. The user still needs to specify an average length, but because this is than applied as a statistical average, shorter/longer blocks are also present in the final sample.
17-
The algorithm works by randomly selecting a starting point in the time-series and at each step it either increases the block size by one or selects a new block with a new starting point. This choice happens with a fixed probability governed by the parametrisation.
15+
The proposed methodology automatically estimates the optimal block size. As mentioned in the original paper, the methodology is based on the notion of spectral estimation via the flat-top lag-windows of Politis and Romano (1995). The proposed solution is described in the paper [Polis and White (2004)](http://public.econ.duke.edu/~ap172/Politis_White_2004.pdf)
1816

1917
### Input
20-
- A time-series that you want to bootstrap.
21-
- The parameter m describing the average duration of the blocks in the sample.
22-
- The length of the output sample.
23-
24-
### Output
25-
- Vector of bootstrapped values of specified length.
18+
- The time-series for which the calibration is necessary `data`.
19+
20+
### Output
21+
- Integer specifying the optimal block length.
2622

2723
## Getting started
24+
Given a time series with values 0.4, 0.2, 0.1, 0.4, 0.3, 0.1, 0.3, 0.4, 0.2, 0.5, 0.1, and 0.2 the user desires to use the stationary bootstrap algorithm for resampling. The objective is to automatically retrieve the "optimal" value of the parameter needed for stationary bootstrap algorithm.
2825

29-
Given the time-series with observed values 0.4, 0.2, 0.1, 0.4, 0.3, 0.1, 0.3, 0.4, 0.2, 0.5, 0.1, and 0.2, the user is looking to bootstrap a new sample of length 9 where the average block is of size 4.
26+
```bash
3027

31-
```python
3228
import numpy as np
33-
from StationaryBootstrap import StationaryBootstrap
34-
35-
# Original time-series
36-
data = np.array([0.4,0.2,0.1,0.4,0.3,0.1,0.3,0.4,0.2,0.5,0.1,0.2])
37-
38-
# Average length of the block
39-
m = 4
4029

41-
# Length of output sample
42-
sampleLength = 12
30+
from stationary_bootstrap_calibrate import OptimalLength
4331

44-
ans = StationaryBootstrap(data, m, sampleLength)
32+
data = np.array([0.4, 0.2, 0.1, 0.4, 0.3, 0.1, 0.3, 0.4, 0.2, 0.5, 0.1, 0.2])
4533

46-
print(ans)
34+
m = OptimalLength(data)
4735
# Out[0]: 4.0
48-
```
36+
```

0 commit comments

Comments
 (0)