py-qte
  • Unconfounded
    • Estimators
    • Benchmarks
  • IV
    • Estimators
    • Instrument Validity
  • Regression Discontinuity
    • Estimators
  • Difference-in-Differences
    • Estimators
    • Aggregating Estimates
  • Reference

On this page

  • The Data
  • Changes-in-Changes
  • Quantile Difference-in-Differences
  • Mean Difference-in-Differences
  • Distributional Difference-in-Differences
  • Summary
  • References
  • View source
  • Report an issue

Distributional Difference-in-Differences

This page demonstrates the estimators that py-qte offers for distributional difference-in-differences. The available estimators are

  1. Changes-in-changes (Athey & Imbens 2006),
  2. Quantile difference-in-differences (Athey & Imbens 2006, Section 3.3),
  3. Mean difference-in-differences, and
  4. Distributional difference-in-differences (Callaway, Li & Oka 2018).

All four follow the approach of Callaway & Sant’Anna 2021 in that they allow an arbitrary number of groups and time periods, but the actual effects are estimated per treated group-time cell relative to a single comparison (pre-treatment) period and a single control group. The estimators offer various ways to determine the comparison group and period. As in Callaway & Sant’Anna 2021, aggregation procedures are offered which give treatment effects at higher levels than the individual group-time cells of the treated. The available aggregations are described here.

The object of interest in what follows is the entire distribution of \(Y^{d=0}(d=1,t=T)\), i.e. the potential outcome under no treatment (as indicated by the superscript \(d=0\)) for a group that was in fact treated, i.e. \(d=1\), at period \(T\).

The available estimators differ in under what assumptions this counterfactual distribution is derived from observables. The following sections give a brief description of each estimator and the underlying identification assumptions, together with showing how the corresponding estimation can be performed with the py-qte package and how to present the results.

Listing 1 displays what quantiles are computed throughout and the configuration of the boostrap.

Listing 1
from qte.bootstrap import BootstrapConfig

QS = [0.25, 0.50, 0.75]
BOOTSTRAP = BootstrapConfig(n_iter=50, seed=42, n_workers=4)

The Data

The demonstration data are county-level teen employment in the United States from 2003 to 2007, together with whether a county’s minimum wage was raised above the federal minimum. The dataset contains three treatment groups identified by the year in which the respective county was initially treated (2004, 2006, 2007). There is also a group of counties that was never treated. The panel is balanced: 500 counties observed in each of the five years.

The outcome of interest is lemp, the natural logarithm of the number of employed teenagers in the county. Because it is a count and not a rate, its level also reflects how large a county is, and differences in county size across the treatment groups are visible in the averages below.

Listing 2
from qte.datasets import load_mpdta

GROUP_LABEL = (
    pl.col("group")
    .replace(float("inf"), None)
    .cast(pl.Int64)
    .cast(pl.String)
    .fill_null("never treated")
    .alias("Group")
)

# `first.treat` is 0 for counties that never raised their minimum wage; the estimators expect
# +inf for never-treated units, which is what the default of `TrtGroupConfig` assumes.
panel = load_mpdta().with_columns(pl.col("first.treat").replace(0, float("inf")).alias("group"))
print(f"{panel.height:,} county-year observations for {panel['countyreal'].n_unique()} counties")
print(f"years: {panel['year'].unique().sort().to_list()}")
2,500 county-year observations for 500 counties
years: [2003, 2004, 2005, 2006, 2007]

Table 1 reports the average log teen employment by treatment group and year. We see that there are large differences in the outcome variable even under no treatment. This suggests that a simple comparison between the treated group and a control group will not successfully identify treatment effects on the treated group. The distributional difference-in-differences estimators can address some of the potential confounding.

Table 1

