Skip to contents

Introduction

This vignette provides an overview of estimation and uniform inference methods that can be implemented using the didhetero package.

For the sake of brevity, we omit many details of our methods here, which can be found in Imai, Qin, and Yanagi (2025).

Staggered DiD Setup

We consider essentially the same staggered difference-in-differences (DiD) setup as in Callaway and Sant’Anna (2021).

We have balanced panel data for which we observe the following variables for units i=1,,ni = 1, \dots, n and periods t=1,,𝒯t = 1, \dots, \mathcal{T}.

  • The outcome variable Yi,tY_{i,t}.

  • The binary treatment Di,tD_{i,t} such that Di,1=0D_{i,1} = 0 and that Di,t1=1D_{i,t-1} = 1 implies Di,t=1D_{i,t} = 1 for any t=3,,𝒯t = 3, \dots, \mathcal{T}.

  • The “group” Gi=min{t:Di,t=1}G_i = \min\{ t : D_{i,t} = 1 \} if Di,t=1D_{i,t} = 1 for some tt, and Gi=0G_i = 0 otherwise.

  • The kk-dimensional vector of the pre-treatment covariates XiX_i that includes a scalar continuous covariate ZiZ_i as an element of particular interest.

Target Parameters

To examine the heterogeneity in treatment effects with respect to groups, periods, and continuous covariate values, we consider two types of target parameters:

  • The group-time conditional average treatment effect (CATT) given Z=zZ = z.

  • The summary parameters that aggregate CATTs with estimable weighting functions.

CATT is CATTg,t(z)=𝔼[Yi,t(g)Yi,t(0)Gi,g=1,Zi=z],\begin{equation} {\text{CATT}}_{g,t}(z) = \mathbb{E} [ Y_{i,t}(g) - Y_{i,t}(0) \mid G_{i,g} = 1, Z_i = z ], \end{equation} where Yi,t(g)Y_{i,t}(g) and Yi,t(0)Y_{i,t}(0) denote the potential outcomes given Gi=gG_i = g and Gi=0G_i = 0, respectively, and zz is a value of ZiZ_i. Estimating CATTg,t(z){\text{CATT}}_{g,t}(z) over (g,t,z)(g, t, z) is helpful in understanding the treatment effect heterogeneity with respect to group gg, calendar time tt, and covariate value zz.

The aggregated parameter is θ(z)=g𝒢t=2𝒯wg,t(z)CATTg,t(z),\begin{equation} \theta(z) = \sum_{g \in \mathcal{G}} \sum_{t=2}^{\mathcal{T}} w_{g,t}(z) \cdot \text{CATT}_{g,t}(z), \end{equation} where 𝒢\mathcal{G} denotes the set of realized treatment timings and wg,t(z)w_{g,t}(z) is an estimable weighting function that determines the causal interpretation of this aggregated parameter.

Examples include:

  • The event-study-type conditional average treatment effect θes(e,z)\theta_{\text{es}}(e, z).

  • The group-specific conditional average treatment effect θsel(g,z)\theta_{\text{sel}}(g, z).

  • The calendar-time conditional average treatment effect θc(t,z)\theta_{\text{c}}(t, z).

  • The simple weighted conditional average treatment effect θWO(z)\theta_{\text{W}}^{\text{O}}(z).

Doubly Robust Identification, Estimation, and Uniform Inference

We can show that CATTg,t(z)\text{CATT}_{g,t}(z) is identified by a conditional doubly robust (DR) estimand DRg,t(z)\text{DR}_{g,t}(z), which is a conditional counterpart of the DR estimand in Callaway and Sant’Anna (2021). This identification result serves as a building block of estimation and uniform inference for CATT and the aggregated parameter.

