cleverly.longitudinal.SurvivalCTMLE#
- class cleverly.longitudinal.SurvivalCTMLE(regimens: Any, *, reference: str | None = None, horizons: Sequence[int] | None = None, outcome_learner: Any | None = None, n_folds: int = 1, learner_folds: int = 5, g_bounds: Any = (0.01, 1.0), alpha: float = 0.9995, alpha_sig: float = 0.05, max_iter: int = 20, tol: float = 1e-10, selection_folds: int = 5, selection_split: Sequence[int] | None = None, penalty: bool = True, hazard_pooling: str = 'node', random_state: int | None = None, run_id: str | None = None, n_jobs: int = 1, survival_model: str = 'hazard', targeting: str = 'iterative', simultaneous: bool = False, n_multiplier: int = 10000, multiplier_kind: str = 'mammen', band_scale: str = 'logit', band_reference: str = 'normal', repeats: int = 1, n_bootstrap: int = 0, bootstrap_resampling: Any = 'auto', bootstrap_interval: Any = 'percentile', stopping: Any = 'relative', step_bound: float | None = None, step_search: bool = True, iterate: Any = 'last', step_size: float = 0.001, q_bounds: tuple[float, float] | None = None, msm: Any = None, node_bounds: Mapping[Any, Any] | None = None, ratio_trim: float | None = None, isotonic: bool = False, pseudo_learner: Any | None = None, treatment_learner: Any | None = None, censoring_learner: Any | None = None, competing_learner: Any | None = None, density_bins: int | None = None, ratio: str = 'density', strategy: str = 'greedy', patience: int | None = None, candidates: Any = None, ordering: Any = None, preorder: str | None = None, lambdas: Any = None, treatment_candidates: Any = None, oat_design: str | None = None, selection_inner_folds: int = 2, selection_estimand: str | None = None, loss: str = 'auto', **refused: Any)[source]#
Collaborative TMLE of a treatment-specific risk curve (Stitelman and van der Laan 2010).
For each horizon and each static arm of a binary baseline treatment, the fit selects a main-term logistic treatment model and a main-term pooled logistic censoring model by the greedy collaborative search of the source, and reports the risk of the arm from that selection’s targeted event hazard. The module docstring of
cleverly.longitudinal.collaborativestates the search, the loss and the penalty. Every estimate is a point:std_error,ciandpvalueraise, andplugin_std_errorandplugin_intervalkeep the hazard influence curve at the selected state as a diagnostic. The memory guard ofLTMLEdoes not check this fit: its memory is outside that guard’s calibration.- Parameters:
- regimens
mappingor sequence Static arms of the binary baseline treatment, such as
{"a1": 1, "a0": 0}.- reference
strorNone, default=None The regimen every contrast is taken against; the first declared by default.
- horizonssequence
ofintorNone, default=None The nodes the curve is reported at. Each horizon runs its own selections, so naming the horizons you need saves time.
- outcome_learner
estimatororNone, default=None The learner of the initial event hazard \(\hat Q_2\), fitted once on the full data and held fixed through the selection.
Noneuses the default Super Learner.- n_folds
int, default=1 The outer split.
1fits \(\hat Q_2\) and every candidate in sample, the source’s setting. At2or more, \(\hat Q_2\) and each full-data candidate are fitted out of fold.- learner_folds
int, default=5 The internal folds of a Super Learner outcome learner.
- g_bounds
floatortupleoffloat, default=(0.01, 1.0) The bound of each cumulative mechanism product, as on hazard
LTMLE.- alpha
float, default=0.9995 The probability bound of every hazard.
- alpha_sig
float, default=0.05 The significance level of the plug-in diagnostic interval.
- max_iter
int, default=20 Outer iterations of each targeting solve.
- tol
float, default=1e-10 The relative-score tolerance of each targeting solve.
- selection_folds
int, default=5 The folds of the cross-validated move count. The source does not state its count.
- selection_splitsequence
ofintorNone, default=None Fold labels
0toV - 1per row, in place of the random selection split.- penaltybool, default=True
Whether the risk adds the printed penalty (24) of the source.
- hazard_pooling{“node”, “pooled”}, default=”node”
How \(\hat Q_2\) pools the nodes. The censoring candidates always pool the nodes with one indicator per node.
- random_state
intorNone, default=None Seeds the outer split, the selection split and the outcome learner.
- run_id
strorNone, default=None A label for the run record.
- n_jobs
int, default=1 Workers of the outcome learner.
- regimens
See also
cleverly.longitudinal.LTMLEHazard targeting with a fitted mechanism, with intervals.
cleverly.estimators.CTMLECollaborative TMLE of a point-treatment mean.
Notes
The other keywords of
LTMLEand of pointCTMLEare accepted only at their defaults, and every other value raises before any learner with the reason the design records: a band, a bootstrap, a repeated split, a non-greedy strategy, a learner for the mechanisms, a projection and a targeting rule each have no source here.loss="loglik"equals the default"auto".Examples
>>> import numpy as np >>> import pandas as pd >>> from sklearn.linear_model import LogisticRegression >>> from cleverly.longitudinal import LongitudinalData, SurvivalCTMLE >>> rng = np.random.default_rng(0) >>> n = 300 >>> w1, w2 = rng.normal(size=n), rng.normal(size=n) >>> a = rng.binomial(1, 1 / (1 + np.exp(-0.5 * w1))) >>> event = rng.binomial(1, 1 / (1 + np.exp(0.5 - 0.6 * w1 + 0.5 * a))) >>> time = np.where(event == 1, rng.integers(1, 3, size=n), 2).astype(float) >>> frame = pd.DataFrame({"time": time, "event": event, "A": a, "W1": w1, "W2": w2}) >>> data = LongitudinalData.from_time_to_event( ... frame, time="time", event="event", treatment="A", baseline=["W1", "W2"] ... ) >>> result = SurvivalCTMLE( ... {"a1": 1, "a0": 0}, ... reference="a0", ... outcome_learner=LogisticRegression(), ... selection_folds=3, ... random_state=0, ... ).fit(data) >>> sorted(result.selection) [('a0', 1), ('a0', 2), ('a1', 1), ('a1', 2)] >>> result.inference_status 'working_mechanism_plugin'