Average log teen employment by treatment group and year
Group1 2003 2004 2005 2006 2007
2004 6.180 6.107 6.059 6.027 6.085
2006 6.574 6.518 6.528 6.557 6.543
2007 5.843 5.811 5.821 5.824 5.820
never treated 5.655 5.592 5.605 5.639 5.661
Yellow cells are years in which the group is treated; grey cells are not treated, which includes the years before a group is treated and the never-treated counties throughout.
1 Group is the first year in which the county's minimum wage exceeded the federal minimum.

Changes-in-Changes

The Changes-in-Changes (CIC) model was developed by Athey & Imbens 2006. The crucial assumptions are that the outcomes under no treatment — if the causal target of interest is an effect on the treated — are determined by a “production function”, \(Y^{d=0}=h(U,t)\), that depends on time, \(t\), and on a single unobserved index of individual-level characteristics, \(U\).

The production function is assumed to be monotone in that index, and it is indexed by neither group membership nor the individual observation \(i\). The distribution of \(U\) is unrestricted across groups but, within a group, does not change over time. It is further assumed that the latent characteristics satisfy a common support assumption across groups.

So this model, intuitively, assumes that in the absence of the treatment two individuals from different groups with the same latent characteristic \(U=u\) display the exact same evolution of outcomes. This, together with the assumption of common support, suggests that one can indeed identify the counterfactual distribution of the outcomes of the treated under no treatment in the post-treatment period.

Formally, under the assumptions of the CIC model this counterfactual distribution is generated by the following transformation, applied to the outcomes of the treated in the pre-treatment period.

\[ k_{CIC}(y) = F^{-1}_{Y^{obs}(d=0,t=1)}\!\left(F_{Y^{obs}(d=0,t=0)}(y)\right). \]

Listing 3 shows how to use this estimator in py-qte.

Listing 3
from qte.distributional_did import estimate_changes_in_changes_effects

with timer("changes-in-changes"):
    cic = estimate_changes_in_changes_effects(
        panel,
        "lemp",
        "group",
        "year",
        "countyreal",
        qs=QS,
        bootstrap_config=BOOTSTRAP,
    )
[changes-in-changes] 1.80s

Table 2 and Figure 1 show the results in tabular and graphical form.

cic.overall.tabulate(quantiles=QS)
Table 2

Quantile & Average Treatment Effects
Outcome         : lemp
Estimator       : changes_in_changes
Base period     : universal
Control group   : never_treated
Confidence Lvl  : 0.95
Quantile Effect Estimate Std. Error Lower CI Upper CI
Quantile Treatment Effects
0.25 −0.10 0.05 −0.20 0.00
0.50 0.00 0.05 −0.10 0.10
0.75 −0.05 0.06 −0.17 0.08
Average Treatment Effects
- −0.02 0.02 −0.05 0.02
show_chart(cic.overall.plot())
Figure 1: Changes-in-Changes: quantile treatment effects on the overall aggregation.

Quantile Difference-in-Differences

The Quantile Difference-in-Differences (QDID) model is motivated by the idea that the observed evolution of a quantile \(q\) of the (marginal) distribution of outcomes that the untreated experienced from the pre- to the post-treatment period can act as a stand-in for the counterfactual evolution of the same quantile that the outcome distribution of the treated would have experienced had they not been treated.

\[ F^{-1}_{Y^{d=0}(d=1,t=1)}(q) = F^{-1}_{Y^{obs}(d=1,t=0)}(q) + \left[F^{-1}_{Y^{obs}(d=0,t=1)}(q) - F^{-1}_{Y^{obs}(d=0,t=0)}(q)\right] \]

The QDID model is formalized — that is, connected to a set of assumptions on primitives — in Athey & Imbens 2006, Section 3.3. They assume that \(Y^{d=0} = \tilde{h}(U,G,T) = \tilde{h}_G(U,G) + \tilde{h}_T(U,T)\), which is strictly increasing in \(U\), and that \(U\) is independent of both \(G\) and \(T\). This model generates differences in the distribution of \(Y^{d=0}\) both across groups and across time. Intuitively, at a fixed \(U\) the change in untreated potential outcomes is identical across the two groups, which is what identifies the counterfactual distribution in an essentially analogous way to the standard difference-in-differences model (at a fixed \(u\) the counterfactual post-treatment period outcome of the treatment is exactly equal to the pre-treatment period outcome plus the observed change in the outcome derived from the untreated).

