cleverly.longitudinal.SequentialIPW#

class cleverly.longitudinal.SequentialIPW(regimens: Any, *, normalization: str = 'hajek', **kwargs: Any)[source]#

Inverse probability weighting of a treatment regimen over time.

The estimate reweights the units that follow a regimen by the cumulative ratio of the intervention density to the treatment and censoring mechanism, the clever covariate of LTMLE. normalization="hajek" divides the weighted outcome sum by the weight sum, as R ltmle’s CalcIPTW does. "horvitz_thompson" divides by n. A survival risk under Hajek is the product of the IPW discrete hazards, and a competing cause’s incidence is their Aalen-Johansen sum. See cleverly.longitudinal.baselines.

The estimate is consistent only when every treatment and censoring model is correctly specified. With every model a GLM, the interval is the stacked estimating equation of the mechanism fits and the estimate, which adds the projection term of each mechanism score (Lunceford and Davidian 2004, Section 3.1). That interval is valid for the target only when every GLM is correctly specified. With another learner the fit takes the "adaptive_baseline_plugin" status, and the diagnostic curve is the fixed-mechanism curve.

Parameters:
regimensmapping, Regimen, DynamicRegimen, or sequence of regimens

The regimens, as for LTMLE. A modified treatment policy is refused.

normalization{“hajek”, “horvitz_thompson”}

How the weighted outcome sum is normalized.

referencestr or None

The regimen every contrast is taken against, as for LTMLE.

horizonssequence of int or None

The survival horizons, as for LTMLE.

treatment_learnerobject or None

The treatment mechanism at each node. The default is a GLM.

censoring_learnerobject or None

The censoring mechanism at each node. The default is a GLM.

competing_learnerobject or None

The learner of each eliminated competing event (eliminate= on the data), fit on the rows that passed censoring at the node. None uses the censoring learner.

n_foldsint

Must be 1. The estimator fits in sample.

g_boundsfloat or tuple of float

The bound pair applied to each cumulative mechanism probability. The default is (0.01, 1.0). A bound that binds changes the estimator, and longitudinal_truncation_curve() replays it.

q_boundstuple of float or None

The bounds of a continuous outcome, as for LTMLE.

alpha_sigfloat

Significance level for confidence intervals.

simultaneousbool

Whether to report simultaneous confidence bands, as for LTMLE.

n_multiplierint, default=10_000

The number of multiplier draws behind each band.

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

The distribution of the multiplier draws.

band_scale{“logit”, “identity”}, default=”logit”

The scale of the band of a probability or a difference of two probabilities: "logit" builds it on the logit of the estimate’s position in its range (simultaneous_bands()).

band_reference{“normal”, “t”}, default=”normal”

"t" bands each estimate at the critical value’s tail on its own Student t reference, with degrees of freedom from its influence curve (simultaneous_bands()).

random_stateint or None

The seed inherited by every learner random_state that is None, including a Super Learner’s candidates.

run_idstr or None

An identifier of your own, recorded on LongitudinalResult.provenance.

n_jobsint

Worker count for the parallel fan-out.

n_bootstrapint

Full-refit bootstrap replicates, 0 for none. The draws report a bootstrap sd and no percentile inference.

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

"auto" resamples clusters when id= is declared, and rows otherwise.

**refusedAny

outcome_learner, pseudo_learner, density_bins, ratio and msm, which raise because the estimator fits no outcome regression and no density ratio; alpha, max_iter and tol, which raise TypeError; and each point-treatment keyword that LTMLE refuses. ratio_trim other than None and hazard_pooling other than "node" raise CapabilityError.

See also

SequentialGComputation

The sequential regression estimator of the same parameters.

LTMLE

The targeted estimator of the same parameters.

ipw

The one-call form of this estimator.

Examples

>>> from cleverly.datasets import make_longitudinal
>>> from cleverly.longitudinal import SequentialIPW
>>> frame, _ = make_longitudinal(n=300, seed=0)
>>> result = SequentialIPW({"always": 1, "never": 0}).fit(
...     frame,
...     outcome="Y",
...     treatment=["A1", "A2"],
...     baseline=["W1", "W2"],
...     time_varying=[[], ["L2"]],
...     censoring=["C1", "C2"],
... )
>>> sorted(result.estimates)
['ate_regimen[never vs always]', 'ey_regimen[always]', 'ey_regimen[never]']
>>> result.config.normalization
'hajek'

Methods#

Attributes#