cleverly.interventions.Scale#

class cleverly.interventions.Scale(factor: float, cap: float | DoseQuantile | SupportBoundary | None, name: str = '', target: Literal['population', 'fold_average'] | None = None)[source]#

Multiply everyone’s dose by factor, up to cap.

\(d(a) = c\,a\) where \(c\,a \le u\), and \(a\) elsewhere. The map is strictly increasing for \(c > 0\), its inverse is \(a / c\) and the derivative of the inverse is \(1 / c\), so the density ratio is

\[h(a, W) = \frac{g(a / c \mid W)}{c\, g(a \mid W)}\,\mathbb 1\{a \le u\} + \mathbb 1\{c\, a > u\}.\]
Parameters:
factorfloat

The multiplier. It is positive; 1.0 is the natural course.

capfloat, DoseQuantile, SupportBoundary or None

The largest dose the policy assigns. A unit whose scaled dose would exceed it keeps its own, as for Shift. A tuner reads it from the treatment law.

namestr

The report label. Defaults to "x1.25" style, with "natural course" for factor=1.

target{“population”, “fold_average”} or None

The parameter of a map whose cap is a tuner, as for Shift.

Methods#

Scale.apply(treatment: ndarray[tuple[Any, ...], dtype[float64]]) → tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[bool]]][source]#

(assigned, held): the assigned dose, and which rows the cap held back.

Parameters:
treatmentndarray

(n,) observed dose.

Returns:
assignedndarray

(n,) dose the policy assigns.

heldndarray

(n,) boolean, true where the cap held the row at its own dose.

Attributes#

Scale.name: str = ''#
Scale.target: Literal['population', 'fold_average'] | None = None#
Scale.factor: float#
Scale.cap: float | DoseQuantile | SupportBoundary | None#