Plot the ATT(g,t) matrix from a Callaway-Sant'Anna event study
Source:R/plot_att_gt.R
plot_att_gt.RdVisualises the full cohort-by-period ATT(g,t) matrix stored in the
att_gt attribute of an es_result object produced by
run_es(estimator = "cs"). Two display styles are available:
"heatmap": a tile plot with calendar time \(t\) on the x-axis and cohort \(g\) on the y-axis, colour-filled by the point estimate. Cells whose pointwise confidence interval excludes zero are marked with a filled dot; cells that are simultaneously significant (when bootstrap data are available) are additionally marked with an open diamond."facet": one panel per cohort showing ATT(g,t) over calendar time \(t\) with a pointwise confidence ribbon, mirroring the style ofplot_es(). A lighter simultaneous CI ribbon is overlaid when bootstrap data are available.
Both types draw a vertical dashed line at \(t = g\) (treatment onset) for each cohort.
Arguments
- x
An
es_resultobject returned byrun_es(estimator = "cs"), or anatt_gt_resultdata frame produced by extractingattr(x, "att_gt")and giving it class"att_gt_result".- type
"heatmap"(default) or"facet".- ci_level
Confidence level for pointwise intervals (default 0.95).
- zero_line
Logical; draw a horizontal reference line at zero in the
"facet"display (defaultTRUE).- theme
One of
"bw"(default),"minimal", or"classic".- color
Line and point colour used in the
"facet"display (default"#B25D91FF", matchingplot_es()).- fill
Ribbon fill colour in the
"facet"display (default"#B25D91FF").- alpha
Ribbon transparency in the
"facet"display (default0.2).- object
An
att_gt_resultobject (extracted from anes_resultviaattr(result, "att_gt")).- ...
Passed to
plot_att_gt.
Value
A ggplot2::ggplot() object.
Bootstrap annotation
When attr(x, "bootstrap") is present (i.e., run_es() was
called with bootstrap = TRUE), both plot types add simultaneous
inference overlays sourced from the (g,t)-level bootstrap object.
Examples
if (FALSE) { # \dontrun{
cs_result <- run_es(data = mydata, outcome = y, time = year,
timing = g, unit = id, fe = ~id + year,
staggered = TRUE, estimator = "cs")
plot_att_gt(cs_result)
plot_att_gt(cs_result, type = "facet")
} # }