GradedInterventionTimeSeries.effect#

GradedInterventionTimeSeries.effect(window, channels=None, scale=0.0)[source]#

Estimate the causal effect of scaling treatment channels in a time window.

This method computes a counterfactual scenario by scaling the specified treatment channels in the given window, reapplying all transforms with the same parameters, and comparing to the observed outcome.

Parameters:
  • window (Tuple[Union[pd.Timestamp, int], Union[pd.Timestamp, int]]) – Start and end of the effect window (inclusive).

  • channels (List[str], optional) – List of treatment channel names to scale. If None, scales all channels.

  • scale (float, default=0.0) – Scaling factor for the counterfactual (0.0 = remove treatment).

Returns:

result – Dictionary containing: - “effect_df”: DataFrame with observed, counterfactual, effect, cumulative effect - “total_effect”: Total effect in window - “mean_effect”: Mean effect per period in window

Return type:

Dict

Examples

# Estimate effect of removing treatment completely
effect = result.effect(
    window=(df.index[0], df.index[-1]),
    channels=["comm_intensity"],
    scale=0.0,
)
print(f"Total effect: {effect['total_effect']:.2f}")