Skip to contents

Creates a scatter plot of the Goodman-Bacon (2021) decomposition, showing how each 2x2 DID comparison contributes to the overall TWFE estimate. Points are sized by weight and colored by comparison type.

Usage

bacon_decomp_plot(
  decomp,
  weighted_avg = NULL,
  title = "Goodman-Bacon Decomposition"
)

Arguments

decomp

A data frame from bacondecomp::bacon(), with columns estimate, weight, and type.

weighted_avg

Numeric. The overall TWFE estimate (weighted average). If NULL (default), computed from the decomposition.

title

Character string. Plot title. Default is "Goodman-Bacon Decomposition".

Value

A ggplot2 object.

References

Goodman-Bacon, A. (2021). "Difference-in-Differences with Variation in Treatment Timing." Journal of Econometrics, 225(2), 254-277.

Examples

if (FALSE) { # \dontrun{
library(bacondecomp)
df <- bacon(y ~ treatment, data = your_data, id_var = "id", time_var = "time")
bacon_decomp_plot(df)
} # }