arch.bootstrap.IIDBootstrap

class arch.bootstrap.IIDBootstrap(*args: ndarray | DataFrame | Series, seed: None | int | RandomState | Generator = None, **kwargs: ndarray | DataFrame | Series)[source]

Bootstrap using uniform resampling

Parameters:
*args: ndarray | DataFrame | Series

Positional arguments to bootstrap

seed: None | int | RandomState | Generator = None

Seed to use to ensure reproducable results. If an int, passes the value to value to np.random.default_rng. If None, a fresh Generator is constructed with system-provided entropy.

**kwargs: ndarray | DataFrame | Series

Keyword arguments to bootstrap

data

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

Type:

tuple

pos_data

Tuple containing the positional arguments (in the order entered)

Type:

tuple

kw_data

Dictionary containing the keyword arguments

Type:

dict

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 seed attribute after the bootstrap has been created. See the example below. Note that seed is a reserved keyword and any variable passed using this keyword must be an integer, a Generator or a 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 IIDBootstrap
>>> from numpy.random import standard_normal
>>> y = standard_normal((500, 1))
>>> x = standard_normal((500,2))
>>> z = standard_normal(500)
>>> bs = IIDBootstrap(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 seed if reproducibility is required

>>> from numpy.random import default_rng
>>> seed = default_rng(1234)
>>> bs = IIDBootstrap(x, y=y, z=z, seed=seed)

This is equivalent to

>>> bs = IIDBootstrap(x, y=y, z=z, seed=1234)

Methods

apply(func[, reps, extra_kwargs])

Applies a function to bootstrap replicated data

bootstrap(reps)

Iterator for use when bootstrapping

clone(*args[, seed])

Clones the bootstrap using different data with a fresh prng.

conf_int(func[, reps, method, size, tail, ...])

cov(func[, reps, recenter, extra_kwargs])

Compute parameter covariance using bootstrap

reset([use_seed])

Resets the bootstrap to either its initial state or the last seed.

update_indices()

Update indices for the next iteration of the bootstrap.

var(func[, reps, recenter, extra_kwargs])

Compute parameter variance using bootstrap

Properties

generator

Set or get the instance PRNG

index

The current index of the bootstrap

state

Set or get the generator's state