cleverly.IPWMethod#

class cleverly.IPWMethod(models: ModelSpec = ModelSpec(outcome_learner=None, treatment_learner=None, missingness_learner=None, intermediate_learner=None, pseudo_learner=None, censoring_learner=None, density_bins=None, ratio='density', screen_treatment=False, screen_threshold=0.1, min_retain=None, outcome_by_arm=False, survival_model='iterated_mean'), cross_fitting: CrossFitting = CrossFitting(enabled=False, n_folds=10, learner_folds=5, repeats=1, stratify_by='none', targeting_scheme='pooled', fold_evaluation=False, split_plan=None), targeting: Targeting = Targeting(fluctuation='logistic', algorithm='iterative', g_bounds='auto', q_bounds=None, nuisance_bound=0.01, submodel_alpha=0.9995, target_weights=False, step_size=0.001, max_iter=20, tol=1e-10, stopping='relative', step_bound=None, step_search=True, iterate='last', isotonic=False), inference: Inference = Inference(alpha=0.05, n_bootstrap=0, bootstrap_resampling='auto', simultaneous=True, n_multiplier='auto', multiplier_kind='rademacher'), runtime: Runtime = Runtime(random_state=None, run_id=None, n_jobs=1), name: str = 'ipw', normalization: Literal['hajek', 'horvitz_thompson'] = 'hajek')[source]#

Configure sequential inverse probability weighting of a longitudinal regimen.

The estimator fitted by cleverly.longitudinal.SequentialIPW. It reads the treatment and censoring mechanisms only, and fits no outcome regression. The method fits in sample, so cross_fitting defaults to CrossFitting(enabled=False). It fits no fluctuation, so the fluctuation settings of Targeting stay at their defaults. A point-treatment functional, a working model over regimens, a modified treatment policy, and an odds tilt with an estimated mechanism refuse the method.

Parameters:
modelsModelSpec

Nuisance learners. treatment_learner and censoring_learner fit the mechanisms. outcome_learner and pseudo_learner are refused.

cross_fittingCrossFitting

Sample-splitting settings. The default is in sample, and the engine refuses more than one fold.

targetingTargeting

g_bounds and q_bounds. submodel_alpha, max_iter, tol, stopping, step_bound, step_search and iterate are refused, because the estimator fits no fluctuation.

inferenceInference

Interval and resampling settings.

runtimeRuntime

Seed, run identifier, and parallelism.

namestr

Stable method name.

normalization{“hajek”, “horvitz_thompson”}, default=”hajek”

"hajek" divides the weighted outcome sum by the weight sum. "horvitz_thompson" divides by n.

See also

GComputationMethod

The outcome-regression baseline.

SDRMethod

The sequentially doubly robust estimator of the same parameters.

cleverly.longitudinal.SequentialIPW

The engine this configuration is translated for.

cleverly.LongitudinalTreatment

The design whose functionals take this method.

Examples

>>> from cleverly import IPWMethod
>>> method = IPWMethod(normalization="horvitz_thompson")
>>> method.name, method.cross_fitting.enabled
('ipw', False)
>>> method.estimator_kwargs(longitudinal=True)["normalization"]
'horvitz_thompson'

Methods#

IPWMethod.estimator_kwargs(*, longitudinal: bool = False) → dict[str, Any][source]#

Translate this configuration for the longitudinal IPW engine.

Parameters:
longitudinalbool

Must be true, because the estimator is longitudinal.

Returns:
dict of str to Any

IPW engine keyword arguments, with normalization.

Raises:
MethodConfigurationError

When longitudinal is false, or when a fluctuation setting differs from its default.

Attributes#

IPWMethod.name: str = 'ipw'#
IPWMethod.normalization: Literal['hajek', 'horvitz_thompson'] = 'hajek'#