cleverly.assessment.SensitivityFacade#
- class cleverly.assessment.SensitivityFacade(result: Any)[source]#
Access sensitivity analyses supported by a fitted causal result.
- Parameters:
- result
TMLEResultorLongitudinalResult Fitted point-treatment or longitudinal result.
- result
See also
DiagnosticsFacadeThe checks that ask whether the fit itself is sound.
cleverly.AssessmentCapabilityOne row of
capabilities.cleverly.sensitivity.evalue.evalueThe same analysis as a free function.
Notes
Access this facade through
result.sensitivity. Methods use the fitted estimate and nuisance artifacts as their first input. Their remaining arguments match the corresponding functions incleverly.sensitivity. Inspectcapabilitiesto distinguish an unsupported analysis from one that needs additional arguments or expensive work.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=200, seed=0) >>> study = CausalStudy( ... frame, ... design=PointTreatment( ... outcome="Y", treatment="A", adjustment=("W1", "W2", "W3", "W4") ... ), ... ) >>> result = study.identify(ATE()).estimate( ... outcome_learner=LinearRegression(), ... treatment_learner=LogisticRegression(max_iter=1000), ... cross_fit=False, ... random_state=0, ... ) >>> capability = result.sensitivity.capability("omitted_confounding") >>> capability.available, capability.cost (True, 'cheap')
Methods#
- SensitivityFacade.benchmark(*args: Any, **kwargs: Any) Any[source]#
Benchmark confounding strength against observed covariates.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.benchmark(), without its first argument, which this facade supplies from the fitted result.
- Returns:
BenchmarkResultConfounding strength expressed in units of the named observed covariates.
See also
cleverly.sensitivity.benchmarkThe same benchmark as a free function.
Notes
A name the fit does not adjust for raises
DataErrorbefore any refusal, as the free function raises it.
- SensitivityFacade.contour(*args: Any, **kwargs: Any) Any[source]#
Evaluate bias bounds over a confounding-strength grid.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.contour_data(), without its first argument, which this facade supplies from the fitted result.
- Returns:
dataframeBias bounds over the requested grid of confounding strengths.
See also
cleverly.sensitivity.contour_dataThe same grid as a free function.
- SensitivityFacade.elements(*args: Any, **kwargs: Any) Any[source]#
Return the variance elements used by omitted-variable bounds.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.sensitivity_elements(), without its first argument, which this facade supplies from the fitted result.
- Returns:
SensitivityElementsThe variance elements the omitted-variable bounds are built from.
See also
cleverly.sensitivity.sensitivity_elementsThe same elements as a free function.
- SensitivityFacade.evalue(*args: Any, **kwargs: Any) Any[source]#
Return an E-value on the risk-ratio scale.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.evalue(), without its first argument, which this facade supplies from the fitted result.
- Returns:
EValueThe minimum risk-ratio association that would explain the effect away.
See also
cleverly.sensitivity.evalueThe same E-value as a free function.
- SensitivityFacade.missingness(*args: Any, **kwargs: Any) Any[source]#
Vary unobserved-outcome odds under a missingness tilt.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.missingness_tilt(), without its first argument, which this facade supplies from the fitted result.
- Returns:
dataframeOne row per tilt value and estimand.
See also
cleverly.sensitivity.missingness_tiltThe same tilt as a free function.
- SensitivityFacade.omitted_confounding(*args: Any, **kwargs: Any) Any[source]#
Bound omitted-confounder bias for a reported estimand.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.omitted_variable_bounds(), without its first argument, which this facade supplies from the fitted result.
- Returns:
SensitivityBoundsBias bounds for each requested estimand.
See also
cleverly.sensitivity.omitted_variable_boundsThe same bound as a free function.
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") ... ), ... ) >>> result = study.identify(ATE()).estimate( ... outcome_learner=LinearRegression(), ... treatment_learner=LogisticRegression(max_iter=1000), ... cross_fit=False, ... random_state=0, ... ) >>> bounds = result.sensitivity.omitted_confounding(cf_y=0.05, cf_d=0.05) >>> bounds.lower < result["ate"].psi < bounds.upper True
- SensitivityFacade.robustness_value(*args: Any, **kwargs: Any) Any[source]#
Return the confounding strength needed to cross the null.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.robustness_value(), without its first argument, which this facade supplies from the fitted result.
- Returns:
See also
cleverly.sensitivity.robustness_valueThe same value as a free function.
- SensitivityFacade.run_all(*, include_refits: bool = False, include_retargets: bool = False, arguments: Mapping[str, Mapping[str, Any]] | None = None, random_state: int | None = None) DiagnosticReport[source]#
Run available sensitivity analyses that need no new arguments.
- Parameters:
- Returns:
DiagnosticReportOne item for every declared sensitivity operation.
- SensitivityFacade.simulated_confounding(*args: Any, **kwargs: Any) Any[source]#
Refit across a simulated common-cause strength grid.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.simulated_confounding(), without its first argument, which this facade supplies from the fitted result.
- Returns:
SimulatedConfoundingResultQualitative estimate movements on the scale of the surface, and retained cell failures.
See also
cleverly.sensitivity.simulated_confoundingThe same surface as a free function.
- SensitivityFacade.tipping_gamma(*args: Any, **kwargs: Any) Any[source]#
Find the missingness tilt at which the estimate crosses its null.
- Parameters:
- *args, **kwargs
Forwarded to
cleverly.sensitivity.tipping_gamma(), without its first argument, which this facade supplies from the fitted result.
- Returns:
See also
cleverly.sensitivity.tipping_gammaThe same search as a free function.