arch.bootstrap.optimal_block_length¶
- arch.bootstrap.optimal_block_length(x: ndarray[tuple[int], dtype[float64]] | Series | ndarray[tuple[int, int], dtype[float64]] | DataFrame) DataFrame[source]¶
Estimate optimal window length for time-series bootstraps.
- Parameters:¶
- x: ndarray[tuple[int], dtype[float64]] | Series | ndarray[tuple[int, int], dtype[float64]] | DataFrame¶
The data, which can be one-dimensional or two-dimensional. Operates column by column if 2-dimensional. Integer, Boolean and float32 data are converted to float64. float16 and complex data are not accepted. The data must be finite and have at least 11 observations.
- Returns:¶
A DataFrame with two columns stationary, the estimated optimal block size for the Stationary Bootstrap, and circular, the estimated optimal block size for the circular bootstrap. The index contains the column names of x if it is a DataFrame, the name of x if it is a Series and the column positions otherwise.
- Return type:¶
- Raises:¶
TypeError – If
xcannot be converted to float64 (strings, dates, float16 or complex data, or None).ValueError – If
xhas more than 2 dimensions, no columns or fewer than 11 observations, or contains NaN or inf.
See also
arch.bootstrap.StationaryBootstrapPolitis and Romano’s bootstrap with exp. distributed block lengths.
arch.bootstrap.CircularBlockBootstrapCircular (wrap-around) bootstrap.
Notes
Algorithm described in ([1]) its correction ([2]) depends on a tuning parameter m, which is chosen as the first value where k_n consecutive autocorrelations of x are all inside a conservative band of \(\pm 2\sqrt{\log_{10}(n)/n}\) where n is the sample size. The maximum value of m is set to \(\lceil \sqrt{n} + k_n \rceil\) where \(k_n=\max(5, \log_{10}(n))\). The block length is then computed as
\[b^{OPT}_i = \left(\frac{2g^2}{d_{i}} n\right)^{\frac{1}{3}}\]where
\[\begin{split}g & = \sum_{k=-m}^m h\left(\frac{k}{m}\right)|k|\hat{\gamma_{k}} \\ h(x) & = \min(1, 2(1-|x|)) \\ d_{i} & = c_{i} \left(\hat{\sigma}^2\right)^2 \\ \hat{\sigma}^2 & = \sum_{k=-m}^m h\left(\frac{k}{m}\right)\hat{\gamma_{k}} \\ \hat{\gamma_{i}} & = n^{-1} \sum_{k=i+1}^n \left(x_k-\bar{x}\right)\left(x_{k-i}-\bar{x}\right) \\\end{split}\]and the two remaining constants \(c_i\) are 2 for the Stationary bootstrap and 4/3 for the Circular bootstrap.
Some of the tuning parameters are taken from Andrew Patton’s MATLAB program that computes the optimal block length. The block lengths do not match this implementation since the autocovariances and autocorrelations are all computed using the maximum sample length rather than a common sampling length.
References