arch.bootstrap.LocalBlockBootstrap.conf_int

LocalBlockBootstrap.conf_int(func: Callable[[...], ndarray[tuple[int, ...], dtype[float64]]], reps: int = 1000, method: 'basic' | 'percentile' | 'studentized' | 'norm' | 'bc' | 'bca' = 'basic', size: float = 0.95, tail: 'two' | 'upper' | 'lower' = 'two', extra_kwargs: dict[str, Any] | None = None, reuse: bool = False, sampling: 'nonparametric' | 'semi-parametric' | 'semi' | 'parametric' | 'semiparametric' = 'nonparametric', std_err_func: Callable[[...], ndarray | DataFrame | Series] | None = None, studentize_reps: int = 1000) → ndarray[tuple[int, ...], dtype[float64]]

Compute confidence intervals using the bootstrap.

Parameters:
func: Callable[[...], ndarray[tuple[int, ...], dtype[float64]]]

Function that computes parameter values. See Notes for requirements.

reps: int = 1000

Number of bootstrap replications. Must be at least 1.

method: 'basic' | 'percentile' | 'studentized' | 'norm' | 'bc' | 'bca' = 'basic'

The method used to construct the interval. “norm” is identical to “var” and “cov”, and “bc” is identical to “debiased” and “bias-corrected”. See Notes for a description of each method. Not case sensitive.

size: float = 0.95

Coverage of confidence interval. Must be strictly between 0 and 1.

tail: 'two' | 'upper' | 'lower' = 'two'

The tail of the interval. When tail is “lower”, all upper bounds are inf. Similarly, “upper” sets all lower bounds to -inf. Not case sensitive.

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

Extra keyword arguments to use when calling func and std_err_func, when appropriate.

reuse: bool = False

Flag indicating whether to reuse previously computed bootstrap results. This allows alternative methods to be compared without rerunning the bootstrap simulation. Reuse is ignored if reps is not the same across multiple runs, func changes across calls, or method is “studentized”. Otherwise the previous results are reused even if extra_kwargs or sampling have changed, so use a new call without reuse (or reset) after changing them.

sampling: 'nonparametric' | 'semi-parametric' | 'semi' | 'parametric' | 'semiparametric' = 'nonparametric'

Type of sampling to use. Not case sensitive. “semi” and “semiparametric” are identical to “semi-parametric”. See Semiparametric Bootstraps and Parametric Bootstraps for the changes to func required when using “semi-parametric” or “parametric”.

std_err_func: Callable[[...], ndarray | DataFrame | Series] | None = None

Function to use when standardizing estimated parameters when using the studentized bootstrap. Providing an analytical function eliminates the need for a nested bootstrap.

studentize_reps: int = 1000

Number of bootstraps to use in the inner bootstrap when using the studentized bootstrap. Its value is ignored, but it must be an int, when std_err_func is provided or method is not “studentized”. Otherwise it must be at least 1.

Returns:

Computed confidence interval. Row 0 contains the lower bounds, and row 1 contains the upper bounds. Each column corresponds to a parameter. When tail is ‘lower’, all upper bounds are inf. Similarly, ‘upper’ sets all lower bounds to -inf.

Return type:

numpy.ndarray

Raises:
  • TypeError – If func or std_err_func is not callable, reps or studentize_reps is not an int, size is not a number, reuse is not a bool, method, tail or sampling is not a str, extra_kwargs is not a dict, or func returns complex values, which have no confidence interval.

  • ValueError – If reps is less than 1, size is not in (0, 1), studentize_reps is less than 1 when it is used, method, tail or sampling is not one of the options, or extra_kwargs has a key that is the name of bootstrapped data.

Notes

When there are no extra keyword arguments, the function is called

func(*args, **kwargs)

where args and kwargs are the bootstrap version of the data provided when setting up the bootstrap. When extra keyword arguments are used, these are appended to kwargs before calling func.

The standard error function, if provided, must return a vector of parameter standard errors and is called

std_err_func(params, *args, **kwargs)

where params is the vector of estimated parameters using the same bootstrap data as in args and kwargs. When sampling is "semi-parametric" or "parametric", the keyword arguments params and state that are passed to func to simulate the data are not passed to std_err_func, which only receives the data and extra_kwargs. The studentized bootstrap with a nested bootstrap simulates the data in the nested bootstrap in the same way as in the outer bootstrap.

The bootstraps are:

  • ‘basic’ - Basic confidence using the estimated parameter and difference between the estimated parameter and the bootstrap parameters

  • ‘percentile’ - Direct use of bootstrap percentiles

  • ‘norm’ - Makes use of normal approximation and bootstrap covariance estimator

  • ‘studentized’ - Uses either a standard error function or a nested bootstrap to estimate percentiles and the bootstrap covariance for scale

  • ‘bc’ - Bias corrected using estimate bootstrap bias correction

  • ‘bca’ - Bias corrected and accelerated, adding acceleration parameter to ‘bc’ method

The acceleration parameter used by ‘bca’ is estimated using a leave-one-out jackknife of the observations in the original data. It is the iid jackknife for all bootstraps, including the block bootstraps, and so does not take account of serial dependence or the block size.

When std_err_func is not provided, the standard error used by ‘studentized’ is estimated in each bootstrap sample using a nested bootstrap of the same type as this bootstrap, which applies the same block size to the bootstrap sample. The block size of the nested bootstrap is not selected separately from the block size of this bootstrap. Provide std_err_func to use a different method, for example, a nested block bootstrap with a different block size.

Examples

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