if (FALSE) {
# Run event study
event_study <- run_es(
data = df,
outcome = y,
treatment = is_treated,
time = year,
timing = 2005,
lead_range = 5, # Corresponds to years 2000-2004 (relative time: -5 to -1)
lag_range = 4, # Corresponds to years 2006-2009 (relative time: 1 to 4)
fe = firm_id + year,
cluster = "state_id",
baseline = -1,
interval = 1
)
# Basic plot
plot_es(event_study)
# Use error bars instead of ribbon confidence intervals
plot_es(event_study, type = "errorbar")
# Adjust vertical reference line
plot_es(event_study, type = "errorbar", vline_val = -0.5)
# Customize axis breaks and title
library(ggplot2)
plot_es(event_study, type = "errorbar") +
ggplot2::scale_x_continuous(breaks = seq(-5, 4, by = 1)) +
ggplot2::ggtitle("Result of Event Study")
}
Run the code above in your browser using DataLab