Skip to contents

Native event-study estimator: relative-time dummies (with reference_period dropped as the baseline) on unit and time fixed effects, fitted by the same native TWFE engine as morie_did_panel_fe. Reproduces fixest::feols + fixest::i() to machine precision (see tests/cross/).

Usage

morie_did_event_study(
  data,
  outcome,
  unit,
  time,
  treatment_time,
  covariates = NULL,
  reference_period = -1L,
  leads = 4L,
  lags = 4L,
  cluster = NULL,
  alpha = 0.05
)

Arguments

data

Panel data frame.

outcome

Outcome column.

unit

Unit identifier column.

time

Calendar-time column (integer-valued).

treatment_time

Column giving the period in which each unit first received treatment (Inf or NA for never-treated units).

covariates

Optional time-varying covariates.

reference_period

Relative-time period omitted as baseline (default -1).

leads

Number of pre-treatment periods to include.

lags

Number of post-treatment periods to include.

cluster

Cluster variable for standard errors (defaults to unit).

alpha

Significance level.

Value

A list with coefficients (data frame), reference_period, pre_trend_f_stat, pre_trend_p_value, and details.

Examples

set.seed(1)
df <- expand.grid(unit = 1:30, time = 1:6)
df$treat_time <- ifelse(df$unit <= 15, 4, Inf)
df$d <- as.integer(df$time >= df$treat_time)
df$y <- 0.1 * df$time + 0.7 * df$d + rnorm(nrow(df), sd = 0.4)
res <- morie_did_event_study(df, "y", "unit", "time", "treat_time",
                             leads = 2L, lags = 2L)
res$coefficients
#>   relative_time    estimate std_error    ci_lower  ci_upper      p_value
#> 1            -2 -0.06545429 0.1456526 -0.35092815 0.2200196 6.531530e-01
#> 2            -1  0.00000000 0.0000000  0.00000000 0.0000000           NA
#> 3             0  0.50753098 0.1918843  0.13144473 0.8836172 8.169457e-03
#> 4             1  0.84043472 0.1951271  0.45799268 1.2228768 1.653977e-05
#> 5             2  0.40110683 0.1917268  0.02532915 0.7768845 3.643184e-02