Estimates average treatment effects on the treated (ATT) using either the
Callaway-Sant'Anna (2021) or Borusyak-Jaravel-Spiess (2024) estimator,
aggregated to a single summary effect ("simple"), per-cohort effects
("by_cohort"), or per calendar-time effects ("by_time").
Arguments
- data
A data.frame containing panel data.
- outcome
Unquoted outcome variable (name or expression, e.g.,
log(y)).- time
Unquoted calendar time variable (numeric).
- timing
Unquoted column giving each unit's first treatment period (
NA= never treated).- unit
Unquoted unit identifier (required).
- estimator
Estimation strategy:
"cs"(Callaway-Sant'Anna 2021, default) or"bjs"(Borusyak-Jaravel-Spiess 2024).- aggregation
Aggregation type:
"simple"(overall ATT, default),"by_cohort"(one ATT per treatment cohort), or"by_time"(one ATT per calendar time period).- control_group
For
estimator = "cs": comparison group,"nevertreated"(default) or"notyettreated".- anticipation
For
estimator = "cs": number of anticipation periods before treatment (non-negative integer, default0L).- conf_level
Numeric confidence level(s) (default
0.95). Multiple levels are supported, e.g.,c(0.90, 0.95).- interval
Numeric time spacing (default
1; informational only).- time_transform
Logical; if
TRUE, creates consecutive integer time within unit viadplyr::dense_rank(). Requiresunit.
Value
A data.frame of class "att_result" with columns:
groupCohort or calendar time (
NAfor"simple").estimateATT point estimate.
std.errorStandard error.
statistict-statistic (
estimate / std.error).p.valueTwo-sided p-value (normal approximation).
conf_low_XX,conf_high_XXCI bounds for each
conf.level.
Attributes: aggregation, estimator, conf.level, N, N_units,
N_treated, N_nevertreated, control_group (CS only), att_gt (CS
raw ATT(g,t) table), tau_it (BJS unit-time effects table).
Details
This function complements event_study(): use event_study() when you
want a full event-study curve (dynamic effects by relative time), and
att() when you want aggregated ATT estimates that collapse the time
dimension.
The result has broom::tidy() and broom::glance() methods, so it can be
passed to modelsummary::modelsummary() (rendered with tinytable) to build
a publication table — including stacking several estimators (e.g. did()
TWFE, CS, and BJS) side by side in one table.
att() supersedes calc_att() as of fixes 1.0.0.
Aggregation formulas (CS estimator)
simple: \(\theta = \sum_g (n_g/n_{treated}) \cdot \overline{ATT(g,\cdot)}\) where \(\overline{ATT(g,\cdot)}\) is the mean over post-treatment periods.
by_cohort: \(\theta(g) = \overline{ATT(g,\cdot)}\) per cohort.
by_time: \(\theta(t) = \sum_{g \le t} w(g,t) \cdot ATT(g,t)\) with \(w(g,t) = n_g / \sum_{g' \le t} n_{g'}\).
Standard errors (BJS estimator)
BJS SEs are approximate (naive sample variance of unit-time effects). Cluster-robust SEs for BJS aggregations are planned for a future release.
See also
event_study() for event-study (dynamic) estimates, and
calc_att() for the deprecated verb-style predecessor.