arch.bootstrap.IIDBootstrap.cov

IIDBootstrap.cov(func: Callable[[...], ndarray | DataFrame | Series], reps: int = 1000, recenter: bool = True, extra_kwargs: dict[str, Any] | None = None) float | ndarray[Any, dtype[float64]][source]

Compute parameter covariance using bootstrap

Parameters:
func: Callable[[...], ndarray | DataFrame | Series]

Callable function that returns the statistic of interest as a 1-d array

reps: int = 1000

Number of bootstrap replications

recenter: bool = True

Whether to center the bootstrap variance estimator on the average of the bootstrap samples (True) or to center on the original sample estimate (False). Default is True.

extra_kwargs: dict[str, Any] | None = None

Dictionary of extra keyword arguments to pass to func

Returns:

Bootstrap covariance estimator

Return type:

numpy.ndarray

Notes

func must have the signature

func(params, *args, **kwargs)

where params are a 1-dimensional array, and *args and **kwargs are data used in the the bootstrap. The first argument, params, will be none when called using the original data, and will contain the estimate computed using the original data in bootstrap replications. This parameter is passed to allow parametric bootstrap simulation.

Examples

Bootstrap covariance of the mean

>>> from arch.bootstrap import IIDBootstrap
>>> import numpy as np
>>> def func(x):
...     return x.mean(axis=0)
>>> y = np.random.randn(1000, 3)
>>> bs = IIDBootstrap(y)
>>> cov = bs.cov(func, 1000)

Bootstrap covariance using a function that takes additional input

>>> def func(x, stat='mean'):
...     if stat=='mean':
...         return x.mean(axis=0)
...     elif stat=='var':
...         return x.var(axis=0)
>>> cov = bs.cov(func, 1000, extra_kwargs={'stat':'var'})

Note

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