arch.bootstrap.IndependentSamplesBootstrap.var

IndependentSamplesBootstrap.var(func, reps=1000, recenter=True, extra_kwargs=None)

Compute parameter variance using bootstrap

Parameters
funccallable()

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

repsint, default 1000

Number of bootstrap replications

recenterbool, default 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, default None

Dictionary of extra keyword arguments to pass to func

Returns
ndarray

Bootstrap variance estimator

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)
>>> variances = bs.var(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)
>>> variances = bs.var(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

Return type

Union[float, ndarray]