cleverly.CausalResult#
- class cleverly.CausalResult(*args, **kwargs)[source]#
Define operations shared by fitted causal-result families.
Concrete point-treatment and longitudinal results provide this interface. Use the protocol when application code accepts either result family.
- Parameters:
- *args, **kwargs
Present because
typing.runtime_checkable()gives a protocol a synthetic constructor. A protocol is implemented, not instantiated.
- Attributes:
- estimates
mappingofstrtoParameterEstimate Estimates keyed by stable parameter alias.
- identified_effect
IdentifiedEffect Causal question and identifying assumptions used for the fit.
- method
EstimationMethod Method configuration used for estimation.
- parameter_keys
mappingofstrtoParameterKey Structured identities for the reported aliases.
- provenance
Provenance Runtime and dependency information for the fit.
- assessment_cache
mapping Saved diagnostic and sensitivity artifacts.
- assessment_family
str Result-owned capability family declaration.
- estimate
ParameterEstimate The sole parameter estimate. A concrete result raises
ValueErrorhere when it reports more than one parameter, soisinstancedoes not presence-check it. Usepsi()or item access to name the parameter you want.
- estimates
Notes
typing.runtime_checkable()givesisinstancea presence check over every member this class body declares. On Python 3.11 that check reads each member withhasattr(), which calls a property and swallows onlyAttributeError. A member whose read can raise anything else therefore turnsisinstanceinto an exception.estimateis such a member, so this class declares it undertyping.TYPE_CHECKING: a type checker still sees it, and the runtime check does not read it. Add a new member here only when reading it on every supported result cannot raise.
Methods#
- CausalResult.assess(*, include_refits: bool = False, include_retargets: bool = False, arguments: Mapping[str, Mapping[str, Any]] | None = None, random_state: int | None = None) AssessmentReport[source]#
Run the applicable post-fit assessment battery.
- Parameters:
- Returns:
AssessmentReportValidation, diagnostics, and sensitivity in one report.
- CausalResult.contrast(function: Any, names: Sequence[str], **kwargs: Any) Any[source]#
Apply the delta method to a smooth function of estimates.
- Parameters:
- function
callable() Function from a parameter vector to one scalar.
- namessequence
ofstr Parameter aliases passed to
functionin order.- **kwargs
Any Options forwarded to the concrete result implementation.
- function
- Returns:
ParameterEstimateTransformed estimate and influence-curve inference.
- CausalResult.covariance(names: Sequence[str] | None = None) Any[source]#
Estimate covariance for selected parameters.
- CausalResult.ratio(numerator: str, denominator: str, **kwargs: Any) Any[source]#
Return the risk ratio or odds ratio of two level estimates.
- Parameters:
- Returns:
ParameterEstimateThe ratio, with its interval on the log scale.
- CausalResult.save(path: Any) Any[source]#
Serialize the fitted result.
- Parameters:
- pathpath-like
Destination for the serialized result.
- Returns:
PathThe destination path, as given.
Attributes#
- CausalResult.diagnostics#
Return the diagnostics facade for saved fit artifacts.
- CausalResult.influence_curves#
Return influence curves keyed by parameter alias.
- CausalResult.replayability#
Report which analyses this result can replay.
- CausalResult.sensitivity#
Return the sensitivity-analysis facade for this result.