cleverly.inference.run_bootstrap#
- cleverly.inference.run_bootstrap(data: Resamplable, refit: Callable[[Any], Mapping[str, tuple[float, float]]], *, n_replicates: int, resampling: Literal['auto', 'iid', 'cluster'] = 'auto', random_state: int | None = None, n_jobs: int = 1) BootstrapResult[source]#
Run
n_replicatesfull-refit bootstrap replicates.- Parameters:
- data
CausalDataorLongitudinalData Validated study data to resample.
- refit
callable() Maps a resampled container of the same type to a mapping of estimand name to
(estimate, standard error)(RefitFn). Replicates that raise are dropped and counted rather than aborting the run: with weak overlap a resample can easily end up with an empty treatment arm in some stratum.- n_replicates
int How many replicates to draw.
- resampling{“auto”, “iid”, “cluster”}
"auto"resamples clusters when the data has them, and rows otherwise."iid"always resamples rows."cluster"requires cluster ids and is refused without them. Any other value is refused.- random_state
intorNone Seed for the replicate draws.
- n_jobs
int Number of joblib workers.
- data
- Returns:
BootstrapResultThe replicate estimates and standard errors, and how many replicates failed.
- Raises:
TypeErrorWhen a replicate’s refit returns anything but
(estimate, standard error)pairs.