Skip to content
Marketing Measurement Science

Difference-in-Differences

Difference-in-Differences Lift Calculator

Enter average monthly spend for members and matched controls before and after the join date. The default values come from the simulated cohort at the default Matching settings. An interval also requires information about sampling variation and dependence.

Program Lift Decomposition

Adjusting for baseline

The same paired pretest and posttest observations can support different comparisons. Ask how units entered each group and which counterfactual mean the design makes credible. These examples are synthetic and use the same measurement scale before and after treatment.

Inspect the paired observations

With two periods, the difference in mean changes subtracts the baseline gap from the posttest gap. That imposes a slope of one in the regression calculation. Common-slope ANCOVA subtracts the fitted within-group slope times the baseline gap.

DiD needs parallel group-average untreated trends and no anticipation to identify the usual two-group ATT. Individual trajectories may differ. ANCOVA needs conditional exchangeability at baseline, overlap and a credible outcome model. If slopes differ, allow an interaction and standardize predictions to a named target population. Measurement noise, regression to the mean and weak overlap can all change the comparison.

Worked Bayesian baseline adjustment

Use the recorded-pretest example. To isolate the interval interpretation, fix the common slope at 0.60 and the individual residual standard deviation at 2. The adjusted group gap of 4 has a Gaussian likelihood with variance 2² × (1/8 + 1/8) = 1. A Normal(0, 5²) prior for the gap gives a posterior with mean 3.85 and a central 95% credible interval from 1.92 to 5.77 units.

For an independent replicate with the same design and eight units per arm, the posterior predictive 95% interval for the adjusted sample gap is 1.10 to 6.59 units. The observed gap of 4 is inside. In a fitted analysis, compare replicated and observed group spreads and trends as well.

A credible interval assigns probability to parameters under the likelihood and priors. A frequentist confidence procedure targets repeated-sample coverage under its assumptions. This conjugate example needs no sampler. For sampled posteriors, inspect R-hat, bulk and tail chain effective sample size, divergences, and predictive checks.

The calculator above uses the four group means. Estimating the within-group slope requires paired unit-level observations like these.

Who can serve as a control?

Explore common and staggered adoption

Start with one adoption date

With two groups and two periods, subtract the control change from the treated change. In a balanced panel this is also the coefficient on treated-group × post with unit and date fixed effects. With one common adoption date and more periods, the single interaction pools pre and post dates. An event study instead reports the gap at each relative date minus the gap at the last untreated date.

In this example, compare early to never-treated stores. Their gaps are 5, 5, 10 and 11 points. Equal date weights give a pooled contrast of (10 + 11)/2 − (5 + 5)/2 = 5.5 points. Putting three quarters of post weight on month 0 gives 5.25 points. Changing sample sizes or panel balance can also change the implicit weights. Against month −1, the event-study contrasts at months 0 and 1 are +5 and +6 points.

Choose a cohort and calendar date

Early stores adopt in month 0, late stores in month 1. Event time is e = t − g for calendar date t and adoption date g. The baseline is e = −1 under no anticipation. If effects can start a periods early, use a baseline before g − a and screen controls for anticipated exposure through the follow-up.

Illustrative store cohorts · 30-day conversion rates
Store cohortMonth −2Month −1Month 0Month 1
Early18%20%27%30%
Late16%18%20%26%
Never treated13%15%17%19%

At the defaults, early stores gain 7 points and the two untreated cohorts gain 2 points each. The estimated early-cohort effect at adoption is +5 percentage points.

The grid gives each available comparison cohort equal weight. It shows point contrasts from aggregate rates. To combine several treated cohorts at a horizon, specify the target and its weights. For example, equal weight per treated unit gives larger adoption cohorts more weight. A fixed set of contributing cohorts supports a comparison of effects across horizons for the same population.

