stack_coefs(model, conf_level = 0.95)Event-study coefficients
Extract the event-study coefficients, standard errors, and confidence intervals from a fitted stacked regression — for custom plotting or combining models.
R stack_coefs() ↔︎ Stata stored results (r(att), r(table), e()) after stacked reg
Usage
Arguments
| Argument | Description |
|---|---|
model |
A model from stackreg() (or a fixest model on stacked data). |
conf_level |
Confidence level for the intervals (default 0.95). |
stacked reg depvar, cluster(varname)
* the fitted coefficients live in e(b) / e(V); the parameter table in r(table)
matrix list e(b)
matrix list r(table)
* scalar ATT summaries
display r(att) // average post-period ATT
display r(att_se) // its delta-method SEThere is no separate extractor subcommand in Stata: after stacked reg the per-event-time coefficients are the interaction terms in e(b)/e(V) (with the standard r(table) layout), and the pooled summary is in the r() scalars.
R ↔︎ Stata mapping
| R | Stata |
|---|---|
stack_coefs(model) |
e(b) / e(V) / r(table) after stacked reg |
average post-period ATT (attr(model, "avg_post_att")) |
r(att), r(att_se), r(att_lb), r(att_ub), r(n_post) |
per-cohort coefficients (stack_coefs() on a stackreg_groups object) |
r(group_att) after stacked reg, bygroup |
conf_level |
level() on stacked reg |
Value / Stored results
R returns a data.table with event_time, estimate, se, ci_lower, ci_upper. The reference period is included with estimate = 0, se = NA, and a ref_period attribute records which event time is the reference.
Stata: e(b)/e(V) hold the coefficient vector and variance; r(table) is the parameter table; r(att*)/r(n_post)/r(ref) hold the pooled ATT summary. After bygroup, r(group_att) has one row per cohort.
Example
library(stacked)
data(medicaid)
stack <- build_stack(medicaid, "year", "state", "adopt_year",
kappa_pre = 3, kappa_post = 2)
model <- stackreg(stack, "uninsured", cluster_var = "state")
stack_coefs(model) event_time estimate se ci_lower ci_upper
1: -3 -0.001022172 0.003682642 -0.008240017 0.006195674
2: -2 -0.003034560 0.002993349 -0.008901416 0.002832296
3: -1 0.000000000 NA NA NA
4: 0 -0.016269503 0.003933884 -0.023979774 -0.008559231
5: 1 -0.023863697 0.006453761 -0.036512836 -0.011214558
6: 2 -0.025500057 0.007066243 -0.039349639 -0.011650476
stacked use medicaid, clear
stacked build, time(year) unit(state) adopt(adopt_year) kpre(3) kpost(2)
stacked reg uninsured, cluster(state)
matrix list r(table)
display "ATT = " r(att) " (se " r(att_se) ")"See also
stackreg()/stacked reg— fit the modelstack_plot()/stacked plot— plot the coefficients directlystack_summary()/stacked summary— cohort decomposition