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) * BwithB ~ Beta(m phi, (1 - m) phi), where(lo, hi)are the fit’sq_bounds,phiisprecision, andm = m(a, W)is the mean model ofBernoulliAdjustmentOutcome. The Beta law has meanmexactly, so the outcome mean islo + (hi - lo) m(a, W)and every truth is a finite sum. A refutation refuses a declaration whosemleaves the open interval(0, 1)on a row.- Parameters:
- intercept
float Log-odds (logit link) or mean (identity link) of
matf(W) = 0andc(a) = 0.- effect
float Arm term per unit of the treatment code, on the scale of
m’s link.- adjustment_scale
float Multiplier on the covariate term.
- link{“logit”, “identity”}
The link of the mean model.
- precision
float The Beta precision
phi. A larger value gives less noise around the mean.- arm_effects
dictortupleoftupleorNone One arm term per declared arm label, in place of
effect * code.- intermediate_effect
float Effect
gammaof the binary intermediateZof a controlled direct effect, added inside the link with no arm interaction. Point fits only.
- intercept
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.
- bounds
tupleoffloat The fit’s
q_bounds.
- Returns:
- bool
Truewhen 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.
- bounds
tupleoffloat The fit’s
q_bounds.
- Returns:
ndarrayThe outcome mean of each row.
- Raises:
ValueErrorIf
boundsis 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:
- rng
numpy.random.Generator Generator that supplies the draw.
- meanarray_like
The outcome mean of each row, inside
bounds.- bounds
tupleoffloat The fit’s
q_bounds.
- rng
- Returns:
ndarrayOne value per row in
bounds.
Attributes#
- BoundedAdjustmentOutcome.independent#
Return whether the outcome reads neither the covariates nor the treatment.