#
# Minimal examples
### OLS
estimates_ols <- EventStudy(
estimator = "OLS",
data = example_data,
outcomevar = "y_smooth_m",
policyvar = "z",
idvar = "id",
timevar = "t",
controls = "x_r",
FE = TRUE, TFE = TRUE,
post = 3, overidpost = 5,
pre = 2, overidpre = 4,
normalize = - 3
)
plt_ols <- EventStudyPlot(estimates = estimates_ols)
plt_ols
### IV
estimates_fhs <- EventStudy(
estimator = "FHS",
data = example_data,
outcomevar = "y_smooth_m",
policyvar = "z",
idvar = "id",
timevar = "t",
proxy = "x_r",
post = 2, overidpost = 1,
pre = 0, overidpre = 3,
normalize = -1
)
plt_fhs <- EventStudyPlot(estimates = estimates_fhs)
plt_fhs
# Optional arguments
### Change x- and y-axis titles and set ybreaks
EventStudyPlot(estimates = estimates_ols,
xtitle = "Relative time", ytitle = "",
ybreaks = seq(-2, 1, 0.5))
### Add smoothest path
EventStudyPlot(estimates = estimates_ols, smpath = TRUE)
### Add y-mean to y-axis and line y = 0
EventStudyPlot(estimates = estimates_ols, add_mean = TRUE,
add_zero_line = TRUE)
### Do not plot supt bands
EventStudyPlot(estimates = estimates_ols, supt = NULL)
### Setting seed prior to plotting sup-t bands
set.seed(1234)
EventStudyPlot(estimates = estimates_ols)
# Modify plots using ggplot2 functions
library(ggplot2)
### Change color of dots, horizontal line, and theme
plt_ols +
geom_point(color = "red") +
geom_hline(color = "gray", yintercept = 0) +
theme_light() +
theme(panel.grid.minor.x = element_blank())
Run the code above in your browser using DataLab