stack_summary(
stack_data, outcome_var,
cluster_var = NULL, ref_period = -1L, covariates = NULL,
model = c("event_study", "att"),
fe = c("interacted", "saturated"),
unit_var = NULL, time_var = NULL,
weight_type = NULL, pop_var = NULL, weight_var = NULL,
conf_level = 0.95, digits = 4
)Timing-group summary
One row per timing group (sub-experiment) with masses, precision vs corrective weights, and cohort ATTs — plus the two aggregation identities that connect the cohort ATTs to the stacked TWFE estimates.
R stack_summary() ↔︎ Stata stacked summary
Usage
Arguments
| Argument | Description |
|---|---|
stack_data, outcome_var |
Stack from build_stack() and outcome name. |
cluster_var, ref_period, covariates |
As in stackreg(). |
model |
"event_study" (default; average post-period ATT per cohort) or "att". |
fe |
"interacted" (default here — the precision identity is exact only for the canonical TWFE) or "saturated". |
unit_var, time_var |
Read from stacked_meta when NULL; unit_var needed to count treated units. |
weight_type, pop_var, weight_var |
Override the mass basis; default read from stacked_meta. |
conf_level |
Confidence level for the delta-method intervals (default 0.95). |
digits |
Print digits (default 4). |
stacked summary depvar [, cluster(varname) ref(#) model(str) fe(str) ///
covariates(varlist) unitvar(varname) timevar(varname) ///
weighttype(str) popvar(varname) weightvar(varname) level(#)]Options
| Option | Description |
|---|---|
cluster(), ref(), covariates(), level() |
As in stacked reg. |
model(str) |
eventstudy (default) or att. |
fe(str) |
interacted (default here) or saturated. |
weighttype(), popvar(), weightvar() |
Override the mass basis; default read from what stacked build stamped. |
R ↔︎ Stata mapping
| R | Stata |
|---|---|
outcome_var |
depvar |
cluster_var |
cluster() |
ref_period |
ref() |
model / fe |
model() / fe() |
weight_type / pop_var / weight_var |
weighttype() / popvar() / weightvar() |
conf_level |
level() |
digits |
(none; Stata uses default formatting) |
Value / Stored results
R returns a stack_summary object (list) with table (per-cohort rows plus a Total row), D, d_gap, precision and corrective (each the weighted-sum aggregate and its matching TWFE coefficient), and weight_basis. The print method renders the table and the identities.
Stata returns r(summary) (matrix) and scalars r(D), r(d_gap), r(theta_precision), r(theta_corrective), r(twfe_precision), r(twfe_corrective), r(att), r(att_se).
Both print, per cohort: N obs, obs share, treated units, treated-obs share, the precision weight \(w_a^S\) (what an unweighted stacked TWFE implicitly places on the cohort), the corrective Q-weight \(w_a^T\) (the treated-mass share the design targets), their gap, and the cohort ATT/SE/p-value. Beneath: \(D = \sum_a |w_a^S - w_a^T|\), and the two identities — precision-weighted sum of ATTs = unweighted stacked TWFE; corrective-weighted sum = Q-weighted stacked TWFE (the target ATT). This combines what stacked kappa, screen and stacked reg, bygroup report separately.
Example
library(stacked)
data(medicaid)
stack <- build_stack(medicaid, "year", "state", "adopt_year",
kappa_pre = 3, kappa_post = 2)
stack_summary(stack, "uninsured", cluster_var = "state")Stacked DiD summary by timing group (event study, fe = interacted)
Outcome: uninsured | weight basis: unit counts
group N obs obs shr N trt trt shr precis wt correc wt wS - wT ATT SE
2014 276 0.4600 28 0.8000 0.6437 0.8000 -0.1563 -0.0216 0.0065
2015 126 0.2100 3 0.0857 0.1511 0.0857 0.0654 -0.0159 0.0052
2016 120 0.2000 2 0.0571 0.1058 0.0571 0.0486 -0.0421 0.0041
2019 78 0.1300 2 0.0571 0.0994 0.0571 0.0423 -0.0152 0.0039
Total 600 1.0000 35 1.0000 1.0000 1.0000 -0.0000 -0.0219 0.0054
p-val
0.0009
0.0022
0.0000
0.0001
0.0001
Design divergence (from adoption dates alone; N = unit counts mass):
S_a = (N_a^D * N_a^C) / (N_a^D + N_a^C) [precision mass of sub-experiment a]
precision weight w_a^S = S_a / sum_b S_b
corrective weight w_a^T = N_a^D / sum_b N_b^D
D = sum_a |w_a^S - w_a^T| = 0.3125
D-gap (largest single-cohort gap): cohort 2014, |w^S - w^T| = 0.1563
Precision-weighted aggregate (what the UNWEIGHTED stacked TWFE reports):
theta_S = sum_a w_a^S * ATT_a = -0.0222
unweighted stacked TWFE coefficient = -0.0222 [match]
Corrective-weighted aggregate (the target ATT):
theta_Q = sum_a w_a^T * ATT_a = -0.0219
Q-weighted stacked TWFE coefficient = -0.0219 [match]
stacked use medicaid, clear
stacked build, time(year) unit(state) adopt(adopt_year) kpre(3) kpost(2)
stacked summary uninsured, cluster(state)See also
stackreg()/stacked reg— the underlying estimationkappa_trade_offs()/stacked kappa— the outcome-free screen- Kappa trade-offs vignette