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 thannull,"greater"that it is greater thannull, and"two-sided"that it is different fromnull.- 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
funcandstd_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:¶
- Raises:¶
TypeError – If
funcorstd_err_funcis not callable,repsorstudentize_repsis not an int,method,alternativeorsamplingis not a str, orextra_kwargsis not a dict.ValueError – If
repsis less than 1,studentize_repsis less than 1 when it is used,nullcontains NaN or is not one value per parameter,method,alternativeorsamplingis not one of the options, orextra_kwargshas a key that is the name of bootstrapped data.
Notes
The p-value is the smallest significance level at which the
conf_int()interval excludesnull, computed by inverting the interval. When the same bootstrap replications are used, the p-value matches the correspondingconf_intcall 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, andalternative="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 ofnull.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,)