# from https://mixtape.scunning.com/09-difference_in_differences # Part 9.5.3 Abortion legalization and long-term gonorrhea incidence #-- DD estimate of 15-19 year olds in repeal states vs Roe states install.packages("estimatr") install.packages("robustbase") library(tidyverse) library(haven) library(estimatr) library(magrittr) library(dplyr) library(robustbase) read_data <- function(df) { full_path <- paste("https://github.com/scunning1975/mixtape/raw/master/", df, sep = "") df <- read_dta(full_path) return(df) } abortion <- read_data("abortion.dta") %>% mutate( repeal = as_factor(repeal), year = as_factor(year), fip = as_factor(fip), fa = as_factor(fa), ) filterdata <- abortion %>% filter(bf15 == 1) reg<- lm_robust(lnr ~ repeal*year + fip + acc + ir + pi + alcohol+ crack + poverty+ income+ ur, data = filterdata, weights = totpop, clusters = fip) abortion_plot <- tibble( sd = reg[[2]][76:90], mean = reg[[1]][76:90], year = c(1986:2000)) abortion_plot %>% ggplot(aes(x = year, y = mean)) + geom_rect(aes(xmin=1986, xmax=1992, ymin=-Inf, ymax=Inf), fill = "cyan", alpha = 0.01)+ geom_point()+ geom_text(aes(label = year), hjust=-0.002, vjust = -0.03)+ geom_hline(yintercept = 0) + geom_errorbar(aes(ymin = mean - sd*1.96, ymax = mean + sd*1.96), width = 0.2, position = position_dodge(0.05))