cleverly.sensitivity.SimulatedConfoundingResult#
- class cleverly.sensitivity.SimulatedConfoundingResult(estimand: str, original_estimate: float, movement_scale: Literal['estimate_difference', 'log_ratio'], grid: ConfounderStrengthGrid, cells: tuple[SimulatedConfoundingCell, ...], calibrations: tuple[ObservedConfounderCalibration, ...], root_seed: int, latent_seed: int, refit_seed: int, n_repeats: int, repeat_aggregation: Literal['coordinatewise_median'], treatment_family: str, outcome_family: str, treatment_law: str, outcome_law: str, weight_report: WeightReport, backend: str | None = None, stratum: tuple[Any, ...] | None = None, strata_names: tuple[str, ...] = (), population: Literal['baseline', 'perturbed_treatment_group'] = 'baseline', conditioning_arm: Any = None, known_mechanism_carried: bool = False, treatment_components: tuple[str, ...] = ())[source]#
Store a qualitative simulated-confounding stress surface.
- Parameters:
- estimand
str Binary-treatment ATE, ATT, ATC, counterfactual-mean, risk-ratio, odds-ratio, or population-attributable-contrast alias, named modified-policy mean alias, or named modified-policy contrast alias.
- original_estimate
float Point estimate from the unperturbed fitted result.
- movement_scale{“estimate_difference”, “log_ratio”}
Scale used for the signed displacement. Ratio estimates use their stored log value. Other estimates use their reported value.
- grid
ConfounderStrengthGrid Explicit strength pairs evaluated by the surface.
- cells
tupleofSimulatedConfoundingCell Successful estimates and retained failures in grid order.
- calibrations
tupleofObservedConfounderCalibration Optional source-style comparisons against numeric observed covariates.
- root_seed
int Seed resolved for the complete operation.
- latent_seed
int Tagged child seed used to draw the shared latent vector.
- refit_seed
int Seed reused by every estimator refit. It equals
root_seed. A refit reuses the repeat seed sequence of the original fit only when this seed equals the seed of that fit.random_state=Noneresolves to the seed of the fit when the fit declared one. An unseeded fit, or an explicitrandom_stateother than the seed of the fit, gives the refits a different sequence, so movement near the anchor can carry a fold artifact. Perturbing a stratification variable can also change the realised folds.- n_repeats
int Number of complete cross-fitting draws in the original and refitted estimates.
- repeat_aggregation{“coordinatewise_median”}
Estimator-owned rule that names how the estimator aggregates the complete cross-fitting draws when there is more than one draw. The estimator applies no aggregation to a single draw.
- treatment_family
str Treatment family covered by the perturbation law.
- outcome_family
str Original outcome family.
- treatment_law
str Human-readable treatment perturbation rule.
- outcome_law
str Human-readable outcome perturbation rule.
- weight_report
WeightReport Provenance for the fixed empirical row-mass vector used by every cell.
- backend
strorNone Dataframe backend used by frame methods.
- stratum
tupleorNone Selected baseline stratum values.
Noneselects the full baseline population.- strata_names
tupleofstr Names of the columns defining the selected baseline stratum.
- population{“baseline”, “perturbed_treatment_group”}
Whether the target averages over its baseline population or its cell’s observed treatment group. ATT and ATC use the latter.
- conditioning_arm
AnyorNone Original treatment label defining the ATT or ATC population.
- treatment_components
tupleofstr The component columns of a vector treatment, in the grid’s order, or
(). Each cell’streatment_strengthandinduced_treatment_associationthen hold one value per component in this order.- known_mechanism_carriedbool
Whether the fitted data declared a known treatment mechanism. The flip of strength \(s\) is drawn from a latent normal independent of \(W\), so the flipped treatment’s mechanism is known too: \(g_s(a \mid W) = (1 - s)\, g_0(a \mid W) + s\, g_0(1 - a \mid W)\). Every cell that moves the treatment declares \(g_s\), and its refit divides by it.
- estimand
- Attributes:
target_measure{“unweighted”, “fixed_empirical_tilt”}Name the empirical measure on which every cell is evaluated.
association_population{“selected_baseline_stratum”, “full_fitted_population”}Name the baseline rows used for the induced treatment association.
calibration_population{“full_fitted_population”}Name the original rows used for observed-covariate calibration.
refit_population{“full_fitted_population”}Name the rows perturbed together before every complete estimator refit.
See also
simulated_confoundingBuild this result from a fitted estimator.
Methods#
- SimulatedConfoundingResult.calibration_frame() Any[source]#
Return model-dependent observed-covariate comparisons.
- Returns:
dataframeOne row per covariate and perturbed-variable role.
- SimulatedConfoundingResult.population_lines() tuple[str, ...][source]#
Return the population provenance of this surface, one field to a line.
The single field list and label vocabulary that
summary()prints and that the post-fit assessment row joins with"; ". Written twice the two reports drift, and a reader cannot tell which population a movement belongs to.
- SimulatedConfoundingResult.summary() str[source]#
Return a qualitative text summary without an inferential verdict.
- Returns:
strOriginal estimate, seeds, perturbation laws, cell movements, and the induced treatment association of each cell.
- SimulatedConfoundingResult.to_frame() Any[source]#
Return one backend-native row per declared strength pair.
- Returns:
dataframeEstimates, the movement scale of the displacement, displacements, induced treatment associations, and retained failure details. Two population columns join a movement to the rows it belongs to.
association_populationrepeatsassociation_populationon every row, which names the baseline rows the association was measured on.target_population_fractioncarriesSimulatedConfoundingCell.target_population_fraction, which is the conditioning-arm share that cell targets. A failed cell keeps its fraction, because the surface records it before the refit.
Attributes#
- SimulatedConfoundingResult.association_population#
Name the baseline rows used for the induced treatment association.
- SimulatedConfoundingResult.calibration_population#
Name the original rows used for observed-covariate calibration.
- SimulatedConfoundingResult.complete#
Return whether every declared cell produced an estimate.
- SimulatedConfoundingResult.conditioning_arm: Any = None#
- SimulatedConfoundingResult.failures#
Return structured failures in grid order.
- SimulatedConfoundingResult.population: Literal['baseline', 'perturbed_treatment_group'] = 'baseline'#
- SimulatedConfoundingResult.refit_population#
Name the rows perturbed together before every complete estimator refit.
- SimulatedConfoundingResult.successful_cells#
Return cells that produced estimates in grid order.
- SimulatedConfoundingResult.target_measure#
Name the empirical measure on which every cell is evaluated.
- SimulatedConfoundingResult.movement_scale: Literal['estimate_difference', 'log_ratio']#
- SimulatedConfoundingResult.grid: ConfounderStrengthGrid#
- SimulatedConfoundingResult.cells: tuple[SimulatedConfoundingCell, ...]#
- SimulatedConfoundingResult.calibrations: tuple[ObservedConfounderCalibration, ...]#
- SimulatedConfoundingResult.repeat_aggregation: Literal['coordinatewise_median']#
- SimulatedConfoundingResult.weight_report: WeightReport#