Skip to contents

Visualises 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 of plot_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.

Usage

# S3 method for class 'att_gt_result'
plot(
  x,
  type = c("heatmap", "facet"),
  ci_level = 0.95,
  zero_line = TRUE,
  theme = c("bw", "minimal", "classic"),
  color = NULL,
  fill = NULL,
  alpha = NULL,
  ...
)

# S3 method for class 'att_gt_result'
autoplot(object, ...)

Arguments

x

An es_result object returned by run_es(estimator = "cs"), or an att_gt_result data frame produced by extracting attr(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 (default TRUE).

theme

One of "bw" (default), "minimal", or "classic".

color

Line and point colour used in the "facet" display (defaults to the package's steel blue, matching plot.es_result()).

fill

Ribbon fill colour in the "facet" display (defaults to the package's lighter ribbon tint).

alpha

Ribbon transparency in the "facet" display (default 0.35).

...

Passed on to the plotting engine.

object

An att_gt_result object; see 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.

See also

Examples

if (FALSE) { # \dontrun{
cs_result <- event_study(y ~ 1 | id + year, data = mydata, time = year,
                         timing = g, estimator = "cs")
plot(att_gt(cs_result))
plot(att_gt(cs_result), type = "facet")
} # }