
Sensitivity of DiD estimate to parallel-trends violations
Source:R/did.R
morie_did_sensitivity_analysis.RdFor each \(\delta\), computes a bias-adjusted confidence set under the bound \(|\mathrm{bias}| \le \delta \hat\sigma\) (Rambachan & Roth, 2023, conservative version).
Usage
morie_did_sensitivity_analysis(
data,
outcome,
treatment,
post,
covariates = NULL,
delta_range = 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.
- delta_range
Numeric vector of \(\delta\) values to evaluate (default
seq(0, 2, 0.25)).- cluster
Optional cluster ID column for CR1 standard errors.
- alpha
Significance level for confidence intervals (default 0.05).
Details
For a relative-magnitudes bound anchored on observed event-study
pre-trends (Rambachan & Roth's \(\bar M\)
parameterization, conservative version) see
morie_did_honest_sensitivity.
References
Rambachan, A., & Roth, J. (2023). A more credible approach to parallel trends. Review of Economic Studies, 90(5), 2555–2591.
Examples
set.seed(7)
n <- 300
d <- rbinom(n, 1, 0.5); p <- rbinom(n, 1, 0.5)
y <- 1 + 0.3 * d + 0.4 * p + 0.5 * d * p + rnorm(n, sd = 0.5)
df <- data.frame(y = y, d = d, post = p)
out <- morie_did_sensitivity_analysis(df, "y", "d", "post")
str(out, max.level = 1)
#> 'data.frame': 9 obs. of 4 variables:
#> $ delta : num 0 0.25 0.5 0.75 1 1.25 1.5 1.75 2
#> $ ci_lower : num 0.1952 0.165 0.1349 0.1047 0.0745 ...
#> $ ci_upper : num 0.668 0.699 0.729 0.759 0.789 ...
#> $ covers_zero: logi FALSE FALSE FALSE FALSE FALSE FALSE ...