| run_es | R Documentation |
Runs an event study regression on panel data, supporting both classic (universal timing) and staggered (unit-varying timing via sunab).
The function builds the design (lead/lag factor or sunab), estimates with fixest, and returns a tidy table with metadata.
run_es(
data,
outcome,
treatment = NULL,
time,
timing,
fe = NULL,
lead_range = NULL,
lag_range = NULL,
covariates = NULL,
cluster = NULL,
weights = NULL,
baseline = -1L,
interval = 1,
time_transform = FALSE,
unit = NULL,
staggered = FALSE,
method = c("classic", "sunab"),
estimator = c("twfe", "cs", "sa", "bjs"),
control_group = c("nevertreated", "notyettreated"),
anticipation = 0L,
conf.level = 0.95,
vcov = "HC1",
vcov_args = list(),
bootstrap = FALSE,
B = 999L,
alpha = 0.05,
boot_seed = NULL
)
data |
A data.frame containing panel data. |
outcome |
Unquoted outcome (name or expression, e.g., |
treatment |
Unquoted treatment indicator (0/1 or logical). Used only when |
time |
Unquoted time variable (numeric or Date). |
timing |
For |
fe |
One-sided fixed-effects formula, e.g., |
lead_range, lag_range |
Integers for pre/post windows. If |
covariates |
One-sided formula of additional controls, e.g., |
cluster |
Cluster specification (one-sided formula like |
weights |
Observation weights (a name/one-sided formula or a numeric vector of length |
baseline |
Integer baseline period (default |
interval |
Numeric spacing of the time variable (default |
time_transform |
Logical; if |
unit |
Unit identifier variable (required when |
staggered |
Logical; if |
method |
Either |
estimator |
Estimation strategy: |
control_group |
For |
anticipation |
For |
conf.level |
Numeric vector of confidence levels (default |
vcov |
VCOV type passed to |
vcov_args |
List of additional arguments forwarded to |
bootstrap |
Logical; if |
B |
Integer number of bootstrap draws (default |
alpha |
Significance level for the simultaneous band (default |
boot_seed |
Integer seed for the bootstrap RNG; |
A data.frame of class "es_result" with columns:
term, estimate, std.error, statistic, p.value
conf_low_XX, conf_high_XX (for each requested conf.level)
relative_time (integer; 0 = event), is_baseline (logical; marks the reference period)
Attributes include: lead_range, lag_range, baseline, interval, call, model_formula, conf.level,
N, N_units, N_treated, N_nevertreated, fe, vcov_type, cluster_vars, staggered, sunab_used.
One-step event study: specify outcome, treatment, time, timing, fixed effects, and (optionally) covariates.
Switch between Classic (factor expansion) and Staggered-SAFE (method = "sunab").
Flexible clustering, weights, and VCOV choices (e.g., vcov = "HC1" | "HC3" | "CR2" | "iid" ...).
Automatic lead/lag window detection and customizable baseline period.
Returns an "es_result" object compatible with print() and autoplot().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.