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
doeffect 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_baselineis not provided. Ignored ifoutput_baselineis already given.args_intervention (dict | None) – Input arguments for the intervention scenario. Passed to the prediction method to compute predictions if
output_interventionis not provided. Ignored ifoutput_interventionis already given.on_batch (bool) – If
True, usepredict_on_batch()instead ofpredict()when computing predictions fromargs_baselineorargs_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_baselinenorargs_baselineis provided, or if neitheroutput_interventionnorargs_interventionis provided.- Return type:
See also
cleanup()to remove the temporary directory if created.