Bell Statistics

What is CausalImpact?

CausalImpact is Google's open-source method for estimating a campaign's effect from time-series data. It fits a Bayesian structural time-series model on the pre-period, using control series as predictors, and projects it forward to build the counterfactual.

Also called
Bayesian structural time series, BSTS, CausalImpact R package, Google CausalImpact
Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

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 period

Actual minus counterfactual, accumulated, with a credible interval from the posterior.

The control requirement
predictive of y, and unaffected by the intervention

Both halves. Selecting by correlation alone will pick up contaminated series.

The placebo check
run it on a period with no intervention; expect no effect

The 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.

Frequently asked questions

How do I choose control series for CausalImpact?
They must be predictive of the treated series before the intervention and genuinely unexposed to it. Verify the second against the media plan rather than the data, because a contaminated series correlates especially well and a correlation-based selection will prefer it. Several controls are better than one, and each should be defensible on its own rather than included because it improved the fit.
When should I use CausalImpact instead of a geo experiment?
When randomisation was not possible — the campaign has already run, or the intervention was decided by someone else. A randomised geo test is stronger because assignment rather than a model creates the counterfactual. CausalImpact is what you reach for when that option has passed, and its credibility rests on the control series and the validation rather than on the design.
How do I know whether to believe a CausalImpact result?
Run a placebo analysis on a period where nothing happened and confirm it reports no effect. Hold out a window before the intervention and check the forecast against reality. Confirm the control series were genuinely unexposed. And read the credible interval rather than the point estimate — non-randomised six-week analyses produce wide intervals honestly, and a suspiciously narrow one usually means the forecast uncertainty was dropped somewhere.

Related terms

  • Counterfactual forecast

    The dotted line on every geo chart — a prediction, not an observation, and the whole result rests on it.

  • Geo experiment

    Randomise regions instead of users — the way to test marketing that cannot be hidden from a person.

  • GeoLift

    Open-source geo testing with the power simulation built in — it tells you whether the test can work before you run it.

  • Synthetic control

    Build the comparison group instead of finding one — the method for when you have one treated unit.

Calculate it

  • Paired t-test

    Before-and-after or matched pairs — size the study on the difference SD, then test it.

  • Correlation test

    Pearson r or Spearman rho, with the Fisher-z interval that says how little a small sample knows.

Knowing the term is the easy part

Applying it to a live measurement problem is the part that goes wrong. If you are designing an experiment, reading a result you do not trust, or trying to work out what your marketing actually caused, that is the work we do.