File size: 1,410 Bytes
0369477 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File name: figure4.R
# In:
# - replication_data.RData
# Out:
# - /Figures/figure4.pdf
require(lme4)
require(lfe)
require(MatchIt)
require(WeightIt)
require(tjbal)
require(optmatch)
require(stargazer)
require(cobalt)
require(tidyverse)
require(ggridges)
rm(list = ls())
gc()
####################################################################################################################### Loading data
load('../Data/replication_data.RData')
####################################################################################################################### Loading functions
source('./helper_functions.R')
# Figure 4
finalDat$post <- ifelse(finalDat$date > as.Date('2020-03-10'),1,0)
finalDat$treat <- ifelse(finalDat$DMA_March17Cases > 1,1,0)
summary(tmp <- lmer(as.formula(paste0("pcttw_sanders ~ treat*post + (1|DMA_CODE)")),finalDat))$coefficients
toplot <- data.frame(interaction_plot_continuous(tmp,num_points = 2,pointsplot = T))
pdf('../Figures/figure4.pdf',width = 7,height = 5)
toplot %>%
mutate(x = factor(ifelse(x_2 == 0,'Pre','Post'),levels = c('Pre','Post'))) %>%
ggplot(aes(x = x,y = delta_1))+
geom_point() +
geom_errorbar(aes(ymin = lb,ymax = ub),width= .1) +
geom_hline(yintercept = 0,linetype = 'dashed') +
xlab("Period") + ylab("Marginal Effect of Exposure") +
theme_ridges()
dev.off() |