arch.bootstrap.CircularBlockBootstrap.p_value

CircularBlockBootstrap.p_value(func: Callable[[...], ndarray[tuple[int, ...], dtype[float64]]], null: float | ndarray | DataFrame | Series = 0.0, alternative: 'two-sided' | 'less' | 'greater' = 'two-sided', reps: int = 1000, method: 'basic' | 'percentile' | 'studentized' | 'norm' | 'bc' | 'bca' = 'basic', reuse: bool = False, extra_kwargs: dict[str, Any] | None = None, 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 a bootstrap p-value by inverting a confidence interval.

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

Function that computes parameter values. See conf_int() for the required signature.

null: float | ndarray | DataFrame | Series = 0.0

Value(s) of the parameter under the null hypothesis. Must be a scalar or a 1-dimensional array with one value per parameter returned by func.

alternative: 'two-sided' | 'less' | 'greater' = 'two-sided'

The alternative hypothesis. "less" tests that the parameter is less than null, "greater" that it is greater than null, and "two-sided" that it is different from null.

reps: int = 1000

Number of bootstrap replications. Must be at least 1.

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

The confidence interval method to invert. Not case sensitive.

reuse: bool = False

Flag indicating whether to reuse previously computed bootstrap results. The conditions are the same as in conf_int().

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

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

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

Type of sampling to use. Not case sensitive.

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

Function to use when standardizing estimated parameters when using the studentized bootstrap.

studentize_reps: int = 1000

Number of bootstraps to use in the inner bootstrap when using the studentized bootstrap without std_err_func.

Returns:

A 1-dimensional array of p-values, one per parameter returned by func.

Return type:

numpy.ndarray

Raises:
  • TypeError – If func or std_err_func is not callable, reps or studentize_reps is not an int, method, alternative or sampling is not a str, or extra_kwargs is not a dict.

  • ValueError – If reps is less than 1, studentize_reps is less than 1 when it is used, null contains NaN or is not one value per parameter, method, alternative or sampling is not one of the options, or extra_kwargs has a key that is the name of bootstrapped data.

Notes

The p-value is the smallest significance level at which the conf_int() interval excludes null, computed by inverting the interval. When the same bootstrap replications are used, the p-value matches the corresponding conf_int call by construction, for every interval method, including bias-corrected and accelerated intervals.

alternative="less" inverts the upper confidence bound, alternative="greater" inverts the lower bound, and alternative="two-sided" inverts the two-sided interval.

The p-value is resolved by 60 bisection steps, so its effective resolution is about 1 / reps: a p-value is exactly 0 when every replication lies on one side of null.

The studentized method uses the same nested bootstrap as conf_int(). The bias-corrected accelerated method computes the acceleration constant once, before the search.

Examples

>>> import numpy as np
>>> from arch.bootstrap import IIDBootstrap
>>> def func(x):
...     return x.mean(0)
>>> y = np.random.default_rng(1234).standard_normal((1000, 2))
>>> bs = IIDBootstrap(y, seed=1234)
>>> p = bs.p_value(func, null=0.0, reps=1000, method="basic")
>>> p.shape
(2,)