Already-treated cohorts may have evolving treatment effects, so their observed changes can contaminate a staggered comparison. In the canonical Goodman–Bacon decomposition of a static two-way fixed effects estimate, the two-by-two comparison weights are nonnegative. The implied weights on treated cohort-date effects can be negative. See the staggered-adoption methods below and the offer rollout example.

What can pre-trends tell us?

Extensions and alternatives

These designs extend the two-group comparison to staggered adoption, eligibility subgroups, spillovers, varying treatment intensity, and quantile or exit outcomes. Panel-based counterfactual methods are an alternative when no comparison group has a parallel untreated trend. Cutoff designs apply when eligibility follows a documented score threshold.

Adoption by cohort

One shared start with outcomes before and after? Start with the 2×2 contrast and common-adoption fixed effects. With multiple starts, keep calendar dates and event time separate. The cohort grid shows an unadjusted effect for one cohort and date.

Callaway–Sant’Anna

Estimate effects by adoption cohort and calendar date using never-treated or not-yet-treated comparisons outside their anticipation window. Inspect overlap and cohort counts before aggregating.

Sun–Abraham

Estimate cohort-by-event-time effects in a panel using an untreated reference. Report which cohorts contribute at each horizon. A changing cohort mix can look like a changing effect.

Stacked DiD

Build a window for each adoption cohort with controls untreated throughout it. Keep cohort composition comparable, weight each stack for the target effect, and account for controls reused across stacks.

Local-projection DiD

For each horizon, compare changes from the last untreated date using controls still untreated through that horizon. Check the sample and weights at each horizon.

Double/debiased machine learning (DML)

Use a score whose expected value is locally insensitive to small errors in the outcome and treatment models, under conditional parallel trends and overlap. In panels, estimate the untreated outcome change and treatment propensity from baseline covariates. Adjusting for treatment-affected covariates can introduce bias. Split folds by independent unit or cluster. propensity weighting · cross-fitting

Untreated-outcome models

Pooling earlier untreated dates can improve precision when they support the same counterfactual model.

Borusyak–Jaravel–Spiess imputation

Fit an outcome model on untreated observations. Predict what treated outcomes would have been at supported dates, then average the observed-minus-predicted differences with target weights.

Gardner two-stage DiD

Fit unit or group and date effects using untreated observations. Regress the residualized outcomes on the treatment indicators. Carry first-stage uncertainty into inference.

Chen–Sant’Anna–Xie efficient DiD

Combine pre-period contrasts when their moment restrictions are credible. Additional pre-periods can improve precision, and invalid restrictions can introduce bias.

Wooldridge extended TWFE

Use a separate cohort-by-calendar-date treatment indicator for each supported cell. With nonlinear models, report the average difference in predicted outcomes on the outcome scale.

Lee–Wooldridge rolling DiD

Update the comparison set at each adoption horizon. If you detrend using earlier periods, check whether the estimated trends are stable and the remaining comparisons have support.

Hausman comparison. Compare estimates of the same effect on the same sample. Account for their covariance when estimating the uncertainty of their difference. Pre-trend sensitivity

Panel-based counterfactual methods

Synthetic control, synthetic DiD and TROP use repeated outcomes from untreated comparison units to estimate what would have happened to the treated units without the intervention. Unlike two-group DiD, synthetic control does not require a comparison group with a parallel untreated trend. It assumes that the weighted blend of comparison units that reproduces the treated unit’s pre-treatment outcomes would have continued to track its untreated outcomes after treatment. The comparison units available for this are often called the donor pool. The methods differ in how they build the counterfactual: unit weights, time weights, and an outcome model.

