cleverly.PointTreatment#
- class cleverly.PointTreatment(outcome: str, treatment: str | tuple[str, ...], adjustment: ~collections.abc.Sequence[str] = <factory>, randomized: bool = False, missingness: str | None = None, intermediate: str | None = None, weights: str | None = None, weights_type: ~typing.Literal['probability'] = 'probability', weights_estimated: bool = False, cluster: str | None = None, strata: ~collections.abc.Sequence[str] = <factory>, treatment_kind: ~typing.Literal['discrete', 'continuous'] = 'discrete', outcome_family: ~typing.Literal['gaussian', 'binomial', 'auto'] = 'auto', treatment_missingness: str | None = None, treatment_probabilities: ~typing.Any = None, treatment_adjustment: ~collections.abc.Sequence[str] | None = None, continuous_treatment: ~collections.abc.Sequence[str] = <factory>, treatment_support: ~typing.Any = None, dose_atoms: ~collections.abc.Sequence[float] | ~collections.abc.Mapping[str, ~collections.abc.Sequence[float]] = <factory>)[source]#
Declare column roles for a point-treatment study.
- Parameters:
- outcome
str Outcome column.
- treatment
stror sequenceofstr Discrete treatment or continuous dose column, or the columns of a vector treatment. A vector of categorical columns is one categorical treatment over the observed tuples. A vector with a column in
continuous_treatmenttakesModifiedTreatmentPolicywithJointPolicydeclarations only.- adjustmentsequence
ofstr Baseline adjustment columns. Supply at least one unless
randomized=True.- randomizedbool
Whether the treatment was randomized and an empty adjustment set is intentional.
- missingness
strorNone Outcome-observation indicator. One means observed.
- intermediate
strorNone Binary intermediate column for a controlled direct effect.
- weights
strorNone Probability-weight column.
- weights_type{“probability”}
Interpretation of
weights.- weights_estimatedbool
Whether the supplied weights were estimated from these data.
- cluster
strorNone Independent-cluster identifier used for variance estimation.
- stratasequence
ofstr Baseline strata columns, each also an adjustment column. They define stratum-specific parameters, such as
ate[S=1], reported beside the marginal ones.CausalStudy.identify()refuses a stratum that lacks a treatment arm beside an incremental estimand, and anMSMProjectionwhose design is singular inside a stratum.- treatment_kind{“discrete”, “continuous”}
Treatment support used to select supported estimands, for a treatment of one column. A vector treatment keeps
"discrete"and names its doses incontinuous_treatment.- outcome_family{“auto”, “gaussian”, “binomial”}
Outcome family.
"auto"infers it from observed values.- treatment_missingness
strorNone Treatment-observation indicator. One means the treatment is recorded. It declares a treatment missing at random. The composite indicator identifies the arm means and their contrasts on in-sample TMLE and DRTMLE fits, and their point estimates on the in-sample per-arm outcome-adaptive CTMLE. It also identifies regime means and arm MSMs on in-sample TMLE fits.
- treatment_probabilities
mappingofleveltostr,orNone The known treatment mechanism of a randomized design (a tuple of
(level, column)pairs, the form the design stores, is also accepted): each treatment level mapped to the column that holdsP(A = level | W). Every method then divides by these probabilities in place of an estimate, and the columns are not adjustment covariates. A design names columns, so the array forms ofcleverly.TMLE.fit()are refused here.CollaborativeTMLEMethodis unavailable on such a design, because there is no mechanism to select.- treatment_adjustmentsequence
ofstrorNone The adjustment columns that the treatment mechanism reads, a subset of
adjustment.Nonereads all of them. The outcome regression and every other nuisance keep the full set. The declaration restricts the observed-data model and does not change the estimand. The interval is claimed only under that restriction, and the identification record prints it. An empty sequence declares a marginal treatment mechanism. To exclude instruments, omit them fromadjustmentinstead. The declaration is refused besidetreatment_probabilities, which supplies a known mechanism, and beside an incremental estimand, which shifts the fitted propensity score.- continuous_treatmentsequence
ofstr The columns of a vector
treatmentthat hold a continuous dose.- treatment_support
Support,mappingofstrtoSupport,orNone The declared conditional support of a continuous dose, as
cleverly.TMLE.fit()takes it. A vector treatment maps each continuous component to its support. A modified treatment policy must assign each row a dose inside it.- dose_atomssequence
offloat,ormappingofstrtosequenceoffloat The doses of a continuous treatment with a recorded point mass, as
cleverly.TMLE.fit()takes them. A vector treatment maps each continuous component to its atoms.
- outcome
- Attributes:
treatment_columnstupleofstrThe treatment’s columns: one, or the components of a vector.
treatment_namestrThe treatment’s name: its column, or its components joined by
+.support{“discrete”, “continuous”, “vector”}What the prepared treatment is, as
CausalData.treatment_kindrecords it.
See also
LongitudinalTreatmentThe same declaration for time-varying treatment.
CausalStudyWhat a design is handed to along with the data.
cleverly.datasets.make_linear_ateA frame with the columns this example names.
Examples
>>> from cleverly import PointTreatment >>> design = PointTreatment( ... outcome="Y", treatment="A", adjustment=("age", "baseline_score") ... ) >>> design.treatment 'A'
A randomized trial declares that its empty adjustment set is deliberate:
>>> PointTreatment(outcome="Y", treatment="A", randomized=True).adjustment ()
A trial that knows its allocation probabilities names their columns:
>>> PointTreatment( ... outcome="Y", ... treatment="A", ... adjustment=("age",), ... treatment_probabilities={0: "p_control", 1: "p_treated"}, ... ).treatment_probabilities ((0, 'p_control'), (1, 'p_treated'))
A design can let the treatment mechanism read a subset of the adjustment set:
>>> PointTreatment( ... outcome="Y", ... treatment="A", ... adjustment=("age", "baseline_score"), ... treatment_adjustment=("age",), ... ).treatment_adjustment ('age',)
Methods#
Attributes#
- PointTreatment.support#
What the prepared treatment is, as
CausalData.treatment_kindrecords it."vector"is a vector with a continuous component, which has no arms. An all-categorical vector is"discrete": one categorical treatment over its tuples.
- PointTreatment.treatment_columns#
The treatment’s columns: one, or the components of a vector.
- PointTreatment.treatment_name#
The treatment’s name: its column, or its components joined by
+.