cleverly.Inference#

class cleverly.Inference(alpha: float = 0.05, n_bootstrap: int = 0, bootstrap_resampling: Literal['auto', 'iid', 'cluster'] = 'auto', simultaneous: bool = True, n_multiplier: int | Literal['auto'] = 'auto', multiplier_kind: Literal['rademacher', 'mammen', 'normal'] = 'rademacher')[source]#

Configure confidence intervals and resampling.

Parameters:
alphafloat, default=0.05

Significance level for reported intervals.

n_bootstrapint, default=0

Bootstrap fits. Zero disables full-refit bootstrap inference.

bootstrap_resampling{“auto”, “iid”, “cluster”}, default=”auto”

Unit or cluster resampling policy.

simultaneousbool, default=True

Whether multi-parameter results include simultaneous bands.

n_multiplierint or {“auto”}, default=”auto”

Multiplier draws for simultaneous bands.

multiplier_kind{“rademacher”, “mammen”, “normal”}, default=”rademacher”

Distribution of multiplier weights.

See also

TMLEMethod

Method configuration this object is the inference half of.

Targeting

Owns submodel_alpha, which is not a significance level.

cleverly.inference.run_bootstrap

The full-refit bootstrap n_bootstrap requests.

Examples

Report 99 percent intervals and add a cluster bootstrap:

>>> from cleverly import Inference
>>> inference = Inference(alpha=0.01, n_bootstrap=200, bootstrap_resampling="cluster")
>>> inference.alpha, inference.n_bootstrap, inference.bootstrap_resampling
(0.01, 200, 'cluster')

alpha is the significance level. The confidence level is 1 - alpha. The logistic-submodel bound lives on Targeting and is spelled differently for that reason:

>>> from cleverly import Targeting
>>> Targeting().submodel_alpha
0.9995

Methods#

Attributes#

Inference.alpha: float = 0.05#

Significance level of the reported intervals, and what the alpha= shortcut sets. Not to be confused with Targeting.submodel_alpha, which bounds the logistic submodel and is reached as submodel_alpha=.

Inference.bootstrap_resampling: Literal['auto', 'iid', 'cluster'] = 'auto'#
Inference.multiplier_kind: Literal['rademacher', 'mammen', 'normal'] = 'rademacher'#
Inference.n_bootstrap: int = 0#
Inference.n_multiplier: int | Literal['auto'] = 'auto'#

Multiplier-bootstrap draws behind the simultaneous bands. "auto" is each engine’s own default, which is not one number: the point path draws 1000 and the sequential path draws 2000. A single literal here would silently pick one of them for the other engine – and it did, halving every study-driven longitudinal fit’s draws with nothing to read that said so. Resolved in TMLEMethod.estimator_kwargs(), exactly as g_bounds is; the stored configuration keeps "auto" so it still says “the engine’s default”.

Inference.simultaneous: bool = True#