|
1 | 1 | <h1 align="center" style="border-botom: none">
|
2 | 2 | <b>
|
3 |
| - 🐍 A block resampling method used for weakly-dependent stationary time-series data 🐍 |
| 3 | + 🐍 Automatic calibration of the stationary bootstrap algorithm 🐍 |
4 | 4 | </b>
|
5 | 5 | </h1>
|
6 | 6 |
|
7 |
| -Methodology proposed in the 1994 paper by [Politis & Romano](https://www.researchgate.net/publication/254287565_The_Stationary_Bootstrap). |
| 7 | +</br> |
8 | 8 |
|
9 | 9 | ## 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. |
11 | 10 |
|
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. |
13 | 12 |
|
14 | 13 | ## Solution
|
15 | 14 |
|
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) |
18 | 16 |
|
19 | 17 | ### 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. |
26 | 22 |
|
27 | 23 | ## 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. |
28 | 25 |
|
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 |
30 | 27 |
|
31 |
| -```python |
32 | 28 | 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 |
40 | 29 |
|
41 |
| -# Length of output sample |
42 |
| -sampleLength = 12 |
| 30 | +from stationary_bootstrap_calibrate import OptimalLength |
43 | 31 |
|
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]) |
45 | 33 |
|
46 |
| -print(ans) |
| 34 | +m = OptimalLength(data) |
47 | 35 | # Out[0]: 4.0
|
48 |
| -``` |
| 36 | +``` |
0 commit comments