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 isexpit(intercept + f(W) + c(a)), wherefis the standardized sum ofGaussianAdjustmentOutcome. Underlink="identity"it isintercept + adjustment_scale * (expit(s(W)) - 1/2) + c(a), wheresis that sum with scale 1. The identity link gives an arm contrast that does not vary withW, 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:
- intercept
float Log-odds (logit link) or risk (identity link) at
f(W) = 0andc(a) = 0.- effect
float Arm term per unit of the treatment code.
- adjustment_scale
float Multiplier on the covariate term.
- link{“logit”, “identity”}
The link of the mean model.
- 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#
- 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
Truewhen 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:
ndarrayThe 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:
- rng
numpy.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.
- rng
- Returns:
ndarrayZero-one outcomes.
Attributes#
- BernoulliAdjustmentOutcome.independent#
Return whether the outcome reads neither the covariates nor the treatment.