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 native). morie_did_doubly_robust 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

# \donttest{
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")
#> $estimate
#> [1] -0.2594501
#> 
#> $std_error
#> interaction 
#>   0.2744695 
#> 
#> $t_stat
#> interaction 
#>  -0.9452787 
#> 
#> $p_value
#> interaction 
#>   0.3445166 
#> 
#> $ci_lower
#> interaction 
#>  -0.7974004 
#> 
#> $ci_upper
#> interaction 
#>   0.2785002 
#> 
#> $n_treated
#> [1] 100
#> 
#> $n_control
#> [1] 100
#> 
#> $method
#> [1] "did_2x2"
#> 
#> $details
#> $details$all_coefficients
#> [1]  0.03040399  0.05675479  0.16807438 -0.25945014
#> 
#> $details$all_se
#> (Intercept)           d           p interaction 
#>   0.1288547   0.1749138   0.1937529   0.2744695 
#> 
#> $details$n_obs
#> [1] 200
#> 
#> 
# }