library(readxl)
## Warning: package 'readxl' was built under R version 4.3.1
library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.3.1
## Warning: package 'purrr' was built under R version 4.3.1
## Warning: package 'dplyr' was built under R version 4.3.1
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
getwd()
## [1] "C:/Users/User/OneDrive/Research/CDC staggered DID"
setwd("C:/Users/User/OneDrive/Research/CDC staggered DID")
windowsFonts("Times" = windowsFont("Times New Roman"))

Callaway and Sant’Anna

Female Whites

cs_fe_whi_2 <- read_excel("./Results/CS_230916.xlsx",
                          sheet = "fe_whi_2") %>%
  select(time, coefficient, ci_low, ci_high) %>%
  mutate(period = ifelse(time <= -1, "Before treatment", "After treatment"))

cs_fe_whi_2_fig <- cs_fe_whi_2 %>%
  ggplot(aes(x = time, y = coefficient)) +
  geom_point(aes(color = period, shape = period), size = 1) +
  geom_line(aes(color = period, linetype = period)) +
  geom_ribbon(aes(ymin=ci_low, ymax=ci_high, fill = period, alpha = period)) +
  scale_color_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkred", "After treatment" = "darkred")) +
  scale_fill_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkred", "After treatment" = "darkred")) +
  scale_shape_manual(name = "Periods to Treatment", values = c("Before treatment" = 19, "After treatment" = 17)) +
  scale_linetype_manual(name = "Periods to Treatment", values = c("Before treatment" = 2, "After treatment" = 1)) +
  scale_alpha_manual(name = "Periods to Treatment", values = c("Before treatment" = 0.2, "After treatment" = 0.5)) +
  labs(
    x = "", 
    y = "Coefficient",
    title = "Female Whites"
    
  ) +
  geom_vline(aes(xintercept=-1), linetype=2, color="gray60") +
  geom_hline(aes(yintercept=0), linetype=1, color="black") +
  theme_classic() +
  theme(
    legend.position = "none",
    plot.title = element_text(family = "Times", size = (16)),
    legend.title = element_text(family = "Times", size = (16)),
    legend.text = element_text(family = "Times", size = (13)),
    axis.title = element_text(family = "Times", size = (13)),
    axis.text = element_text(family = "Times", size = (12)),
    axis.title.x = element_text(family = "Times", face = "bold"),
    axis.title.y = element_text(family = "Times", face = "bold"),
    )

cs_fe_whi_2_fig

Female Blacks

cs_fe_blk_2 <- read_excel("./Results/CS_230916.xlsx",
                          sheet = "fe_blk_2") %>%
  select(time, coefficient, ci_low, ci_high) %>%
  mutate(period = ifelse(time <= -1, "Before treatment", "After treatment"))

cs_fe_blk_2_fig <- cs_fe_blk_2 %>%
  ggplot(aes(x = time, y = coefficient)) +
  geom_point(aes(color = period, shape = period), size = 1) +
  geom_line(aes(color = period, linetype = period)) +
  geom_ribbon(aes(ymin=ci_low, ymax=ci_high, fill = period, alpha = period)) +
  scale_color_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgoldenrod", "After treatment" = "darkgoldenrod")) +
  scale_fill_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgoldenrod", "After treatment" = "darkgoldenrod")) +
  scale_shape_manual(name = "Periods to Treatment", values = c("Before treatment" = 19, "After treatment" = 17)) +
  scale_linetype_manual(name = "Periods to Treatment", values = c("Before treatment" = 2, "After treatment" = 1)) +
  scale_alpha_manual(name = "Periods to Treatment", values = c("Before treatment" = 0.2, "After treatment" = 0.5)) +
  labs(
    x = "Periods to Treatment", 
    y = "",
    title = "Female Blacks"
  ) +
  geom_vline(aes(xintercept=-1), linetype=2, color="gray60") +
  geom_hline(aes(yintercept=0), linetype=1, color="black") +
  theme_classic() +
  theme(
    legend.position = "none",
    plot.title = element_text(family = "Times", size = (16)),
    legend.title = element_text(family = "Times", size = (16)),
    legend.text = element_text(family = "Times", size = (13)),
    axis.title = element_text(family = "Times", size = (13)),
    axis.text = element_text(family = "Times", size = (12)),
    axis.title.x = element_text(family = "Times", face = "bold"),
    axis.title.y = element_text(family = "Times", face = "bold"),
    )
