cleverly.inference.BootstrapResult#
- class cleverly.inference.BootstrapResult(draws: dict[str, ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.float64]]], n_requested: int, n_failed: int, resampling: str, std_errors: dict[str, ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.float64]]] = <factory>)[source]#
Bootstrap draws for every estimand, plus how many replicates failed.
- Parameters:
- draws
dictofstrtondarray One array of replicate estimates per estimand alias.
- n_requested
int Replicates asked for.
- n_failed
int Replicates that raised and were dropped. Weak overlap can leave a resample with an empty treatment arm in some stratum, and a cross-fitted replicate is also refused by the fold preflight when its own draw leaves an arm or an outcome class out of a training complement. Either way the interval below is conditional on the replicates that ran, and this count is how far it is from the one that was asked for.
- resampling
str Whether rows or clusters were resampled.
- std_errors
dictofstrtondarray, default={} One array of replicate standard errors per estimand alias, aligned with
draws. Each entry is the replicate fit’s own influence-curve standard error. Empty for draws derived after the fit, whose replicates carry no curve.
- draws
Methods#
- BootstrapResult.summary(name: str, alpha: float = 0.05, *, interval: Literal['percentile', 'bca'] = 'percentile', estimate: float | None = None, acceleration: float | None = None) BootstrapSummary[source]#
The bootstrap interval and standard error for one estimand.
The percentile interval takes
np.quantileof the finite draws. It is the default: the point of running a bootstrap here is usually that the sampling distribution is skewed, and a symmetric interval would throw that information away. The BCa interval (bca_interval()) also corrects the median bias and the skew of the draws.- Parameters:
- name
str Estimand alias to summarise.
- alpha
float Significance level of the interval.
- interval{“percentile”, “bca”}, default=”percentile”
Which interval to compute.
- estimate
floatorNone, default=None The full-sample estimate, which the BCa bias correction compares the draws with. Required with
interval="bca".- acceleration
floatorNone, default=None The BCa acceleration, from
bca_acceleration(). Required withinterval="bca".
- name
- Returns:
BootstrapSummaryThe interval and the bootstrap standard error for that estimand.
- Raises:
ValueErrorWhen
intervalis not one of the two, or"bca"lacksestimateoracceleration.