| Type: | Package |
| Title: | Estimators DID with Multiple Groups and Periods |
| Version: | 2.1.0 |
| Maintainer: | Anzony Quispe <anzony.quispe@gmail.com> |
| Description: | Estimators of Difference-in-Differences based on de Chaisemartin and D'Haultfoeuille. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| LazyData: | true |
| URL: | https://github.com/Credible-Answers/did_multiplegt |
| Depends: | R(≥ 3.4.0) |
| Imports: | dplyr (≥ 1.0.0), fixest (≥ 0.6.0), plotrix, sampling, stats, parallel, stringr, rlang, DIDmultiplegtDYN, DIDHAD |
| Suggests: | polars |
| Author: | Anzony Quispe [aut, cre], Diego Ciccia [aut], Felix Knau [aut], Mélitine Malezieux [aut], Doulo Sow [aut], Shuo Zhang [aut], Clément de Chaisemartin [aut] |
| RoxygenNote: | 7.3.3 |
| Additional_repositories: | https://rpolars.r-universe.dev |
| NeedsCompilation: | no |
| Packaged: | 2026-02-17 12:51:23 UTC; anzony.quisperojas |
| Repository: | CRAN |
| Date/Publication: | 2026-02-17 14:30:02 UTC |
Main function
Description
Library of Estimators in Difference-in-Difference (DID) designs with multiple groups and periods.
Usage
did_multiplegt(mode, ...)
Arguments
mode |
("dyn", "had", "old") Estimator selector. The |
... |
Options passed to specified estimator. For more details on allowed options, check out the command-specific documentation: did_multiplegt_dyn, did_had, did_multiplegt_old. |
Overview
did_multiplegt wraps in a single command all the estimators from de Chaisemartin and D'Haultfoeuille. Depending on the mode argument, this command can be used to call the following estimators.
did_multiplegt_dyn. In dyn mode, the command computes the DID event-study estimators introduced in de Chaisemartin and D'Haultfoeuille (2024a). This mode can be used both with a binary and staggered (absorbing) treatment and a non-binary treatment (discrete or continuous) that can increase or decrease multiple times. The estimator is also robust to heterogeneous effects of the current and lagged treatments. Lastly, it can be used with data where the panel st is unblanced or more disaggregated than the group level.
did_had. In had mode, the command computes the DID estimator introduced in de Chaisemartin and D'Haultfoeuille (2024b). This mode estimates the effect of a treatment on an outcome in a heterogeneous adoption design (HAD) with no stayers but some quasi stayers.
did_multiplegt_old. In old mode, the command computes the DID estimators introduced in de Chaisemartin and D'Haultfoeuille (2020). This mode corresponds to the old version of the did_multiplegt command. Specifically, it can be used to estimate DID_M, i.e. the average across t and d of the treatment effects of groups that have treatment d at t-1 and change their treatment at t, using groups that have treatment d at t-1 and t as controls. This mode could also be used to compute event-study estimates, but we strongly suggest to use the dyn mode, since it is way faster and includes comprehensive estimation and post-estimation support.
References
de Chaisemartin, C and D'Haultfoeuille, X (2020). American Economic Review, vol. 110, no. 9. Two-Way Fixed Effects Estimators with Heterogeneous Treatment Effects.
de Chaisemartin, C and D'Haultfoeuille, X (2024a). Review of Economics and Statistics, 1-45. Difference-in-Differences Estimators of Intertemporal Treatment Effects.
de Chaisemartin, C and D'Haultfoeuille, X (2024b). Two-way Fixed Effects and Differences-in-Differences Estimators in Heterogeneous Adoption Designs.
Vella, F. and Verbeek, M. 1998. Journal of Applied Econometrics 13(2), 163–183. Whose wages do unions raise? a dynamic model of unionism and wage rate determination for young men.
Examples
# Test all modes using Vella and Verbeek (1998) data:
data("wagepan_mgt")
wagepan_mgt$X <- runif(n=nrow(wagepan_mgt)) * (wagepan_mgt$year >= 1983)
Y = "lwage"
G = "nr"
T = "year"
D = "union"
X = "X"
did_multiplegt(mode = "old", wagepan_mgt, Y, G, T, D)
## Not run:
# These examples require polars package to be installed
did_multiplegt(mode = "dyn", wagepan_mgt, Y, G, T, D, graph_off = TRUE)
did_multiplegt(mode = "had", wagepan_mgt, Y, G, T, X, graph_off = TRUE)
## End(Not run)
Old DID Multiplegt Estimator (de Chaisemartin and D'Haultfoeuille 2020)
Description
This is the old version of did_multiplegt from de Chaisemartin and D'Haultfoeuille (2020). For most use cases, we recommend using did_multiplegt with mode="dyn" instead, which is faster and has more features.
Usage
did_multiplegt_old(
df,
Y,
G,
T,
D,
controls = c(),
placebo = 0,
dynamic = 0,
threshold_stable_treatment = 0,
recat_treatment = NULL,
trends_nonparam = NULL,
trends_lin = NULL,
brep = 0,
cluster = NULL,
covariance = FALSE,
average_effect = NULL,
parallel = FALSE
)
Arguments
df |
the data frame for input |
Y |
the name of Y variable |
G |
the name of group variable |
T |
the name of time variable |
D |
the name of treatment variable |
controls |
the list of names of control variables, empty if not specified |
placebo |
the number of placebo estimators |
dynamic |
the number of dynamic estimators |
threshold_stable_treatment |
the threshold to mark a difference stable |
recat_treatment |
the name of treatment group recategorized |
trends_nonparam |
trends nonparametric option |
trends_lin |
trends linear option |
brep |
the number of bootstrap replications |
cluster |
cluster variable for standard errors |
covariance |
whether to compute covariance |
average_effect |
average effect option |
parallel |
whether to run bootstrap in parallel |
Value
A list with treatment effects and related statistics
wagepan_mgt
Description
A subset of data from Vella and Verbeek (1998).
Usage
wagepan_mgt
Format
## 'wagepan_mgt' A data frame with 4,360 rows and 5 columns:
- lwage
Log wage.
- nr
Worker ID.
- year
Year
- union
Union status.
- hours
Annual Hours worked.
Source
<http://fmwww.bc.edu/ec-p/data/wooldridge/wagepan.des>