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:
drawsdict of str to ndarray

One array of replicate estimates per estimand alias.

n_requestedint

Replicates asked for.

n_failedint

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.

resamplingstr

Whether rows or clusters were resampled.

std_errorsdict of str to ndarray, 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.

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.quantile of 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:
namestr

Estimand alias to summarise.

alphafloat

Significance level of the interval.

interval{“percentile”, “bca”}, default=”percentile”

Which interval to compute.

estimatefloat or None, default=None

The full-sample estimate, which the BCa bias correction compares the draws with. Required with interval="bca".

accelerationfloat or None, default=None

The BCa acceleration, from bca_acceleration(). Required with interval="bca".

Returns:
BootstrapSummary

The interval and the bootstrap standard error for that estimand.

Raises:
ValueError

When interval is not one of the two, or "bca" lacks estimate or acceleration.

Attributes#

BootstrapResult.draws: dict[str, ndarray[tuple[Any, ...], dtype[float64]]]#
BootstrapResult.n_requested: int#
BootstrapResult.n_failed: int#
BootstrapResult.resampling: str#
BootstrapResult.std_errors: dict[str, ndarray[tuple[Any, ...], dtype[float64]]]#