aimz.ImpactModel.estimate_effect#

ImpactModel.estimate_effect(output_baseline=None, output_intervention=None, args_baseline=None, args_intervention=None, *, on_batch=False)[source]#

Estimate the effect of an intervention.

This computes (intervention - baseline) for every variable in the shared predictive group, preserving sampling (chain/draw) dimensions. When interventions are used in prediction they are applied internally through NumPyro’s do effect handler (graph surgery) without requiring model rewrites.

Parameters:
  • output_baseline (DataTree | None) – Precomputed output for the baseline scenario.

  • output_intervention (DataTree | None) – Precomputed output for the intervention scenario.

  • args_baseline (dict | None) – Input arguments for the baseline scenario. Passed to the prediction method to compute predictions if output_baseline is not provided. Ignored if output_baseline is already given.

  • args_intervention (dict | None) – Input arguments for the intervention scenario. Passed to the prediction method to compute predictions if output_intervention is not provided. Ignored if output_intervention is already given.

  • on_batch (bool) – If True, use predict_on_batch() instead of predict() when computing predictions from args_baseline or args_intervention. Ignored when precomputed outputs are provided.

Returns:

The estimated impact of an intervention. Posterior samples are included if available.

Raises:

ValueError – If neither output_baseline nor args_baseline is provided, or if neither output_intervention nor args_intervention is provided.

Return type:

DataTree

See also

cleanup() to remove the temporary directory if created.