Skip to contents

Estimates the canonical two-group / two-period DiD treatment effect $$\hat\tau = (\bar Y_{1,\text{post}} - \bar Y_{1,\text{pre}}) - (\bar Y_{0,\text{post}} - \bar Y_{0,\text{pre}}).$$ With covariates, fits the regression \(Y = \alpha + \beta D + \gamma P + \tau (D \times P) + X\delta + \varepsilon\) and reports \(\hat\tau\).

Usage

morie_did_2x2(
  data,
  outcome,
  treatment,
  post,
  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.

post

Name of the binary (0/1) post-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 list with elements estimate, std_error, t_stat, p_value, ci_lower, ci_upper, n_treated, n_control, method, details.

Details

For multi-period staggered designs prefer morie_did_group_time_att (Callaway-Sant'Anna via did). morie_did_doubly_robust (via DRDID) is the recommended option when pre-treatment covariates are available.

References

Angrist, J. D., & Pischke, J.-S. (2009). Mostly Harmless Econometrics. Princeton University Press.

Examples

if (FALSE) { # \dontrun{
df <- data.frame(
  y    = rnorm(200),
  d    = rep(c(0, 1), each = 100),
  post = rep(c(0, 1), times = 100)
)
morie_did_2x2(df, "y", "d", "post")
} # }