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 Rltmle’sCalcIPTWdoes."horvitz_thompson"divides byn. A survival risk under Hajek is the product of the IPW discrete hazards, and a competing cause’s incidence is their Aalen-Johansen sum. Seecleverly.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:
- regimens
mapping,Regimen,DynamicRegimen,orsequenceofregimens The regimens, as for
LTMLE. A modified treatment policy is refused.- normalization{“hajek”, “horvitz_thompson”}
How the weighted outcome sum is normalized.
- reference
strorNone The regimen every contrast is taken against, as for
LTMLE.- horizonssequence
ofintorNone The survival horizons, as for
LTMLE.- treatment_learner
objectorNone The treatment mechanism at each node. The default is a
GLM.- censoring_learner
objectorNone The censoring mechanism at each node. The default is a
GLM.- competing_learner
objectorNone The learner of each eliminated competing event (
eliminate=on the data), fit on the rows that passed censoring at the node.Noneuses the censoring learner.- n_folds
int Must be
1. The estimator fits in sample.- g_bounds
floatortupleoffloat The bound pair applied to each cumulative mechanism probability. The default is
(0.01, 1.0). A bound that binds changes the estimator, andlongitudinal_truncation_curve()replays it.- q_bounds
tupleoffloatorNone The bounds of a continuous outcome, as for
LTMLE.- alpha_sig
float Significance level for confidence intervals.
- simultaneousbool
Whether to report simultaneous confidence bands, as for
LTMLE.- n_multiplier
int, 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_state
intorNone The seed inherited by every learner
random_statethat isNone, including a Super Learner’s candidates.- run_id
strorNone An identifier of your own, recorded on
LongitudinalResult.provenance.- n_jobs
int Worker count for the parallel fan-out.
- n_bootstrap
int Full-refit bootstrap replicates,
0for none. The draws report a bootstrap sd and no percentile inference.- bootstrap_resampling{“auto”, “iid”, “cluster”}
"auto"resamples clusters whenid=is declared, and rows otherwise.- **refused
Any outcome_learner,pseudo_learner,density_bins,ratioandmsm, which raise because the estimator fits no outcome regression and no density ratio;alpha,max_iterandtol, which raiseTypeError; and each point-treatment keyword thatLTMLErefuses.ratio_trimother thanNoneandhazard_poolingother than"node"raiseCapabilityError.
- regimens
See also
SequentialGComputationThe sequential regression estimator of the same parameters.
LTMLEThe targeted estimator of the same parameters.
ipwThe 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'