Interventions#

Use interventions to define static, dynamic, stochastic, incremental, or modified treatment assignments. Run the matching support check before you interpret an estimate.

A modified treatment policy is a Shift, a Scale, a Piecewise map, a ModifiedPolicy with declared pieces, or a RiskRatioTilt. Pass the policy to TMLE(policies=...) or as a node of a longitudinal plan. A vector treatment takes a JointPolicy, which declares one policy for each component. A DoseQuantile or a SupportBoundary tunes the cap of a Shift or a Scale from the treatment law. A Support declares the interval of doses that a node can take given its history. The fit refuses, before any learner, a dose or a policy outside it.

Incremental tilts the odds of the treatment. A scalar multiplies the odds of the second of two levels. A mapping from level label to factor tilts a treatment with three or more levels, and a level that it does not name keeps the factor 1. Incremental.factors resolves a declaration against the levels of one treatment or one node.

DynamicRegimen defines a plan across the treatment nodes of a longitudinal fit. A node of that plan can be a rule. It can also be a Stochastic node that draws its arm from a known policy. each_node writes one rule for every node of a long panel, and it returns one NodeRule per node.

LearnedRule declares a rule that the fit learns inside each training fold, and LearnedRuleRecord records that fit.

cleverly.interventions.Intervention

A conditional distribution over the treatment arms.

cleverly.interventions.Static

Set the treatment to one level for everybody: \(g^\star = \mathbb 1\{a = v\}\).

cleverly.interventions.Rule

A dynamic regime: assign \(d(W)\), a deterministic function of the covariates.

cleverly.interventions.Stochastic

A known stochastic regime: assign arm \(a\) with probability \(g^\star(a \mid W)\).

cleverly.longitudinal.DynamicRegimen

A plan whose nodes may be rules rather than constants.

cleverly.longitudinal.each_node

Write one rule for every node, each reading its own node's columns by name.

cleverly.longitudinal.NodeRule

One node of a rule written for every node: calls rule(frame, time).

cleverly.interventions.LearnedRule

Declare the rule whose fold-average value a fit estimates.

cleverly.interventions.LearnedRuleRecord

Record what a learned-rule fit estimated, under result.extra["learned_rule"].

cleverly.interventions.RegimeSet

The regimes a fit targets, and their evaluated densities.

cleverly.interventions.Incremental

Multiply the odds of treatment levels by declared factors.

cleverly.interventions.IPSISet

Every declared tilt, evaluated against the estimated mechanism.

cleverly.interventions.Shift

Add delta to everyone's treatment, up to cap.

cleverly.interventions.Scale

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

cleverly.interventions.DoseQuantile

The cap at a quantile of the natural dose among the units at risk.

cleverly.interventions.SupportBoundary

The cap at a learned conditional quantile of the dose: c(h).

cleverly.interventions.LinearQuantileRegression

A declared linear quantile regression: the boundary beta' (1, features).

cleverly.interventions.Piecewise

A policy that applies a different shift or scale on each interval of the dose.

cleverly.interventions.Piece

One interval of a declared policy and the strictly monotone map it applies there.

cleverly.interventions.Support

The declared conditional support of a continuous dose: [lower(h), upper(h)].

cleverly.interventions.ModifiedPolicy

A modified treatment policy that the analyst declares.

cleverly.interventions.Randomizer

A finite, known law for the randomizer of a randomized policy.

cleverly.interventions.RiskRatioTilt

The risk-ratio incremental intervention of lmtp::ipsi, a randomized policy.

cleverly.interventions.JointPolicy

A modified treatment policy on a vector node, declared one component at a time.

cleverly.interventions.PolicySet

Every declared policy, evaluated on the data and on the estimated mechanism.

cleverly.interventions.SupportReport

RegimeSupport for every regime in a fit, plus the worst case.

cleverly.interventions.RegimeSupport

Overlap for one regime.

cleverly.interventions.IncrementalSupport

Overlap for one tilt -- which for this estimand is a statement, not a warning.

cleverly.interventions.PolicySupport

Overlap for one policy: how hard the density ratio is working, and where it fails.

cleverly.interventions.check_support

Overlap diagnostics for each regime, from the untruncated mechanism.

cleverly.interventions.check_incremental_support

Per-tilt overlap, in the vocabulary the other two axes' reports use.

cleverly.interventions.check_policy_support

Per-policy overlap, in the vocabulary cleverly.interventions.support uses.