Applied to each treated pre-treatment outcome rather than to one quantile at a time, the identity above gives the following transformation:

\[ k_{QDID}(y) = y + \left[F^{-1}_{Y^{obs}(d=0,t=1)}(q) - F^{-1}_{Y^{obs}(d=0,t=0)}(q)\right], \qquad q = F_{Y^{obs}(d=1,t=0)}(y). \]

Listing 4 shows how to use this estimator in py-qte.

Listing 4
from qte.distributional_did import estimate_quantile_did_effects

with timer("quantile difference-in-differences"):
    qdid = estimate_quantile_did_effects(
        panel,
        "lemp",
        "group",
        "year",
        "countyreal",
        qs=QS,
        bootstrap_config=BOOTSTRAP,
    )
[quantile difference-in-differences] 1.74s

Table 3 and Figure 2 show the results in tabular and graphical form.

qdid.overall.tabulate(quantiles=QS)
Table 3

Quantile & Average Treatment Effects
Outcome         : lemp
Estimator       : quantile_did
Base period     : universal
Control group   : never_treated
Confidence Lvl  : 0.95
Quantile Effect Estimate Std. Error Lower CI Upper CI
Quantile Treatment Effects
0.25 −0.11 0.06 −0.22 0.00
0.50 −0.05 0.05 −0.14 0.03
0.75 −0.02 0.05 −0.12 0.07
Average Treatment Effects
- −0.03 0.01 −0.05 0.00
show_chart(qdid.overall.plot())
Figure 2: Quantile Difference-in-Differences: quantile treatment effects on the overall aggregation.

Mean Difference-in-Differences

Mean Difference-in-Differences (MDID) shifts the treated group’s whole pre-treatment distribution by the change in the comparison group’s mean:

\[ \begin{aligned} F_{Y(0)\mid D=1}(y) &= F_{Y,\text{pre}\mid D=1}(y - \Delta), \\[2pt] \Delta &= E[Y_{\text{post}} \mid D=0] - E[Y_{\text{pre}} \mid D=0]. \end{aligned} \]

This is stronger than the usual difference-in-differences assumption, which only requires the means to move in parallel: here every quantile of the counterfactual distribution is the corresponding pre-treatment quantile shifted by the same constant, \(F^{-1}_{Y^{d=0}(d=1,t=1)}(q) = F^{-1}_{Y^{obs}(d=1,t=0)}(q) + \Delta\). In the notation of Athey & Imbens 2006 this is the transformation \(k_{DID}(y) = y + E[Y_{01}] - E[Y_{00}]\).

Relative to the QDID model, the change is not allowed to vary with \(u\): in the QDID model above the time effect can differ across quantiles, whereas here it is a single number. The quantile effects this model reports are consequently not evidence about how effects vary across the distribution — they are the treated group’s own distributional change net of a constant, and only the average effect rests on the identifying assumption.

Listing 5 shows how to use this estimator in py-qte.

Listing 5
from qte.distributional_did import estimate_mean_did_effects

with timer("mean difference-in-differences"):
    mdid = estimate_mean_did_effects(
        panel,
        "lemp",
        "group",
        "year",
        "countyreal",
        qs=QS,
        bootstrap_config=BOOTSTRAP,
    )
[mean difference-in-differences] 1.52s

Table 4 and Figure 3 show the results in tabular and graphical form.

mdid.overall.tabulate(quantiles=QS)
Table 4

