cleverly.estimators.DoseResponseResult#

class cleverly.estimators.DoseResponseResult(curve: DoseResponse, estimates: dict[str, ParameterEstimate], band: SimultaneousBands, pair_support: tuple[PairSupport, ...], quadrature_shift: float, scores: dict[str, float], n_nodes: int, alpha: float, nuisance_record: DoseNuisanceRecord, warnings: tuple[str, ...] = (), backend: str | None = None)[source]#

A fitted kernel-smoothed dose-response curve.

Parameters:
curveDoseResponse

The declaration.

estimatesdict

One ParameterEstimate per pair, keyed by name.

bandSimultaneousBands

The simultaneous band over every declared pair.

pair_supporttuple of PairSupport

One entry per reported estimate, in report order: every pair, and within a fit with baseline strata every pair in every stratum.

quadrature_shiftfloat

The largest change of an estimate, relative to its standard error, when the quadrature nodes are doubled.

scoresdict

The mean weighted score of each pair’s fluctuation at its solution.

n_nodesint

The quadrature doses.

alphafloat

The significance level of the intervals and of the band.

nuisance_recordDoseNuisanceRecord

The outcome regression at the observed dose, which diagnostics.nuisance_models() reads.

warningstuple of str

The fit’s notes: a quadrature-doubling shift above tolerance, an accepted composition no registered study measures (an in-sample fit, observation weights), and pairs below the support floor.

backendstr or None

The dataframe library the fit’s data arrived in, which to_frame() returns by default.

Methods#

DoseResponseResult.assess(*, include_refits: bool = False, include_retargets: bool = False, arguments: Mapping[str, Mapping[str, Any]] | None = None, random_state: int | None = None) → Any[source]#

Run the applicable post-fit assessment battery.

No refutation or sensitivity analysis is implemented for a dose-response curve, so those rows report their refusals.

Parameters:
include_refitsbool

Run requested operations that refit nuisance models.

include_retargetsbool

Include moderate retargets.

argumentsmapping or None

Per-operation keyword arguments.

random_stateint or None

Common seed for stochastic refit operations.

Returns:
AssessmentReport

Validation, diagnostics, and sensitivity in one report.

DoseResponseResult.estimate(h: float, a0: float, stratum: str | None = None) → ParameterEstimate[source]#

The estimate at one declared pair.

Parameters:
hfloat

A declared bandwidth.

a0float

A declared dose.

stratumstr or None

The stratum label, such as "V=1", on a fit with baseline strata.

Returns:
ParameterEstimate

The estimate.

Raises:
KeyError

When no declared pair has exactly this bandwidth and dose, and no declared pair has the parameter name cleverly.dose_response.pair_name() gives them.

Notes

A pair matches by exact float equality first, then by its declared name, which formats each number to ten significant digits and is unique within a declaration. No tolerance is applied: two declared doses can be close in relative terms and still be different estimands.

DoseResponseResult.save(path: Any) → Any[source]#

Write this result to a trusted joblib artifact; see cleverly.load().

Parameters:
pathpath-like

Destination file.

Returns:
Path

The destination path, as given.

DoseResponseResult.to_frame(backend: str | None = None) → Any[source]#

One row per pair: the estimate, its pointwise interval, the band and the support.

Parameters:
backendstr or None

The dataframe library, or None for the library the fit’s data arrived in.

Returns:
DataFrame

Columns bandwidth, dose, stratum (on a fit with strata), estimate, std_error, lower, upper, band_lower, band_upper, rows, kish and low_support.

DoseResponseResult.validate() → Any[source]#

Run the inexpensive default battery without refitting.

Returns:
ValidationReport

One item per validated check, read off the stored fit.

Attributes#

DoseResponseResult.assessment_family: ClassVar[str] = 'dose_response'#

The assessment family: one declaration per assessment operation in cleverly.assessment.ASSESSMENT_CAPABILITIES.

DoseResponseResult.backend: str | None = None#
DoseResponseResult.diagnostics#

The support, score, outcome-regression and influence diagnostics of the fit.

DoseResponseResult.fitted_method: ClassVar[str] = 'tmle'#

The method identity of the result.

DoseResponseResult.replayability#

Which assessment operations survive from the stored fit.

DoseResponseResult.sensitivity#

The sensitivity-analysis facade, whose every row refuses on this fit.

DoseResponseResult.warnings: tuple[str, ...] = ()#
DoseResponseResult.curve: DoseResponse#
DoseResponseResult.estimates: dict[str, ParameterEstimate]#
DoseResponseResult.band: SimultaneousBands#
DoseResponseResult.pair_support: tuple[PairSupport, ...]#
DoseResponseResult.quadrature_shift: float#
DoseResponseResult.scores: dict[str, float]#
DoseResponseResult.n_nodes: int#
DoseResponseResult.alpha: float#
DoseResponseResult.nuisance_record: DoseNuisanceRecord#
DoseResponseResult.assessment_cache: AssessmentCache#

Assessment results keyed by operation and normalized arguments. init=False, so a mapping handed to the constructor by dataclasses.replace cannot answer for another fit.