cs_fe_blk_2_fig

Female Hispanic

cs_fe_his_2 <- read_excel("./Results/CS_230916.xlsx",
                          sheet = "fe_his_2") %>%
  select(time, coefficient, ci_low, ci_high) %>%
  mutate(period = ifelse(time <= -1, "Before treatment", "After treatment"))

cs_fe_his_2_fig <- cs_fe_his_2 %>%
  ggplot(aes(x = time, y = coefficient)) +
  geom_point(aes(color = period, shape = period), size = 1) +
  geom_line(aes(color = period, linetype = period)) +
  geom_ribbon(aes(ymin=ci_low, ymax=ci_high, fill = period, alpha = period)) +
  scale_color_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgreen", "After treatment" = "darkgreen")) +
  scale_fill_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgreen", "After treatment" = "darkgreen")) +
  scale_shape_manual(name = "Periods to Treatment", values = c("Before treatment" = 19, "After treatment" = 17)) +
  scale_linetype_manual(name = "Periods to Treatment", values = c("Before treatment" = 2, "After treatment" = 1)) +
  scale_alpha_manual(name = "Periods to Treatment", values = c("Before treatment" = 0.2, "After treatment" = 0.5)) +
  labs(
    x = "", 
    y = "",
    title = "Female Hispanics"
  ) +
  geom_vline(aes(xintercept=-1), linetype=2, color="gray60") +
  geom_hline(aes(yintercept=0), linetype=1, color="black") +
  theme_classic() +
  theme(
    legend.position = "none",
    plot.title = element_text(family = "Times", size = (16)),
    legend.title = element_text(family = "Times", size = (16)),
    legend.text = element_text(family = "Times", size = (13)),
    axis.title = element_text(family = "Times", size = (13)),
    axis.text = element_text(family = "Times", size = (12)),
    axis.title.x = element_text(family = "Times", face = "bold"),
    axis.title.y = element_text(family = "Times", face = "bold"),
    )
cs_fe_his_2_fig

Male Whites

cs_ma_whi_2 <- read_excel("./Results/CS_230916.xlsx",
                          sheet = "ma_whi_2") %>%
  select(time, coefficient, ci_low, ci_high) %>%
  mutate(period = ifelse(time <= -1, "Before treatment", "After treatment"))

cs_ma_whi_2_fig <- cs_ma_whi_2 %>%
  ggplot(aes(x = time, y = coefficient)) +
  geom_point(aes(color = period, shape = period), size = 1) +
  geom_line(aes(color = period, linetype = period)) +
  geom_ribbon(aes(ymin=ci_low, ymax=ci_high, fill = period, alpha = period)) +
  scale_color_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkred", "After treatment" = "darkred")) +
  scale_fill_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkred", "After treatment" = "darkred")) +
  scale_shape_manual(name = "Periods to Treatment", values = c("Before treatment" = 19, "After treatment" = 17)) +
  scale_linetype_manual(name = "Periods to Treatment", values = c("Before treatment" = 2, "After treatment" = 1)) +
  scale_alpha_manual(name = "Periods to Treatment", values = c("Before treatment" = 0.2, "After treatment" = 0.5)) +
  labs(
    x = "", 
    y = "Coefficient",
    title = "Male Whites"
  ) +
  geom_vline(aes(xintercept=-1), linetype=2, color="gray60") +
  geom_hline(aes(yintercept=0), linetype=1, color="black") +
  theme_classic() +
  theme(
    legend.position = "none",
    plot.title = element_text(family = "Times", size = (16)),
    legend.title = element_text(family = "Times", size = (16)),
    legend.text = element_text(family = "Times", size = (13)),
    axis.title = element_text(family = "Times", size = (13)),
    axis.text = element_text(family = "Times", size = (12)),
    axis.title.x = element_text(family = "Times", face = "bold"),
    axis.title.y = element_text(family = "Times", face = "bold"),
    )

cs_ma_whi_2_fig

Male Blacks