Quantile & Average Treatment Effects
Outcome         : lemp
Estimator       : mean_did
Base period     : universal
Control group   : never_treated
Confidence Lvl  : 0.95
Quantile Effect Estimate Std. Error Lower CI Upper CI
Quantile Treatment Effects
0.25 −0.08 0.04 −0.16 0.00
0.50 −0.05 0.05 −0.14 0.04
0.75 −0.02 0.04 −0.09 0.06
Average Treatment Effects
- −0.03 0.01 −0.06 0.00
show_chart(mdid.overall.plot())
Figure 3: Mean Difference-in-Differences: quantile treatment effects on the overall aggregation.

Distributional Difference-in-Differences

The Distributional Difference-in-Differences (DDiD) model of Callaway, Li & Oka 2018 assumes that the change in untreated potential outcomes has the same distribution in both groups. This, however, is not enough to identify \(F_{Y^{d=0}(d=1,t=1)}\). Intuitively, for a given pre-treatment period distribution of outcomes for the treated, \(F_{Y^{d=0}(d=1,t=0)}\), a restriction on the distribution of changes can generate many distributions of the outcome levels of the treated group in the post-treatment period. This issue can be remedied by imposing that the pre-treatment period levels and the changes from the pre- to the post-treatment period move in a similar way together in the treated and in the untreated group. Technically, it is required that the associated copula be the same in both groups.

The counterfactual distribution of interest is then given by:

\[ F_{Y(0)\mid D=1}(y) = \Pr\left\{\Delta Y_{j} + F^{-1}_{Y_{10}}\!\left(F_{Y_{00}}(Y_{j})\right) \le y \;\middle|\; D = 0\right\}, \]

where \(\Delta Y_j\) is comparison unit \(j\)’s own change and \(Y_j\) its pre-treatment outcome.

Listing 6 shows how to use this estimator in py-qte.

Listing 6
from qte.distributional_did import estimate_distributional_did_effects

with timer("distributional difference-in-differences"):
    ddid = estimate_distributional_did_effects(
        panel,
        "lemp",
        "group",
        "year",
        "countyreal",
        qs=QS,
        bootstrap_config=BOOTSTRAP,
    )
[distributional difference-in-differences] 1.63s

Table 5 and Figure 4 show the results in tabular and graphical form.

ddid.overall.tabulate(quantiles=QS)
Table 5

Quantile & Average Treatment Effects
Outcome         : lemp
Estimator       : distributional_did
Base period     : universal
Control group   : never_treated
Confidence Lvl  : 0.95
Quantile Effect Estimate Std. Error Lower CI Upper CI
Quantile Treatment Effects
0.25 −0.09 0.05 −0.19 0.02
0.50 −0.09 0.05 −0.19 0.00
0.75 −0.04 0.05 −0.13 0.06
Average Treatment Effects
- −0.05 0.01 −0.08 −0.02
show_chart(ddid.overall.plot())
Figure 4: Distributional Difference-in-Differences: quantile treatment effects on the overall aggregation.

Summary

Finally, Table 6 compares the four estimators.

Table 6

Quantile treatment effects, overall aggregation, all four estimators
Quantile Changes-in-changes Quantile DiD Mean DiD Distributional DiD
0.25 −0.102 −0.110 −0.078 −0.086
0.5 0.000 −0.055 −0.047 −0.094
0.75 −0.047 −0.023 −0.016 −0.039

References

  1. Athey, S., & Imbens, G. W. (2006). Identification and inference in nonlinear difference-in-differences models. Econometrica, 74(2), 431–497. doi:10.1111/j.1468-0262.2006.00668.x
  2. Callaway, B., Li, T., & Oka, T. (2018). Quantile treatment effects in difference in differences models under dependence restrictions and with only two time periods. Journal of Econometrics, 206(2), 395–413. doi:10.1016/j.jeconom.2018.06.008
  3. Callaway, B., & Sant’Anna, P. H. C. (2021). Difference-in-differences with multiple time periods. Journal of Econometrics, 225(2), 200–230. doi:10.1016/j.jeconom.2020.12.001
  • View source
  • Report an issue