cleverly.estimators.DoseResponseTMLE#
- class cleverly.estimators.DoseResponseTMLE(curve: DoseResponse, *, outcome_learner: Any = None, treatment_learner: Any = None, cross_fit: bool = True, n_folds: int = 5, learner_folds: int = 5, density_bins: int | None = None, fluctuation: Literal['logistic', 'linear'] = 'logistic', q_bounds: tuple[float, float] | None = None, alpha: float = 0.05, n_replicates: int = 10000, random_state: int | None = None, n_jobs: int = 1)[source]#
CV-TMLE of a kernel-smoothed dose-response curve at declared bandwidths and doses.
The estimand at each pair is the smoothed curve of
DoseResponse, not the curve at the dose itself. The interval of each pair needs both nuisances consistent, with the product of their errors small next to that pair’s standard error, which is about \((nh)^{-1/2}\).- Parameters:
- curve
DoseResponse The declaration.
- outcome_learner
estimatororNone The outcome regression, fitted with the dose as a feature.
Nonetakes the package default library.- treatment_learner
estimatororNone The classifier behind the pooled-hazard conditional density.
Nonetakes the package default library.- cross_fitbool
Fit the nuisances out of fold.
- n_folds
int The cross-fitting folds.
- learner_folds
int The folds of a Super Learner’s inner split.
- density_bins
intorNone The bins of the conditional density, or
Nonefor the package default.- fluctuation{“logistic”, “linear”}
The submodel on the scaled outcome.
- q_bounds
tupleoffloatorNone The assumed outcome range of a continuous outcome, or
Nonefor the sample range. A cross-fitted fit of a continuous outcome needs it, as every cross-fitted fit does.- alpha
float The level of the intervals and of the band.
- n_replicates
int, default=10_000 Multiplier draws behind the band, with the Mammen multiplier.
- random_state
intorNone Seed of the split, the learners and the band.
- n_jobs
int Parallel jobs for the nuisance fits.
- curve
Methods#
- DoseResponseTMLE.fit(data: Any, *, outcome: str | None = None, treatment: str | None = None, covariates: Sequence[str] | None = None, weights: str | None = None, id: str | None = None, strata: Sequence[str] | None = None) DoseResponseResult[source]#
Fit the curve.
- Parameters:
- data
Any A pandas or polars dataframe, or a prepared
CausalDatawith a continuous treatment.- outcome
strorNone The outcome column, when
datais a dataframe.- treatment
strorNone The dose column, when
datais a dataframe.- covariates
Sequence[str]orNone The covariate columns, when
datais a dataframe.- weights
strorNone The observation-weight column.
- id
strorNone The cluster column.
- strata
Sequence[str]orNone Baseline strata columns, which must also be covariates. Each stratum gets its own curve, \(E\{\int_D w(a)\bar Q(a, W)\,da \mid V = v\}\), from the same nuisance fits.
- data
- Returns:
DoseResponseResultThe curve, its intervals and its band.