cs_ma_blk_2 <- read_excel("./Results/CS_230916.xlsx",
                          sheet = "ma_blk_2") %>%
  select(time, coefficient, ci_low, ci_high) %>%
  mutate(period = ifelse(time <= -1, "Before treatment", "After treatment"))

cs_ma_blk_2_fig <- cs_ma_blk_2 %>%
  ggplot(aes(x = time, y = coefficient)) +
  geom_point(aes(color = period, shape = period), size = 1) +
  geom_line(aes(color = period, linetype = period)) +
  geom_ribbon(aes(ymin=ci_low, ymax=ci_high, fill = period, alpha = period)) +
  scale_color_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgoldenrod", "After treatment" = "darkgoldenrod")) +
  scale_fill_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgoldenrod", "After treatment" = "darkgoldenrod")) +
  scale_shape_manual(name = "Periods to Treatment", values = c("Before treatment" = 19, "After treatment" = 17)) +
  scale_linetype_manual(name = "Periods to Treatment", values = c("Before treatment" = 2, "After treatment" = 1)) +
  scale_alpha_manual(name = "Periods to Treatment", values = c("Before treatment" = 0.2, "After treatment" = 0.5)) +
  labs(
    x = "Periods to Treatment", 
    y = "",
    title = "Male Blacks"
  ) +
  geom_vline(aes(xintercept=-1), linetype=2, color="gray60") +
  geom_hline(aes(yintercept=0), linetype=1, color="black") +
  theme_classic() +
  theme(
    legend.position = "none",
    plot.title = element_text(family = "Times", size = (16)),
    legend.title = element_text(family = "Times", size = (16)),
    legend.text = element_text(family = "Times", size = (13)),
    axis.title = element_text(family = "Times", size = (13)),
    axis.text = element_text(family = "Times", size = (12)),
    axis.title.x = element_text(family = "Times", face = "bold"),
    axis.title.y = element_text(family = "Times", face = "bold"),
    )
cs_ma_blk_2_fig

Male Hispanic

cs_ma_his_2 <- read_excel("./Results/CS_230916.xlsx",
                          sheet = "ma_his_2") %>%
  select(time, coefficient, ci_low, ci_high) %>%
  mutate(period = ifelse(time <= -1, "Before treatment", "After treatment"))

cs_ma_his_2_fig <- cs_ma_his_2 %>%
  ggplot(aes(x = time, y = coefficient)) +
  geom_point(aes(color = period, shape = period), size = 1) +
  geom_line(aes(color = period, linetype = period)) +
  geom_ribbon(aes(ymin=ci_low, ymax=ci_high, fill = period, alpha = period)) +
  scale_color_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgreen", "After treatment" = "darkgreen")) +
  scale_fill_manual(name = "Periods to Treatment", values = c("Before treatment" = "darkgreen", "After treatment" = "darkgreen")) +
  scale_shape_manual(name = "Periods to Treatment", values = c("Before treatment" = 19, "After treatment" = 17)) +
  scale_linetype_manual(name = "Periods to Treatment", values = c("Before treatment" = 2, "After treatment" = 1)) +
  scale_alpha_manual(name = "Periods to Treatment", values = c("Before treatment" = 0.2, "After treatment" = 0.5)) +
  labs(
    x = "", 
    y = "",
    title = "Male Hispanics"
  ) +
  geom_vline(aes(xintercept=-1), linetype=2, color="gray60") +
  geom_hline(aes(yintercept=0), linetype=1, color="black") +
  theme_classic() +
  theme(
    legend.position = "none",
    plot.title = element_text(family = "Times", size = (16)),
    legend.title = element_text(family = "Times", size = (16)),
    legend.text = element_text(family = "Times", size = (13)),
    axis.title = element_text(family = "Times", size = (13)),
    axis.text = element_text(family = "Times", size = (12)),
    axis.title.x = element_text(family = "Times", face = "bold"),
    axis.title.y = element_text(family = "Times", face = "bold"),
    )
cs_ma_his_2_fig

library(gridExtra)
## Warning: package 'gridExtra' was built under R version 4.3.1
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
grid.arrange(cs_fe_whi_2_fig, cs_fe_blk_2_fig, cs_fe_his_2_fig, 
             cs_ma_whi_2_fig, cs_ma_blk_2_fig, cs_ma_his_2_fig,
             ncol = 3, heights = c(1, 1))