cleverly.IdentifiedEffect#
- class cleverly.IdentifiedEffect(estimand: ATE | ATT | ATC | CounterfactualMean | NaturalCourseMean | PopulationAttributableRisk | PopulationAttributableFraction | RiskRatio | OddsRatio | RegimeMean | RegimeContrast | LearnedRuleValue | ModifiedTreatmentPolicy | ModifiedTreatmentPolicyEffect | IncrementalMean | IncrementalEffect | MSMProjection | ControlledDirectEffect, functional: BackdoorMeanContrast, identification: Identification, provider: IdentificationProvider, protocol: StudyProtocol | None = None, _study: CausalStudy | None = None)[source]#
Bind an estimand to a functional and its identification assumptions.
- Parameters:
- estimand
Estimand Typed causal quantity.
- functional
BackdoorMeanContrast Normalized observed-data target.
- identification
Identification Assumptions, nuisance requirements, and remainder condition.
- provider
IdentificationProvider Provider that performed identification.
- protocol
StudyProtocolorNone Scientific study protocol stamped by
CausalStudy.
- estimand
See also
CausalStudy.identifyWhat returns this object.
MethodAvailabilityOne row of
available_methods().cleverly.EstimationMethodThe configuration
estimate()accepts.
Notes
_studyis the bound study, kept private because it is not part of the reported causal question. An effect built without a study leaves itNone, and such an effect cannot be refitted.Examples
CausalStudy.identify()returns this object. It carries the assumptions the estimate will rest on, and it is what an estimation method is passed to.>>> from cleverly import ATE, CausalStudy, PointTreatment >>> from cleverly.datasets import make_linear_ate >>> frame, _ = make_linear_ate(n=40, seed=1) >>> study = CausalStudy( ... frame, ... design=PointTreatment( ... outcome="Y", treatment="A", adjustment=("W1", "W2", "W3", "W4") ... ), ... ) >>> effect = study.identify(ATE()) >>> effect.estimand.name 'ate' >>> sorted(method.name for method in effect.available_methods())[:2] ['collaborative_tmle', 'drtmle']
Methods#
- IdentifiedEffect.available_methods() tuple[MethodAvailability, ...][source]#
Report estimation methods available for this functional.
- Returns:
tupleofMethodAvailabilityOne capability record for each named method, including refusal reasons.
Notes
The result includes unavailable methods and their refusal reasons. Selecting one raises
CapabilityErrorbefore nuisance fitting starts.availableis per method name. A configuration of an available method can still refuse before any learner. ForLearnedRuleValue, the defaultTMLEMethod()refuses (X11 (e) indocs/roadmap.md), andTMLEMethod(cross_fitting=CrossFitting(fold_evaluation=True))fits.
- IdentifiedEffect.estimate(method: str | EstimationMethod = 'tmle', **overrides: Any) TMLEResult | LongitudinalResult[source]#
Estimate the identified functional.
- Parameters:
- method
strorEstimationMethod Named method or configured method object.
- **overrides
Any Method fields overridden for this fit.
- method
- Returns:
TMLEResultorLongitudinalResultFitted result matching the study design.
- Raises:
CapabilityErrorIf the method is unavailable or the effect has no bound study.
MethodConfigurationErrorIf
methoddoes not satisfy the estimation-method contract.
See also
IdentifiedEffect.available_methodsReport supported methods before fitting.
TMLEMethodConfigure the default estimation method.
Examples
>>> from sklearn.linear_model import LinearRegression, LogisticRegression >>> from cleverly import ATE, CausalStudy, PointTreatment >>> from cleverly.datasets import make_linear_ate >>> frame, _ = make_linear_ate(n=80, seed=1) >>> study = CausalStudy( ... frame, ... design=PointTreatment( ... outcome="Y", treatment="A", adjustment=("W1", "W2", "W3", "W4") ... ), ... ) >>> effect = study.identify(ATE()) >>> result = effect.estimate( ... outcome_learner=LinearRegression(), ... treatment_learner=LogisticRegression(max_iter=1000), ... cross_fit=False, ... random_state=0, ... ) >>> sorted(result.estimates) ['ate']
- IdentifiedEffect.summary(*, protocol: Literal['full', 'fingerprint'] = 'full') str[source]#
Return a readable identification summary.
- Parameters:
- protocol{“full”, “fingerprint”}
"full"prints every field of the protocol record."fingerprint"prints only its schema and fingerprint, for a reader who has the record already.
- Returns:
strA printable block naming the estimand, the functional, and the assumptions.
Attributes#
- IdentifiedEffect.protocol: StudyProtocol | None = None#
- IdentifiedEffect.estimand: ATE | ATT | ATC | CounterfactualMean | NaturalCourseMean | PopulationAttributableRisk | PopulationAttributableFraction | RiskRatio | OddsRatio | RegimeMean | RegimeContrast | LearnedRuleValue | ModifiedTreatmentPolicy | ModifiedTreatmentPolicyEffect | IncrementalMean | IncrementalEffect | MSMProjection | ControlledDirectEffect#
- IdentifiedEffect.functional: BackdoorMeanContrast#
- IdentifiedEffect.identification: Identification#
- IdentifiedEffect.provider: IdentificationProvider#