1 What Problem Does It Solve?
Standard difference-in-differences (DiD) methods assume a binary treatment: units are either treated or not. But many real-world policies involve a continuous dose: a firm's share of costs covered by an investment subsidy, the number of training hours received by a worker, or the percentage of a community's area subject to environmental regulation. When the treatment dose varies continuously across units and over time, standard binary DiD estimates average over dose heterogeneity in an uncontrolled way.
The contdid package (Callaway et al., 2024) implements the Callaway et al. (2024) estimator for the Average Dose-Response Function (ADRF) in settings with staggered continuous treatment adoption . It combines the group-time average treatment effect framework of Callaway and Sant'Anna (2021) with doubly robust estimation and kernel smoothing to trace out the full dose-response curve.
2 The Estimand
Let Dit ∈ [0, ¯d] be the continuous treatment dose received by unit i in period t. Define Yit(d)as the potential outcome under dose d. The ADRF at dose level d is:
the average treatment effect of receiving dose d relative to no treatment. When d is binary, (1) reduces to the standard ATT.
The ADRF can also be defined at the level of dose changes (causal response function):
the average effect of moving from dose d to dose d'.
3 Identifying Assumptions
Identification of the ADRF requires:
- Parallel trends for continuous doses: for all dose levels d, the pre-treatment trend in $Y(0)$ is independent of the dose received:
This is stronger than the binary parallel trends condition because it must hold for every dose level d, not just for a treated vs. control comparison.
- No anticipation: outcomes are unaffected by future treatment.
- Staggered adoption structure: once a unit receives a positive dose, it remains treated (irreversibility), analogous to the staggered binary adoption setting.
- Overlap: for each dose level d, there are sufficient control (untreated or not-yet-treated) units with similar pre-treatment characteristics.
4 Installation and Setup
5 A Minimal Working Example
The following example uses a simulated panel dataset with a continuous treatment dose to illustrate the main workflow.
The cont_did() function returns an object with ADRF estimates at a grid of dose values, together with bootstrap standard errors and 95% uniform confidence bands.
6 Key Options and Their Meaning
7 Comparison to Alternative Approaches
The key distinction is the identification assumption. GPS and npcausal require unconfoundedness—that all confounders are observed in X. The contdid estimator instead relies on parallel trends, which is more plausible in panel settings with unit and time fixed effects. If reliable panel data are available with multiple pre-treatment periods, contdid is the preferred choice.
8 Pitfalls and Practical Advice
- Insufficient dose variation. The ADRF is poorly identified near dose levels d with few observations. Inspect the empirical distribution of D before interpretation; do not trust estimates at the tails of the dose distribution.
- Balanced panel requirement. The current implementation requires a balanced panel (all units observed in all periods). Unbalanced panels need preprocessing to fill in missing observations or to identify and restrict the estimation sample.
- Parallel trends is harder to verify. With binary treatment, pre-trend tests check a single condition. With continuous treatment, parallel trends must hold for all dose levels—a richer assumption that is harder to test nonparametrically.
- Choice of bandwidth. The ADRF estimate is sensitive to the kernel bandwidth. Report estimates at multiple bandwidths and check stability.
9 Conclusion
The contdid package extends the staggered DiD framework to continuous treatment doses, filling a significant gap in the applied econometrics toolkit. By estimating the full Average Dose-Response Function rather than a single binary ATT, it provides richer information about treatment effect heterogeneity across dose levels. Researchers working with policies that have continuous intensity variation—subsidies, training programmes, environmental regulations—should consider contdid as their primary estimation tool, conditional on having a valid parallel trends argument.
References
- Callaway, B. and Sant'Anna, P. H. C. (2021). Difference-in-differences with multiple time periods. Journal of Econometrics, 225(2):200-230.
- Callaway, B., Goodman-Bacon, A., and Sant'Anna, P. H. C. (2024). Difference-in-differences with a continuous treatment. NBER Working Paper No. 32117.
- Hirano, K. and Imbens, G. W. (2004). The propensity score with continuous treatments. In A. Gelman and X.-L. Meng (eds.), Applied Bayesian Modeling and Causal Inference from Incomplete-Data Perspectives, pages 73-84. Wiley .
- Kennedy, E. H. (2017). Non-parametric methods for doubly robust estimation of continuous treatment effects. Journal of the Royal Statistical Society, Series B, 79(4):1229-1245 .