cleverly.interventions.check_policy_support#

cleverly.interventions.check_policy_support(policies: PolicySet, density: ConditionalDensity | MixedDensity | None, treatment: ndarray[tuple[Any, ...], dtype[float64]], *, propensity: ndarray[tuple[Any, ...], dtype[float64]] | None = None, mechanisms: Sequence[ndarray[tuple[Any, ...], dtype[float64]]] = (), absolute_score_weights: ndarray[tuple[Any, ...], dtype[float64]] | None = None, equations: tuple[str, ...] = (), n_repeats: int = 1, folds: Folds | None = None, declared_support: tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]] | None = None) → dict[str, PolicySupport][source]#

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

The quantity a policy’s positivity rests on is not a propensity but the ratio \(g^d(a \mid w) / g(a \mid w)\): it is what multiplies each residual, so its tail is where one row starts to dominate the estimating equation. A randomized policy’s ratio is the weighted mean of its components’ ratios.

mechanisms are the further (n, C + 1) denominators a fit declared – the missingness mechanism under delta=, the intermediate density under intermediate= – of which only column 0, the value at the row’s own dose, is read here. The weight the estimating equation forms is \(h_r(A, W) / \{\pi(A, W) q_z(A, W)\}\), so the two reweightings multiply and an effective sample size taken of the ratio alone understates the strain – cleverly.sensitivity.positivity makes the same argument about 1 / g and a population weight. Passing nothing reports the ratio by itself, which is what a fit with no such mechanism means.

Parameters:
policiesPolicySet

The evaluated policies to report on.

densityConditionalDensity, MixedDensity or None

The estimated density the ratios were built from, on a continuous treatment.

treatmentndarray

(n,) observed dose, or level code on a categorical treatment.

propensityndarray or None

(n, K) fitted probabilities, on a categorical treatment.

mechanismssequence of ndarray

Further (n, C + 1) denominators the fit declared. Only column 0, the value at the row’s own dose, is read.

absolute_score_weightsndarray or None

Fitted abs(w_i * H_ij) columns, in component order. None records an omission.

equationstuple of str

Fitted score-equation names, in component order.

n_repeatsint

Number of stored cross-fitting draws. The retained weights and the fold means describe draw 1.

foldsFolds or None

The partition the mechanism was cross-fitted over, which sets the rows of each PolicySupport.fold_mean_ratio entry. None reads every row as one fold.

declared_supporttuple of ndarray or None

(lower, upper), the declared support on every row, from declared_support_bounds(). None when the fit declared none.

Returns:
dict of str to PolicySupport

One record per policy, keyed by its report label.