Weekly sales for four weeks before and three weeks after a campaign launch. Comparison Store A sells 8, 10, 9 and 12 units before launch and 12, 14 and 15 units after. Comparison Store B sells 12, 10, 14 and 14 units before launch and 16, 16 and 17 units after. Before launch, the synthetic counterfactual, 0.75 times Comparison Store A plus 0.25 times Comparison Store B plus 1 unit, matches the Campaign Store exactly: 10, 11, 11.25 and 13.5 units. After launch the Campaign Store sells 16, 18 and 20 units, while the synthetic counterfactual is 14, 15.5 and 16.5 units. Week −4 · Campaign Store: 10 units; Synthetic Counterfactual: 10 units; Comparison Store B: 12 units; Comparison Store A: 8 units Week −3 · Campaign Store: 11 units; Synthetic Counterfactual: 11 units; Comparison Store B: 10 units; Comparison Store A: 10 units Week −2 · Campaign Store: 11.25 units; Synthetic Counterfactual: 11.25 units; Comparison Store B: 14 units; Comparison Store A: 9 units Week −1 · Campaign Store: 13.5 units; Synthetic Counterfactual: 13.5 units; Comparison Store B: 14 units; Comparison Store A: 12 units Week 0 · Campaign Store: 16 units; Synthetic Counterfactual: 14 units; Comparison Store B: 16 units; Comparison Store A: 12 units Week 1 · Campaign Store: 18 units; Synthetic Counterfactual: 15.5 units; Comparison Store B: 16 units; Comparison Store A: 14 units Week 2 · Campaign Store: 20 units; Synthetic Counterfactual: 16.5 units; Comparison Store B: 17 units; Comparison Store A: 15 units
Illustrative retail example. Weights of 0.75 and 0.25 on two comparison stores, plus a level adjustment of 1 unit, reproduce the campaign store's weekly sales before launch. After launch, the gap between the campaign store and the synthetic counterfactual (2, 2.5 and 3.5 units) estimates the campaign's effect. The unit weights and level adjustment are the part of synthetic DiD shown here; its time weights are not.

Synthetic control

Compare the treated unit with a weighted blend of untreated comparison units chosen to match its pre-treatment outcome path. Check pre-treatment fit, weight concentration, and placebo gaps under the same fitting rules.

Synthetic DiD

Weight comparison units to match the treated pre-period path up to a level offset. Weight pre-period dates to match the comparison units’ later level. Inspect both sets of weights.

Triply robust panel (TROP)

Combine unit and time weighting with additive effects and a latent factor model. Check prediction on untreated cells held out of fitting and sensitivity to the factor specification.

Eligibility and spillovers
Eight cells for a triple difference
Area and dateEligibleIneligible
Program area · beforeEligible baselineSubgroup baseline
Program area · afterExposedMust be unaffected
Comparison area · beforeEligible baselineSubgroup baseline
Comparison area · afterUnexposed comparisonUnexposed subgroup
Form the eligible-minus-ineligible gap in each row. Compare its change across areas.

Common-adoption triple differences (DDD)

Compare changes in the eligibility gap across areas. Require an unaffected subgroup and parallel untreated changes in those gaps. Use a common target covariate distribution when adjusting.

Staggered triple differences

Form a triple difference for each supported cohort and date using an untreated comparison cohort with both eligibility groups. Aggregate using weights for the target population.

Spatial spillover DiD

  1. Program areaOwn adoption at month 0
  2. NeighborFirst exposure at month 0
  3. Outside radiusClean comparison while unexposed
Define the exposure radius from how the intervention travels. Record own adoption and first neighbor exposure separately.

Record own treatment and nearby exposure separately. A direct effect holds nearby exposure fixed. A spillover effect varies nearby exposure among untreated units. Check support for the chosen contrast.

Treatment intensity and switching

In marketing data, treatment intensity can be measured by weekly advertising spend, impressions or gross rating points in a market. Markets can launch at different budgets, and spend can later rise, fall, pause or resume. Which comparison is available depends on whether some markets stay at zero spend, whether spend changes come close to zero, and whether some markets hold their starting spend.

