Fourteen Difference-in-Difference Estimators Walk Into a Bar …

Introduction

Setup

set.seed(23)
sim6b <- params6b %>% make_data(N = 500, start = 2008, stop = 2022, rho_t=0.8) 
sim6b %>% plot_data()
df_sim6b <- sim6b %>% pluck("df") %>% prepare()
sim6b_truth <- sim6b$truth
sim6b_desc <- sim6b$params$desc
sim6b_est <- df_sim6b %>% estimate()
sim6b_res <- sim6b_est %>% discriminate(truth = sim6b$truth)
plan(multisession,workers=parallel::detectCores()-1)
res6b <-
  with_progress({
    gen_est_disc(1:100, params = params6b, start = 2008, stop = 2022, rho_t = 0.8, N = 500)

  })


p_df6b <-
  res6b %>%
  bind_rows() %>%
  group_by(rel_time) %>%
  summarise_all(mean) %>%
  gather(estimator,estimate,-rel_time) %>%
  filter(estimator!="truth")

ests <- p_df6b$estimator %>% unique()

p_df6b_ <-
  ests %>%
    map_df(~({
      res6b[[1]] %>%
        select(rel_time,truth) %>%
        gather(estimator,estimate,-rel_time) %>%
        mutate(estimator_p = estimator) %>%
        mutate(estimator=.x)
    }))



p_df6b %>% mutate(estimator = ests_lut[estimator]) %>%
  ggplot(aes(x = rel_time, y = estimate)) +
  geom_point() +
  geom_line() +
  geom_line(data = p_df6b_ %>% mutate(estimator = ests_lut[estimator]), colour = "red") +
  hrbrthemes::theme_ipsum() +
  #ggsci::scale_color_aaas()+
  #scale_y_continuous(limits = c(0,5.5)) +
  #scale_x_continuous(expand=c(0.25,0), breaks = seq(0,10,1)) +
  #geom_dl(method = list("last.bumpup"),aes(label = estimator))+
  #geom_dl(method = list("first.bumpup"),aes(label = estimator))+
  theme(legend.position="none") +
  facet_wrap(~estimator, scales = "free") +
  labs(x = "Relative Time\n(Note: Truth is Shown in Red", y = "Estimate") +
  ggtitle("Staggered Enty\nHeterogeneous Dynamic Treatment Effects")