Skip to contents

Draws the period-by-period treatment effect estimates and bootstrap confidence intervals returned by sdid_event_study(), together with a horizontal zero reference line and a vertical treatment-time reference line. When the numeric time index has gaps (e.g. missing survey years such as 2011–2012 between 2010 and 2013), axis tick marks default to the observed periods (x$times) so unobserved years are never labeled on the axis, and vline_offset interpolates across the adjacent observed periods (-0.5 places the vertical line midway between the last pre-treatment period and the first post-treatment period; the default -1 places it on the last pre-treatment period).

Usage

# S3 method for class 'sdid_event_study'
plot(
  x,
  ci_type = NULL,
  colors = NULL,
  connect = FALSE,
  vline = list(),
  vline_offset = .VLINE_OFFSET_DEFAULT,
  hline = list(),
  ...
)

Arguments

x

An sdid_event_study object from sdid_event_study().

ci_type

Which confidence interval to draw: "normal" or "percentile". Defaults to x$ci_type.

colors

Optional single color string for the point estimates and error bars (default "#1a9641").

connect

Logical; connect adjacent period estimates with a line (default FALSE, standard point-and-interval event-study style).

vline

Aesthetic overrides for the vertical treatment-time line, as a list passed to ggplot2::geom_vline() (e.g. list(color = "red")), or NULL/FALSE to hide the line. May include xintercept to pin an explicit axis position.

vline_offset

Where to draw the vertical treatment line, in periods relative to the first post-treatment period (default -1, the last pre-treatment period; -0.5 lands midway between the last pre-treatment and first post-treatment period, even when intermediate years are absent). Cannot be combined with vline = list(xintercept = ...).

hline

Aesthetic overrides for the horizontal zero line, as a list passed to ggplot2::geom_hline(), or NULL/FALSE to hide the line.

...

Ignored.

Value

A ggplot2 plot object.