
Unified Pre-Trends Testing for Event Study Models
test_pretrends.RdTests the parallel trends assumption by performing a joint F-test of
pre-treatment coefficients and optionally running sensitivity analysis
via HonestDiD. Accepts either a fixest model object or manually
supplied coefficient estimates and variance-covariance matrix.
Usage
test_pretrends(
model = NULL,
betahat = NULL,
sigma = NULL,
pre_periods = NULL,
conf_level = 0.95,
honest_did = FALSE
)Arguments
- model
A
fixestmodel object fromfeols. IfNULL,betahatandsigmamust be provided.- betahat
Numeric vector of pre-treatment coefficient estimates. Used only when
modelisNULL.- sigma
Variance-covariance matrix for
betahat. Used only whenmodelisNULL.- pre_periods
Integer vector indicating which coefficients are pre-treatment. If
NULL(default), auto-detected from negative period names in thefixestmodel (e.g., coefficients containing"-1","-2", etc.).- conf_level
Numeric. Confidence level for individual tests. Default is
0.95.- honest_did
Logical. If
TRUEand the HonestDiD package is installed, run sensitivity analysis usingHonestDiD::createSensitivityResults. Default isFALSE.
Value
A list with components:
- joint_test
A list with
f_stat,df1,df2, andp_valuefrom the joint F-test of pre-treatment coefficients equal to zero.- individual_tests
A data frame with columns
term,estimate,std_error,t_stat,p_value,ci_lower,ci_upperfor each pre-treatment coefficient.- plot
A
ggplot2object showing pre-treatment coefficients with confidence intervals and a reference line at zero.- honest_did
If requested and available, results from HonestDiD sensitivity analysis. Otherwise
NULL.
Examples
if (FALSE) { # \dontrun{
data(base_stagg, package = "fixest")
mod <- feols(y ~ i(time_to_treatment, ref = -1) | id + year,
data = base_stagg)
result <- test_pretrends(mod)
result$joint_test
result$plot
# Manual input
result2 <- test_pretrends(
betahat = c(-0.02, 0.01, -0.03),
sigma = diag(c(0.01, 0.01, 0.01)),
pre_periods = 1:3
)
} # }