Skip to content

Causal impact reporting

polars_ts.causal.causal_impact_reporting

Reporting mixin for CausalImpact — summary, to_frame, placebo_test.

CausalImpactReportingMixin

Mixin providing summary, to_frame, and placebo_test methods.

Attributes below are declared for mypy — they are set by the consuming CausalImpact class.

results()

Return per-series CausalImpactResult objects.

Returns

dict[Any, CausalImpactResult] Mapping from series ID to result.

summary()

Return a summary DataFrame with one row per series.

Columns: id_col, total_effect, total_effect_lower, total_effect_upper, relative_effect, relative_effect_lower, relative_effect_upper, pre_mape, pre_coverage.

to_frame()

Return pointwise results as a DataFrame.

Columns: id_col, step, observed, counterfactual, counterfactual_lower, counterfactual_upper, point_effect, point_effect_lower, point_effect_upper, cumulative_effect, cumulative_effect_lower, cumulative_effect_upper.

placebo_test(df, placebo_date)

Run a placebo test at a date before the actual intervention.

Fits the model pretending placebo_date is the intervention, using only data from the pre-intervention period (data after the real intervention is excluded to avoid contamination). If the model is well-specified, the estimated effect should be near zero.

Parameters

df Same panel DataFrame used in fit(). placebo_date A date strictly before the actual intervention.

Returns

pl.DataFrame Summary with columns: id_col, total_effect, total_effect_lower, total_effect_upper, relative_effect.