Illustrative weekly advertising spend by market ($ thousands)
MarketBaselineWeek 1Week 2Week 3
Market ANo paid media0000
Market BSmall launch budget00.50.50.5
Market CLarge launch budget0888
Market DRaises, pauses, resumes2040030
Market EHolds its starting spend20202020
Market A stays dark, so it is the zero-spend comparison for Markets B and C. Market B’s launch budget sits close to zero. Market D doubles its spend, goes dark in week 2 and resumes above its starting level, so its path crosses its baseline. Market E holds its starting spend throughout. Group markets by starting spend and by the week and direction of their first spend change before building horizon comparisons.

DiD with continuous treatment intensity

Compare markets that launch at a given weekly spend with markets that stay at zero spend, such as Market C against Market A. Under parallel trends in untreated outcomes, this identifies the average effect of that spend level for the markets that chose it. Comparing effects across spend levels, such as Market B’s budget against Market C’s, requires additional comparability assumptions: markets that chose larger budgets may have responded differently to the same spend.

Heterogeneous adoption without stayers (DIDHAD)

Sometimes every market starts spending in the same week and none stays at zero, so no market can play Market A’s role. Markets whose spend rises only slightly, like Market B, can then identify the untreated change in outcomes under continuity at zero spend and common trends. Check whether enough markets launch with budgets near zero to support that boundary. If every launch budget is far from zero, the untreated change requires extrapolation or additional comparisons.

Intertemporal DiD

Compare switchers, markets whose spend changes, with stayers that hold the same starting spend through follow-up, such as Market D against Market E. The effect compares Market D’s sales under its observed spend path with its sales had it held its starting spend. Advertising effects can carry over into later weeks, so check earlier spend histories. Inspect increases and cuts separately: Market D’s increase in week 1 and its pause in week 2 can move sales in opposite directions.

Quantiles and exit
  1. Treated pre-quantileLocate its outcome value.
  2. Control pre-rankFind the percentile of that value among controls.
  3. Control post-quantileRead the outcome at that percentile.
The transported outcome is the treated group’s counterfactual post quantile. Subtract it from the observed treated post quantile.

Changes-in-changes (CiC)

Find the treated pre-period outcome’s rank in the control distribution. Read the control post-period outcome at that rank. Check shared support and stable composition under a common monotone outcome transformation.

Additive quantile DiD

Apply the control group’s change in a specified quantile to the treated group’s pre-treatment quantile. This assumes parallel untreated quantile shifts on the chosen outcome scale.

Duration DiD

For contract exit, compare cumulative exit by a specified duration. Align the start date and risk sets. Check censoring before comparing outcomes.

Illustrative survival and cumulative hazards
GroupSurvival at month 1Survival at month 2ΔHInterval exit probability among month-1 survivors
Comparison0.800.720.10510%
Treated, observed0.750.600.22320%

The interval exit probability is 1 − exp(−ΔH), where H = −log(survival). Use an additive or proportional hazard restriction to reconstruct counterfactual survival, then report cumulative exit as one minus survival. Retention

Cutoff designs

Does a documented score threshold change eligibility, with outcome data just above and below it? Go to sharp and fuzzy Regression Discontinuity to choose between an eligibility effect and a local receipt effect, and use the cutoff explorer to inspect both sides.

Choose a design

This chooser covers designs that use outcome histories or a documented cutoff. Choose the outcome, timing and comparisons you observe. For a post-only study, see the assignment and adjustment routes.

Post-only studies

Random assignment can identify an effect using follow-up outcomes alone. See randomized assignment and the Offer Experiment. In observational data, propensity-based adjustment can support a comparison if measured pre-treatment covariates account for confounding and there is adequate overlap.

Staggered DiD. Compare each adoption cohort with unexposed, untreated observations at the same dates. Verify parallel untreated changes, no anticipation, and stable composition. See staggered-adoption methods.

Before fitting, check who remains untreated and unexposed at each horizon. Tabulate missing outcomes and check whether group composition changes.