Skip to contents

The TWFE DiD coefficient with staggered adoption is a weighted average over the complete partition of the panel into timing-group 2x2 designs (Goodman-Bacon 2021, Theorem 1, eqs. 7-9): each timing cohort against never-treated units, earlier against later cohorts before the later adopt, and later cohorts against already-treated earlier ones – the forbidden comparison. This function is a documented alias of morie_did_bacon_decomposition and returns its value unchanged.

Usage

Prtdid(data, outcome, treatment, unit, time)

Arguments

data

Long-format balanced panel data frame.

outcome

Name of the outcome column.

treatment

Name of the absorbing 0/1 treatment column.

unit

Name of the unit identifier column.

time

Name of the period column.

Value

List with components (one row per 2x2 comparison: treated cohort, control group, weight, estimate), overall_estimate (the recomposed TWFE coefficient) and details.

References

Goodman-Bacon, A. (2021). Difference-in-differences with variation in treatment timing. Journal of Econometrics, 225(2), 254-277. doi:10.1016/j.jeconom.2021.03.014. Implemented from Theorem 1 and eqs. (7)-(9) of NBER Working Paper 25018;

See also

Gbtcom for the three-way composition by comparison type.

Examples

set.seed(21)
d <- expand.grid(time = 1:6, unit = 1:30)
first <- rep(c(3, 5, Inf), each = 10)[d$unit]
d$D <- as.integer(d$time >= first)
d$y <- d$unit / 10 + d$time / 5 + 1.5 * d$D + rnorm(nrow(d), sd = 0.2)
p <- Prtdid(d, "y", "D", "unit", "time")
p$overall_estimate
#> [1] 1.511734