To perform uniform inference for CATTg,t(z)\text{CATT}_{g,t}(z) over a set of (g,t,z)(g, t, z), we can construct a (1α)(1 - \alpha) uniform confidence band for CATTg,t(z)\text{CATT}_{g,t}(z) over the set of (g,t,z)(g, t, z) by a family of intervals, denoted as 𝒞={𝒞g,t(z)}\mathcal{C} = \{ \mathcal{C}_{g,t}(z) \} with 𝒞g,t(z)=[DR̂g,t(z)c(1α)SÊg,t(z),DR̂g,t(z)+c(1α)SÊg,t(z)],\begin{equation} \mathcal{C}_{g,t}(z) = \left[ \widehat{\text{DR}}_{g,t}(z) - c(1 - \alpha) \cdot \widehat{\text{SE}}_{g,t}(z), \qquad \widehat{\text{DR}}_{g,t}(z) + c(1 - \alpha) \cdot \widehat{\text{SE}}_{g,t}(z) \right], \end{equation} where DR̂g,t(z)\widehat{\text{DR}}_{g,t}(z) is a three-step estimator computed with certain parametric estimation procedures and nonparametric local polynomial regressions, SÊg,t(z)\widehat{\text{SE}}_{g,t}(z) is a pointwise standard error, and c(1α)c(1 - \alpha) is a uniform critical value obtained from an analytical method or weighted bootstrapping.

To perform uniform inference for the aggregated parameter, we can construct a (1α)(1 - \alpha) uniform confidence band for θ(z)\theta(z) over the set of zz and the variable specific to the summary parameter of interest (e.g., treatment exposure time ee) by a family of intervals, denoted as 𝒞θ={𝒞θ(z)}\mathcal{C}_{\theta} = \{ \mathcal{C}_{\theta}(z) \} with 𝒞θ(z)=[θ̂(z)cθ(1α)SÊθ(z),θ̂(z)+cθ(1α)SÊθ(z)],\begin{equation} \mathcal{C}_{\theta}(z) = \left[ \widehat{\theta}(z) - c_{\theta}(1 - \alpha) \cdot \widehat{\text{SE}}_{\theta}(z), \quad \widehat{\theta}(z) + c_{\theta}(1 - \alpha) \cdot \widehat{\text{SE}}_{\theta}(z) \right], \end{equation} where θ̂(z)\widehat{\theta}(z) is an estimator obtained as an empirical analogue of θ(z)\theta(z), SÊθ(z)\widehat{\text{SE}}_{\theta}(z) is a pointwise standard error, and cθ(1α)c_{\theta}(1 - \alpha) is a uniform critical value via an analytical method or multiplier bootstrapping.

Importantly, to ensure the validity of uniform inference, the critical value c(1α)c(1 - \alpha) must not depend on (g,t,z)(g, t, z) and is larger than the standard Wald-type pointwise critical value (i.e., the (1α/2)(1 - \alpha/2) quantile of the standard normal distribution). Similarly, the uniform critical value cθ(1α)c_{\theta}(1 - \alpha) should not depend on zz and the variable specific to the summary parameter of interest (e.g., treatment exposure time ee) and is larger than the standard Wald-type pointwise critical value.

Recommendations

  • For constructing the uniformly valid critical value, the bootstrap would work better than the analytical method.

  • For the choice of the local polynomial order, the recommended default is p = 2.

  • For the bandwidth, we recommend different choices depending on the local polynomial order. When p = 2, the recommended default is to use the IMSE-optimal bandwidth for local linear regression (bwselect = "IMSE1"). When p = 1, the recommended default is to use the rule-of-thumb undersmoothing for local linear regression (bwselect = "US1"). This is because we need to make bias arising from kernel smoothing asymptotically negligible for justify our uniform confidence bands. In this view, bwselect = "IMSE2" is not recommended.

  • Although checking for the heterogeneity in pre-trends is useful for assessing the credibility of the identifying assumptions, doing so may widen the confidence intervals in post-treatment periods. In this view, we set pretrend = FALSE as the default.

  • To examine the heterogeneity in all key variables and covariate values, the recommended default is uniformall = TRUE.

References

  • Callaway, B., & Sant’Anna, P. H. (2021). Difference-in-differences with multiple time periods. Journal of Econometrics, 225(2), 200-230. Link

  • Imai, S., Qin, L., & Yanagi, T. (2025). Doubly Robust Uniform Confidence Bands for Group-Time Conditional Average Treatment Effects in Difference-in-Differences. arXiv preprint arXiv:2305.02185. Link