# arch.bootstrap.StationaryBootstrap¶

class `arch.bootstrap.``StationaryBootstrap`(block_size, *args, random_state=None, **kwargs)[source]

Politis and Romano (1994) bootstrap with expon distributed block sizes

Parameters
block_size`int`

Average size of block to use

args

Positional arguments to bootstrap

kwargs

Keyword arguments to bootstrap

`arch.bootstrap.optimal_block_length`

Optimal block length estimation

`arch.bootstrap.CircularBlockBootstrap`

Circular (wrap-around) bootstrap

Notes

Supports numpy arrays and pandas Series and DataFrames. Data returned has the same type as the input date.

Data entered using keyword arguments is directly accessibly as an attribute.

To ensure a reproducible bootstrap, you must set the `random_state` attribute after the bootstrap has been created. See the example below. Note that `random_state` is a reserved keyword and any variable passed using this keyword must be an instance of `RandomState`.

Examples

Data can be accessed in a number of ways. Positional data is retained in the same order as it was entered when the bootstrap was initialized. Keyword data is available both as an attribute or using a dictionary syntax on kw_data.

```>>> from arch.bootstrap import StationaryBootstrap
>>> from numpy.random import standard_normal
>>> y = standard_normal((500, 1))
>>> x = standard_normal((500,2))
>>> z = standard_normal(500)
>>> bs = StationaryBootstrap(12, x, y=y, z=z)
>>> for data in bs.bootstrap(100):
...     bs_x = data[0][0]
...     bs_y = data[1]['y']
...     bs_z = bs.z
```

Set the random_state if reproducibility is required

```>>> from numpy.random import RandomState
>>> rs = RandomState(1234)
>>> bs = StationaryBootstrap(12, x, y=y, z=z, random_state=rs)
```
Attributes
data`tuple`

Two-element tuple with the pos_data in the first position and kw_data in the second (pos_data, kw_data)

pos_data`tuple`

Tuple containing the positional arguments (in the order entered)

kw_data`dict`

Dictionary containing the keyword arguments

Methods

 `apply`(func[, reps, extra_kwargs]) Applies a function to bootstrap replicated data `bootstrap`(reps) Iterator for use when bootstrapping `clone`(*args, **kwargs) Clones the bootstrap using different data with a fresh RandomState. `conf_int`(func[, reps, method, size, tail, …]) Parameters `cov`(func[, reps, recenter, extra_kwargs]) Compute parameter covariance using bootstrap Gets the state of the bootstrap’s random number generator `reset`([use_seed]) Resets the bootstrap to either its initial state or the last seed. `seed`(value) Seeds the bootstrap’s random number generator `set_state`(state) Sets the state of the bootstrap’s random number generator Update indices for the next iteration of the bootstrap. `var`(func[, reps, recenter, extra_kwargs]) Compute parameter variance using bootstrap

Methods

 `apply`(func[, reps, extra_kwargs]) Applies a function to bootstrap replicated data `bootstrap`(reps) Iterator for use when bootstrapping `clone`(*args, **kwargs) Clones the bootstrap using different data with a fresh RandomState. `conf_int`(func[, reps, method, size, tail, …]) Parameters `cov`(func[, reps, recenter, extra_kwargs]) Compute parameter covariance using bootstrap Gets the state of the bootstrap’s random number generator `reset`([use_seed]) Resets the bootstrap to either its initial state or the last seed. `seed`(value) Seeds the bootstrap’s random number generator `set_state`(state) Sets the state of the bootstrap’s random number generator Update indices for the next iteration of the bootstrap. `var`(func[, reps, recenter, extra_kwargs]) Compute parameter variance using bootstrap

Properties

 `index` The current index of the bootstrap `random_state` Set or get the instance random state