In plain English
CausalImpact estimates the effect of an intervention on a time series when a controlled experiment was not run. It fits a Bayesian structural time-series model to the pre-intervention period — decomposing the series into trend, seasonality and the contribution of control series that were not affected — and then projects that model through the intervention period to produce a counterfactual forecast. The gap between actual and forecast is the estimated effect.
Its advantages over a simple before-and-after comparison are substantial. It models trend and seasonality explicitly rather than assuming them away. It uses control series as predictors, so anything affecting both treated and control markets is absorbed. And because it is Bayesian, it returns a credible interval on the cumulative effect rather than a point estimate, with the uncertainty widening appropriately as the forecast extends.
Everything depends on the control series, and this is where implementations go wrong. They must be predictive of the treated series before the intervention, and they must be genuinely unaffected by it. A control region that also received some campaign spend, or a metric downstream of the one being tested, contaminates the counterfactual and biases the effect towards zero. Picking control series by correlation alone will happily select contaminated ones, since a contaminated series correlates well by construction.
The second failure is treating pre-period fit as validation. With enough candidate predictors the model will fit the pre-period almost perfectly and can still forecast badly — the spike-and-slab prior does some variable selection, and it is not a substitute for testing the forecast on held-out data. Running the analysis on a period where nothing happened, and confirming it reports no effect, is the cheapest available sanity check and is skipped remarkably often.
Compared with the alternatives, it sits between a matched-market geo experiment and synthetic control. A randomised geo test is stronger, because assignment rather than a model creates the counterfactual, and is not always possible — the campaign may already have run. Synthetic control constructs a weighted combination of donors with constrained weights; CausalImpact fits a fuller time-series model with regression on the controls. In practice both are applied to similar problems and often agree, which is itself a useful check.
The formula
The model decomposition, and the two checks that separate a credible result from a well-fitted one.
- The model
yₜ = μₜ + τₜ + βᵀxₜ + εₜLocal trend μ, seasonality τ, regression on control series x. Fitted on the pre-period only.
- The effect
cumulative lift = Σ ( yₜ − ŷₜ ) over the post periodActual minus counterfactual, accumulated, with a credible interval from the posterior.
- The control requirement
predictive of y, and unaffected by the interventionBoth halves. Selecting by correlation alone will pick up contaminated series.
- The placebo check
run it on a period with no intervention; expect no effectThe cheapest validation available — see the correlation calculator for the pre-period relationship.
Worked example
A brand runs a six-week regional television campaign that was never randomised, and analyses it with CausalImpact using twelve untreated regions as control series. Two validation checks are run before the result is accepted.
- Control series
- 12 untreated regions
- Pre-period
- 78 weeks
- Pre-period fit
- R² = 0.94
- Placebo test on a quiet 6-week window
- effect +0.4%, interval spans zero
- Campaign estimate
- +8.2% cumulative, 95% CI +2.1% to +14.6%
- Two control regions received spillover TV
- excluded on review; estimate rose to +11.4%
The placebo test passed, and removing two contaminated control regions moved the estimate from +8.2% to +11.4%.
The placebo check is what makes the headline believable: run on a window where nothing happened, the model correctly found nothing, which is evidence the machinery is not manufacturing effects. The contamination finding is the more instructive part. Two of the twelve control regions sat adjacent to the campaign area and received overspill television, so they were partly treated — and because they were partly treated they tracked the treated series especially well, which is exactly why a correlation-based selection had chosen them. Including them pulled the counterfactual up towards the treated trajectory and understated the effect by three percentage points. The general rule is that control series must be verified as genuinely unexposed on the media plan, not merely as well-correlated. And note the interval width: +2.1% to +14.6% is a wide range, which is honest for a non-randomised six-week analysis and would look much tighter if the forecast uncertainty were dropped.
Common misconceptions
- דCausalImpact establishes causality from observational data.”
- It estimates an effect under an assumption — that the pre-period relationship with the control series would have continued. That assumption is not verifiable during the intervention, so the result is only as causal as the assumption is credible. A randomised geo test creates the counterfactual by design rather than assuming it, and is stronger whenever it is available.
- דAny well-correlated series makes a good control.”
- It must also be unaffected by the intervention, and correlation-based selection actively favours contaminated series — a region receiving spillover advertising tracks the treated series better than a clean one. Verify controls against the media plan rather than against a correlation matrix.
- דA good pre-period fit means the counterfactual is trustworthy.”
- In-sample fit is close to free with many candidate predictors. What matters is out-of-sample forecasting: hold out a window the model has not seen, or run a placebo analysis on a quiet period and confirm it reports no effect. A model that finds an effect where none exists will find an inflated one where something does.