Skip to contents

Native two-way fixed-effects estimator of \(Y_{it} = \alpha_i + \lambda_t + \tau D_{it} + X'\delta + \varepsilon_{it}\) via alternating-projection demeaning (Frisch-Waugh-Lovell) with CR1 cluster-robust standard errors using the same small-sample correction as fixest::feols's default (reproduced to machine precision in tests/cross/).

Usage

morie_did_panel_fe(
  data,
  outcome,
  treatment,
  unit,
  time,
  covariates = NULL,
  cluster = NULL,
  alpha = 0.05
)

Arguments

data

A data frame containing the outcome, treatment, post and any covariate columns.

outcome

Name of the outcome column.

treatment

Name of the binary (0/1) treatment-group column.

unit

Unit identifier column.

time

Time period column.

covariates

Optional character vector of covariate column names.

cluster

Optional cluster ID column for CR1 standard errors.

alpha

Significance level for confidence intervals (default 0.05).

Value

A result list; see morie_did_2x2.

Examples

set.seed(2)
df <- expand.grid(unit = 1:60, time = 1:6)
df$treat_time <- ifelse(df$unit <= 30, 4, Inf)
df$d <- as.integer(df$time >= df$treat_time)
df$y <- 0.5 * df$time + 1.5 * df$d + rnorm(nrow(df), sd = 0.5)
res <- morie_did_panel_fe(df, "y", "d", "unit", "time")
res$estimate
#> [1] 1.443414