cleverly.validation.BernoulliAdjustmentOutcome#

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

Declare a binary outcome Y ~ Bern(m(a, W)).

Under link="logit" the mean is expit(intercept + f(W) + c(a)), where f is the standardized sum of GaussianAdjustmentOutcome. Under link="identity" it is intercept + adjustment_scale * (expit(s(W)) - 1/2) + c(a), where s is that sum with scale 1. The identity link gives an arm contrast that does not vary with W, so the held design reads the standard-error ratio and the coverage on a binary outcome. A refutation refuses an identity-link declaration whose mean leaves [0, 1] on a row.

Parameters:
interceptfloat

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

effectfloat

Arm term per unit of the treatment code.

adjustment_scalefloat

Multiplier on the covariate term.

link{“logit”, “identity”}

The link of the mean model.

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#

BernoulliAdjustmentOutcome.admissible(mean: Any, **_: Any) → bool[source]#

Return whether every risk lies in [0, 1].

Parameters:
meanarray_like

Risks to check.

**_Any

Bound keywords of the bounded process; unused.

Returns:
bool

True when every risk is a probability.

BernoulliAdjustmentOutcome.mean(covariates: Any, arms: Any, *, centre: Any = None, scale: Any = None, **_: Any) → ndarray[source]#

Return the risk 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.

**_Any

Bound keywords of the bounded process; unused.

Returns:
ndarray

The risk of each row. The identity link can leave [0, 1]; the refutation refuses such a declaration before it draws.

BernoulliAdjustmentOutcome.sample(rng: Generator, mean: Any, **_: Any) → ndarray[source]#

Draw one binary outcome per row with risk mean.

Parameters:
rngnumpy.random.Generator

Generator that supplies the draw.

meanarray_like

The risk of each row, in [0, 1].

**_Any

Bound keywords of the bounded process; unused.

Returns:
ndarray

Zero-one outcomes.

Attributes#

BernoulliAdjustmentOutcome.adjustment_scale: float = 1.0#
BernoulliAdjustmentOutcome.arm_effects: Any = None#
BernoulliAdjustmentOutcome.effect: float = 1.0#
BernoulliAdjustmentOutcome.family: str = 'binomial'#
BernoulliAdjustmentOutcome.independent#

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

BernoulliAdjustmentOutcome.intercept: float = -0.5#
BernoulliAdjustmentOutcome.intermediate_effect: float = 0.0#
BernoulliAdjustmentOutcome.name: str = 'bernoulli_adjustment_dependent'#