All estimators in qte.distributional_did follow the per-cell approach of Callaway & Sant’Anna 2021: for a treatment group \(g\) and a period \(t\) they construct the counterfactual distribution of that cell and compare it to the observed one. We are often interested in effects above the level of the individual cells. In the py-qte package, besides the cell-level effect estimates, effects by treatment group, by event time and overall effects, all on the treated, are available.
In the following, we demonstrate these aggregations using the mpdta dataset, a description of which can be found here in the context of the Changes-in-Changes (CIC) estimator.
Listing 1 shows the estimation on which our aggregations are based.
Listing 1
from qte.bootstrap import BootstrapConfigfrom qte.datasets import load_mpdtafrom qte.distributional_did import estimate_changes_in_changes_effectsQS = [0.25, 0.50, 0.75]# Kept deliberately small so the page builds quickly while the documentation is being iterated on.BOOTSTRAP = BootstrapConfig(n_iter=50, seed=42, n_workers=4)panel = load_mpdta().with_columns(pl.col("first.treat").replace(0, float("inf")).alias("group"))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.64s
Aggregation
Aggregating distributional estimates differs from aggregating means. To get from cell-level means to an aggregation level of choice, it is enough to weight the individual cells by their relative cell sizes. This is not true for the aggregation of quantiles: a sum of cell-size-weighted quantiles generally does not correspond to the quantile of the distribution that corresponds to the aggregation level (for instance, the overall distribution of outcomes under treatment and under no treatment for the treated group). Thus, one first has to construct the aggregate distribution by combining the cell-level distributions (on a common grid) with the appropriate weights; the quantiles of interest are then the quantiles of that aggregate distribution.
By Treatment Group
One effect per treatment group, averaged over that group’s post-treatment periods.
cic.group.tabulate(quantiles=QS)
Table 1
Quantile & Average Treatment Effects
Outcome : lemp
Estimator : changes_in_changes
Base period : universal
Control group : never_treated
Confidence Lvl : 0.95
treatment_group
Quantile
Effect Estimate
Std. Error
Lower CI
Upper CI
Quantile Treatment Effects
2004
0.25
−0.17
0.15
−0.46
0.12
2004
0.50
−0.13
0.10
−0.32
0.06
2004
0.75
−0.04
0.08
−0.19
0.11
2006
0.25
−0.11
0.07
−0.25
0.04
2006
0.50
0.02
0.07
−0.11
0.14
2006
0.75
−0.02
0.09
−0.19
0.16
2007
0.25
−0.03
0.07
−0.16
0.10
2007
0.50
−0.12
0.06
−0.23
0.00
2007
0.75
−0.07
0.06
−0.19
0.05
Average Treatment Effects
2004
-
−0.07
0.05
−0.16
0.03
2006
-
0.00
0.03
−0.05
0.05
2007
-
−0.02
0.02
−0.06
0.03
show_chart(cic.group.plot(), facet_width=200)
Figure 1: Changes-in-Changes, aggregated by treatment group.
By Time Since Treatment
Effects by event time \(e = t - g\); negative event times are placebo cells.
cic.event_study.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
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