Skip to contents

Fits unit and time fixed effects on the UNTREATED observations only (via the native alternating demeaner), imputes the untreated potential outcome for every treated cell, and averages the treatment-minus-imputation differences. Standard error by cluster (unit) bootstrap of the whole impute-and-average pipeline – conservative and assumption-light.

Usage

morie_did_borusyak(
  data,
  outcome,
  unit,
  time,
  treatment_time,
  n_bootstrap = 199L,
  seed = 42L,
  alpha = 0.05
)

Arguments

data

Long panel data frame.

outcome, unit, time

Column names.

treatment_time

First treated period per unit (NA = never).

n_bootstrap

Cluster-bootstrap replications. Default 199.

seed

RNG seed.

alpha

CI tail.

Value

List of class "morie_did": estimate, std.error, conf.int, p.value, method, n_units, n_periods, call.

References

Borusyak, Jaravel & Spiess (2024) REStud 91(6).

Examples

df <- expand.grid(id = 1:40, t = 1:8)
df$g <- ifelse(df$id <= 20, 5L, NA)
df$y <- rnorm(nrow(df)) + ifelse(!is.na(df$g) & df$t >= df$g, 2, 0)
morie_did_borusyak(df, "y", "id", "t", "g", n_bootstrap = 29L)
#> Difference-in-differences -- Borusyak-Jaravel-Spiess imputation (cluster bootstrap SE) 
#>   ATT: 2.3454  (SE 0.1700)  95% CI [2.0123, 2.6785]  p = 2.55e-43
#>   Units: 40  Periods: 8