Counterfactual time-series methods¶
This module covers two related designs for interventions observed over time:
- interrupted time series;
- synthetic control.
Both methods require a model of what would have happened after intervention in the absence of treatment.
Dedicated counterfactual DGP¶
The treated series has an untreated trajectory constructed from a convex combination of donor units plus optional unsupported structure.
Because the untreated counterfactual is stored explicitly, estimator error can be measured directly.
The simulator can also introduce:
- a treated-unit component that the donor pool cannot reproduce;
- a post-intervention structural break unrelated to treatment.
These are useful because they separate poor donor support from violations of post-period structural stability.
Interrupted time series¶
The segmented model is
[ Y_t = \beta_0 + \beta_1 t + \beta_2 1(t \ge T_0) + \beta_3 (t-T_0)_+ + \varepsilon_t. ]
Here:
- beta_2 is the immediate level change;
- beta_3 is the slope change after intervention.
The untreated counterfactual is obtained by setting both intervention terms to zero in the fitted model.
A causal interpretation requires the pre-intervention trajectory to remain informative about the untreated post-intervention path.
A simultaneous external shock at the intervention date is therefore a direct threat to identification.
Synthetic control¶
Synthetic control estimates non-negative donor weights that sum to one and minimise pre-treatment squared error:
[ \min_w \sum_{t<T_0} \left( Y_{1t} - \sum_j w_j Y_{jt} \right)^2 ]
subject to
[ w_j \ge 0, \qquad \sum_j w_j = 1. ]
The post-treatment gap is
[ \hat\tau_t = Y_{1t} - \sum_j \hat w_j Y_{jt}. ]
The implementation reports:
- donor weights;
- synthetic trajectory;
- period-by-period gaps;
- pre-treatment RMSE;
- post-treatment RMSE;
- average post-treatment gap.
Pre-treatment fit¶
Good pre-treatment fit does not prove identification, but poor fit is an immediate warning that the donor pool may not reproduce the treated unit's untreated trajectory.
The dedicated failure case adds unsupported treated-unit structure. Its pre-treatment RMSE rises substantially relative to the baseline design.
Placebo time¶
A placebo-time test moves the intervention earlier while restricting the sample to periods before the real intervention.
A material placebo gap indicates that the treated unit and synthetic control were already diverging before treatment.
Placebo units¶
Each donor can be re-labelled as treated in turn and compared with a synthetic control built from the remaining donors.
The resulting placebo distribution provides a reference for how unusual the treated unit's post/pre fit deterioration is relative to untreated units.
The implementation returns placebo-unit average post gaps and RMSE ratios. It does not convert them automatically into a formal randomisation p-value because the validity of such inference depends on the design and donor-pool logic.
Structural breaks¶
A post-intervention shock unrelated to treatment cannot be separated from the treatment effect by these methods without additional information.
The simulator includes a post_structural_break parameter specifically to demonstrate this failure mode.
In that experiment, synthetic control can maintain excellent pre-treatment fit and still attribute the unrelated break to treatment.
That is the key distinction:
- donor support is primarily diagnosed in the pre-period;
- causal attribution also requires post-period structural stability.
What these methods do not establish¶
Neither interrupted time series nor synthetic control turns temporal proximity into causal identification automatically.
A credible analysis still requires:
- no simultaneous confounding intervention;
- no spillover from the treated unit into donors;
- a stable untreated process;
- an appropriate donor pool or time-series specification;
- explicit treatment timing;
- uncertainty and falsification analysis.