Skip to contents

Base plot() method for es_result objects returned by event_study() (or the deprecated run_es()). Draws the event-study curve with pointwise confidence bands as a static ggplot, or — with interactive = TRUE — an interactive plotly chart with hover tooltips (requires the suggested {plotly} package).

Usage

# S3 method for class 'es_result'
plot(
  x,
  ci_level = 0.95,
  type = c("ribbon", "errorbar"),
  interactive = FALSE,
  show_simultaneous = FALSE,
  ...
)

Arguments

x

An es_result object.

ci_level

Confidence level to display (default 0.95).

type

"ribbon" (default) or "errorbar". Static plots only.

interactive

Logical; if TRUE, return an interactive plotly chart instead of a ggplot. Default FALSE.

show_simultaneous

Logical; overlay the simultaneous bootstrap CI band (requires bootstrap = TRUE in the originating event_study() call). Default FALSE.

...

Further styling arguments: for static plots vline_val, hline_val, vline_color, hline_color, linewidth, pointsize, alpha, barwidth, color, fill, theme_style ("bw", "minimal", or "classic"); for interactive plots markersize, show_ribbon, height, width, and the shared color arguments.

Value

A ggplot object, or a plotly object when interactive = TRUE.

Examples

if (FALSE) { # \dontrun{
res <- event_study(df, outcome = y, time = year, timing = g,
                   unit = id, estimator = "cs")
plot(res)
plot(res, type = "errorbar", ci_level = 0.9)
plot(res, interactive = TRUE)
} # }