cleverly.validation.BoundedAdjustmentOutcome#

class cleverly.validation.BoundedAdjustmentOutcome(intercept: float = 0.0, effect: float = 0.5, adjustment_scale: float = 1.0, link: Literal['logit', 'identity'] = 'logit', precision: float = 20.0, arm_effects: Any = None, intermediate_effect: float = 0.0)[source]#

Declare a bounded continuous outcome on the fit’s q_bounds.

The draw is lo + (hi - lo) * B with B ~ Beta(m phi, (1 - m) phi), where (lo, hi) are the fit’s q_bounds, phi is precision, and m = m(a, W) is the mean model of BernoulliAdjustmentOutcome. The Beta law has mean m exactly, so the outcome mean is lo + (hi - lo) m(a, W) and every truth is a finite sum. A refutation refuses a declaration whose m leaves the open interval (0, 1) on a row.

Parameters:
interceptfloat

Log-odds (logit link) or mean (identity link) of m at f(W) = 0 and c(a) = 0.

effectfloat

Arm term per unit of the treatment code, on the scale of m’s link.

adjustment_scalefloat

Multiplier on the covariate term.

link{“logit”, “identity”}

The link of the mean model.

precisionfloat

The Beta precision phi. A larger value gives less noise around the mean.

arm_effectsdict or tuple of tuple or None

One arm term per declared arm label, in place of effect * code.

intermediate_effectfloat

Effect gamma of the binary intermediate Z of a controlled direct effect, added inside the link with no arm interaction. Point fits only.

Methods#

BoundedAdjustmentOutcome.admissible(mean: Any, *, bounds: tuple[float, float] | None = None) → bool[source]#

Return whether every mean lies strictly inside bounds.

Parameters:
meanarray_like

Outcome means to check.

boundstuple of float

The fit’s q_bounds.

Returns:
bool

True when each Beta law is proper.

BoundedAdjustmentOutcome.mean(covariates: Any, arms: Any, *, centre: Any = None, scale: Any = None, bounds: tuple[float, float] | None = None) → ndarray[source]#

Return the outcome mean lo + (hi - lo) m(a, W) of each row.

Parameters:
covariatesarray_like

Covariate matrix with one row per observation.

armsarray_like

The arm term c(a) of each row.

centrearray_like or None

Column centres of the covariate term.

scalearray_like or None

Column scales of the covariate term.

boundstuple of float

The fit’s q_bounds.

Returns:
ndarray

The outcome mean of each row.

Raises:
ValueError

If bounds is missing.

BoundedAdjustmentOutcome.sample(rng: Generator, mean: Any, *, bounds: tuple[float, float] | None = None) → ndarray[source]#

Draw one bounded outcome per row with mean mean.

Parameters:
rngnumpy.random.Generator

Generator that supplies the draw.

meanarray_like

The outcome mean of each row, inside bounds.

boundstuple of float

The fit’s q_bounds.

Returns:
ndarray

One value per row in bounds.

Attributes#

BoundedAdjustmentOutcome.adjustment_scale: float = 1.0#
BoundedAdjustmentOutcome.arm_effects: Any = None#
BoundedAdjustmentOutcome.effect: float = 0.5#
BoundedAdjustmentOutcome.family: str = 'gaussian'#
BoundedAdjustmentOutcome.independent#

Return whether the outcome reads neither the covariates nor the treatment.

BoundedAdjustmentOutcome.intercept: float = 0.0#
BoundedAdjustmentOutcome.intermediate_effect: float = 0.0#
BoundedAdjustmentOutcome.name: str = 'bounded_beta_adjustment_dependent'#
BoundedAdjustmentOutcome.precision: float = 20.0#