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:
curveDoseResponse

The declaration.

outcome_learnerestimator or None

The outcome regression, fitted with the dose as a feature. None takes the package default library.

treatment_learnerestimator or None

The classifier behind the pooled-hazard conditional density. None takes the package default library.

cross_fitbool

Fit the nuisances out of fold.

n_foldsint

The cross-fitting folds.

learner_foldsint

The folds of a Super Learner’s inner split.

density_binsint or None

The bins of the conditional density, or None for the package default.

fluctuation{“logistic”, “linear”}

The submodel on the scaled outcome.

q_boundstuple of float or None

The assumed outcome range of a continuous outcome, or None for the sample range. A cross-fitted fit of a continuous outcome needs it, as every cross-fitted fit does.

alphafloat

The level of the intervals and of the band.

n_replicatesint, default=10_000

Multiplier draws behind the band, with the Mammen multiplier.

random_stateint or None

Seed of the split, the learners and the band.

n_jobsint

Parallel jobs for the nuisance fits.

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:
dataAny

A pandas or polars dataframe, or a prepared CausalData with a continuous treatment.

outcomestr or None

The outcome column, when data is a dataframe.

treatmentstr or None

The dose column, when data is a dataframe.

covariatesSequence[str] or None

The covariate columns, when data is a dataframe.

weightsstr or None

The observation-weight column.

idstr or None

The cluster column.

strataSequence[str] or None

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.

Returns:
DoseResponseResult

The curve, its intervals and its band.