arch.bootstrap.IIDBootstrap.bootstrap

IIDBootstrap.bootstrap(reps: int) → Generator[tuple[tuple[ndarray | DataFrame | Series, ...], dict[str, ndarray | DataFrame | Series]], None, None][source]

Iterate over the bootstrap replications.

Parameters:
reps: int

Number of bootstrap replications. Must be at least 1.

Returns:

An iterator over the replications. It yields a tuple with the data of one bootstrap replication. The first element is a tuple containing the data entered in positional arguments and the second element is a dict containing the data entered using keywords.

Return type:

generator

Raises:
  • TypeError – If reps is not an int.

  • ValueError – If reps is less than 1. A moving block bootstrap also raises if its block size is larger than the number of observations.

Notes

The iterator returns a tuple containing the data entered in positional arguments as a tuple and the data entered using keywords as a dictionary.

Examples

The key steps are problem dependent and so this example shows the use as an iterator that does not produce any output

>>> from arch.bootstrap import IIDBootstrap
>>> import numpy as np
>>> bs = IIDBootstrap(np.arange(100), x=np.random.randn(100))
>>> for posdata, kwdata in bs.bootstrap(1000):
...     # Do something with the positional data and/or keyword data
...     pass

Note

Note this is a generic example and so the class used should be the name of the required bootstrap.