The functions to be used for the SDID and SC Estimates were created.
with.overlay <- function(est, s) { attr(est,'overlay') = s; est }
estimators <- function(sdid,sc,s) {
estimator.list = list(with.overlay(sdid, s), sc)
names(estimator.list)=c('SDID', 'SC')
estimator.list
}
plot.estimators <- function(ests, alpha.multiplier) {
p = synthdid_plot(ests, se.method='none',
alpha.multiplier=alpha.multiplier, facet=rep(1,length(ests)),
trajectory.linetype = 1, effect.curvature=-.4,
trajectory.alpha=.8, effect.alpha=.5, diagram.alpha=1)
suppressMessages(p + scale_alpha(range=c(0,1), guide='none'))
}
The data to be used was prepared and 7 counties in Louisiana were excluded from the analysis. Also Counties in Alabama, Florida and Mississippi were excluded
# Excluding 7 LA Counties.
# Excluding Alabama, Florida and Mississippi Counties.
# then Balancing data.
df <- read.csv("Average Weekly Wage (County).csv") %>%
filter(CountyName != "Jefferson Parish, Louisiana", CountyName != "Orleans Parish, Louisiana",
CountyName != "Plaquemines Parish, Louisiana", CountyName != "St. Bernard Parish, Louisiana",
CountyName != "St. Charles Parish, Louisiana", CountyName != "St. John the Baptist Parish, Louisiana",
CountyName != "St. Tammany Parish, Louisiana", CountyName != "Unknown Or Undefined, Louisiana",
State != "Alabama", State != "Florida", State != "Mississippi") %>%
mutate(Date = case_when(Qtr == 1 ~ paste0(Year, "-01-01"),
Qtr == 2 ~ paste0(Year, "-04-01"),
Qtr == 3 ~ paste0(Year, "-07-01"),
Qtr == 4 ~ paste0(Year, "-10-01"),
TRUE ~ "NA"),
Date = as.Date(Date),
treat = as.numeric(State == "Louisiana")) %>%
group_by(CountyName) %>%
filter(!any(is.na(Total.Covered.Total..all.industries)) & Total.Covered.Total..all.industries != 0) %>%
ungroup()
# Checking counties in LA
LA <- df %>%
filter(State == "Louisiana") %>%
distinct(CountyName)
nrow(LA)
## [1] 57
head(LA, 10)
## # A tibble: 10 × 1
## CountyName
## <chr>
## 1 Acadia Parish, Louisiana
## 2 Allen Parish, Louisiana
## 3 Ascension Parish, Louisiana
## 4 Assumption Parish, Louisiana
## 5 Avoyelles Parish, Louisiana
## 6 Beauregard Parish, Louisiana
## 7 Bienville Parish, Louisiana
## 8 Bossier Parish, Louisiana
## 9 Caddo Parish, Louisiana
## 10 Calcasieu Parish, Louisiana
dt <- seq.Date(from = as.Date("1998-01-01"),
to = as.Date("2019-10-01"), by = "quarter")
df.fix <- data.frame(CountyName = rep(unique(df$CountyName), length(dt))) %>%
arrange(CountyName) %>%
mutate(Date = rep(dt, length(unique(df$CountyName))))
bal_df <- left_join(df.fix, df, by = c("CountyName", "Date")) %>%
mutate(Date = as.Date(Date)) %>%
rename(Total.Covered = Total.Covered.Total..all.industries) %>%
select(CountyName, State, Date, Total.Covered) %>%
group_by(CountyName) %>%
filter(!any(is.na(Total.Covered))) %>%
ungroup() %>%
mutate(treat = ifelse(State == "Louisiana" & Date >= as.Date("2005-07-01"), 1, 0))
bal_df$CountyName <- factor(bal_df$CountyName)
bal_df <- as.data.frame(bal_df)
bal_df$lg <- log(bal_df$Total.Covered)
setup <- panel.matrices(bal_df,
unit = "CountyName", time = "Date", outcome = "lg", treatment = "treat")
sdid.df <- synthdid_estimate(setup$Y, setup$N0, setup$T0)
sc.df <- sc_estimate(setup$Y, setup$N0, setup$T0)
p4 <- plot.estimators(estimators(sdid = sdid.df, sc = sc.df, s = 1),
alpha.multiplier = c(1, 1, 1))
plot.theme <- theme(legend.position = "bottom",
legend.direction = 'horizontal',
legend.key = element_blank(),
legend.background = element_blank(),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
axis.text = element_text(size = 10),
axis.title = element_text(size = 12))
pl <- p4 + plot.theme +
labs(title = "Average Weekly Wage (SDID & SC Estimate)",
y = "Average Weekly Wage", x = "Date")
pl
unit.weights <- synthdid_controls(sdid.df, weight.type = 'omega', mass = 1)
unit.df <- data.frame(sdid = round(unit.weights[rev(1:nrow(unit.weights)), ], 3)) %>%
rownames_to_column(var = "CountyName")
map_df <- unit.df %>%
mutate(sdid_mp = ifelse(sdid > 0, 1, 0))
map_sdid <- map_df %>%
filter(sdid_mp == 1)
head(map_sdid)
## CountyName sdid sdid_mp
## 1 Hocking County, Ohio 0.001 1
## 2 Black Hawk County, Iowa 0.001 1
## 3 Big Stone County, Minnesota 0.001 1
## 4 Kalamazoo County, Michigan 0.001 1
## 5 Washington County, Kentucky 0.001 1
## 6 Geauga County, Ohio 0.001 1
cntydf <- df %>%
filter(State == "Louisiana" | CountyName %in% map_sdid$CountyName)
head(cntydf)
## # A tibble: 6 × 25
## Year Qtr time State CountyName Total.Covered.Total.…¹
## <int> <int> <chr> <chr> <chr> <int>
## 1 1998 1 1998-1 Alaska Haines Borough, Alaska 444
## 2 1998 1 1998-1 Alaska Northwest Arctic Borough… 766
## 3 1998 1 1998-1 Alaska Valdez-Cordova Census Ar… 806
## 4 1998 1 1998-1 Alaska Yukon-Koyukuk Census Are… 510
## 5 1998 1 1998-1 California Alpine County, California 252
## 6 1998 1 1998-1 California Glenn County, California 439
## # ℹ abbreviated name: ¹​Total.Covered.Total..all.industries
## # ℹ 19 more variables: Federal.Government.Total..all.industries <int>,
## # State.Government.Total..all.industries <int>,
## # Local.Government.Total..all.industries <int>,
## # Private.Total..all.industries <int>, Private.Goods.producing <int>,
## # Private.Natural.resources.and.mining <int>, Private.Construction <int>,
## # Private.Manufacturing <int>, Private.Service.providing <int>, …
## SUbset Data, because we want focus on before 2015
regdf <- cntydf %>%
filter(Date < as.Date("2015-01-01"))
## Makes Date Dummy
dloop <- data.frame(Date = unique(regdf$Date))
dloop <- dloop %>%
mutate(year = format(Date,"%Y"),
month=str_pad(string = format(Date ,"%m"),width = 2,side = "left",pad = 0))
head(dloop)
## Date year month
## 1 1998-01-01 1998 01
## 2 1998-04-01 1998 04
## 3 1998-07-01 1998 07
## 4 1998-10-01 1998 10
## 5 1999-01-01 1999 01
## 6 1999-04-01 1999 04
## YEAR DUMMY
for (i in 1:nrow(dloop)) {
regdf[paste0("d.", dloop$year[i],".",dloop$month[i])] <- as.numeric(regdf$Date == unique(regdf$Date)[i])
}
did.reg <- felm(log(Total.Covered.Total..all.industries) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.017732591 0.010934667 0.03916454 -0.003699357
## 2 2000-04-01 0.016709498 0.009425087 0.03518267 -0.001763672
## 3 2000-07-01 0.007857675 0.010260935 0.02796911 -0.012253758
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.05, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Total Weekly Wage") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Goods.producing)) &
Private.Goods.producing != 0)
did.reg <- felm(log(Private.Goods.producing) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.02515973 0.01641328 0.05732976 -0.007010288
## 2 2000-04-01 0.02141337 0.01375561 0.04837435 -0.005547624
## 3 2000-07-01 0.03173034 0.01544802 0.06200845 0.001452229
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl1 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.05, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Goods Producing") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl1
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Natural.resources.and.mining)) &
Private.Natural.resources.and.mining != 0)
did.reg <- felm(log(Private.Natural.resources.and.mining) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.0008721374 0.02801321 0.05577803 -0.05403376
## 2 2000-04-01 0.0056095820 0.02414192 0.05292775 -0.04170859
## 3 2000-07-01 0.0204368785 0.02485194 0.06914667 -0.02827292
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl2 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.1, 0.2, by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Natural Resources and Mining") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl2
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Construction)) &
Private.Construction != 0)
did.reg <- felm(log(Private.Construction) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.02489530 0.02552908 0.07493229 -0.02514169
## 2 2000-04-01 0.01761007 0.02565529 0.06789445 -0.03267430
## 3 2000-07-01 0.03653465 0.02543934 0.08639575 -0.01332645
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl3 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.1, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Construction") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl3
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Manufacturing)) &
Private.Manufacturing != 0)
did.reg <- felm(log(Private.Manufacturing) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.04117219 0.02379477 0.08780994 -0.005465568
## 2 2000-04-01 0.02151096 0.01753491 0.05587938 -0.012857457
## 3 2000-07-01 0.04240183 0.01816180 0.07799896 0.006804693
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl4 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.05, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Manufactruing") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl4
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Service.providing)) &
Private.Service.providing != 0)
did.reg <- felm(log(Private.Service.providing) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.026699493 0.01472751 0.05556541 -0.002166426
## 2 2000-04-01 0.014877028 0.01201100 0.03841859 -0.008664531
## 3 2000-07-01 0.008736158 0.01139256 0.03106557 -0.013593257
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl5 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.05, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Service Providing") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl5
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Trade..transportation..and.utilities)) &
Private.Trade..transportation..and.utilities != 0)
did.reg <- felm(log(Private.Trade..transportation..and.utilities) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.04377763 0.02100690 0.08495115 0.002604101
## 2 2000-04-01 0.01144370 0.01511089 0.04106105 -0.018173653
## 3 2000-07-01 0.01402636 0.01614209 0.04566485 -0.017612142
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl6 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.1, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Trade, Transportation and Utilities") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl6
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Financial.activities)) &
Private.Financial.activities != 0)
did.reg <- felm(log(Private.Financial.activities) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 -0.009462656 0.01658721 0.02304827 -0.04197358
## 2 2000-04-01 0.026318004 0.02065579 0.06680334 -0.01416734
## 3 2000-07-01 0.003368487 0.01572671 0.03419284 -0.02745586
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl7 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.1, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Financial Activities") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl7
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Professional.and.business.services)) &
Private.Professional.and.business.services != 0)
did.reg <- felm(log(Private.Professional.and.business.services) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 -0.007833416 0.03220268 0.05528383 -0.07095067
## 2 2000-04-01 -0.010545804 0.03651996 0.06103331 -0.08212492
## 3 2000-07-01 0.023118359 0.03311824 0.08803011 -0.04179339
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl8 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.1, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Professional and Business Services") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl8
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Education.and.health.services)) &
Private.Education.and.health.services != 0)
did.reg <- felm(log(Private.Education.and.health.services) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 -0.005265315 0.01493681 0.024010828 -0.03454146
## 2 2000-04-01 -0.031626687 0.01507002 -0.002089457 -0.06116392
## 3 2000-07-01 -0.027277514 0.01654377 0.005148266 -0.05970329
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl9 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.1, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Education and Health Services") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl9
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Private.Leisure.and.hospitality)) &
Private.Leisure.and.hospitality != 0)
did.reg <- felm(log(Private.Leisure.and.hospitality) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 0.005666079 0.02357798 0.05187891 -0.04054675
## 2 2000-04-01 0.011906290 0.02275539 0.05650686 -0.03269428
## 3 2000-07-01 -0.045474504 0.02035665 -0.00557548 -0.08537353
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl10 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.2, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Leisure and Hospitality") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl10
regdf1 <- regdf %>%
group_by(CountyName) %>%
filter(!any(is.na(Local.Government.Total..all.industries)) &
Local.Government.Total..all.industries != 0)
did.reg <- felm(log(Local.Government.Total..all.industries) ~
treat:(d.2000.01 + d.2000.04 + d.2000.07 + d.2000.10 +
d.2001.01 + d.2001.04 + d.2001.07 + d.2001.10 +
d.2002.01 + d.2002.04 + d.2002.07 + d.2002.10 +
d.2003.01 + d.2003.04 + d.2003.07 + d.2003.10 +
d.2004.01 + d.2004.04 + d.2004.07 + d.2004.10 +
d.2005.01 + d.2005.04 + d.2005.10 +
d.2006.01 + d.2006.04 + d.2006.07 + d.2006.10 +
d.2007.01 + d.2007.04 + d.2007.07 + d.2007.10 +
d.2008.01 + d.2008.04 + d.2008.07 + d.2008.10 +
d.2009.01 + d.2009.04 + d.2009.07 + d.2009.10 +
d.2010.01 + d.2010.04 + d.2010.07 + d.2010.10 +
d.2011.01 + d.2011.04 + d.2011.07 + d.2011.10 +
d.2012.01 + d.2012.04 + d.2012.07 + d.2012.10 +
d.2013.01 + d.2013.04 + d.2013.07 + d.2013.10 +
d.2014.01 + d.2014.04 + d.2014.07 + d.2014.10)
| CountyName + Date | 0 | CountyName, data = regdf1)
## Export Coeffiecent and test for Heteroscedasticity SE
coef_df <- coeftest(did.reg, vcov = vcov(did.reg, type = 'robust'))
coef_df <- coef_df[,] %>%
as_tibble() %>%
mutate(variables = rownames(coef_df))
coef_df$date <- as.Date(paste0(coef_df$variables, ".01"),
format = "treat:d.%Y.%m.%d")
event_df <- data.frame(date=seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by = "quarter"))
event_df <- left_join(event_df, coef_df[, c(1, 2, 6)])
## Joining with `by = join_by(date)`
event_df[is.na(event_df)] <- 0
colnames(event_df) <- c("time","coef","se")
## Makes Confident Interval
event_df$ci_upper <- event_df$coef + 1.96 * event_df$se
event_df$ci_lower <- event_df$coef - 1.96 * event_df$se
head(event_df,3)
## time coef se ci_upper ci_lower
## 1 2000-01-01 -0.018959813 0.01875068 0.01779152 -0.05571115
## 2 2000-04-01 -0.001791924 0.01985096 0.03711596 -0.04069981
## 3 2000-07-01 -0.024254259 0.02195940 0.01878617 -0.06729468
dates <- seq.Date(as.Date("2000-01-01"),as.Date("2014-12-01"),by='quarter')
# Define start and end dates for plot
start_date <- as.Date("2003-01-01")
end_date <- as.Date("2014-12-01")
# Create sequence of dates for x-axis
dates_seq <- seq.Date(from = start_date, to = end_date, by = "month")
# Subset event_df to only include dates after or equal to start_date
event_df_sub <- event_df[dates >= start_date, ]
pl11 <- ggplot(event_df, aes(x = dates, y = coef)) +
geom_point() +
geom_line()+
#geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), width = 0.2) +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = 0.2) +
geom_hline(yintercept = 0, linetype = "dashed", color = "red") +
geom_vline(xintercept = as.Date("2005-10-01"), linetype = "dashed", color = "blue") +
scale_x_date(date_labels = "%b %Y", limits = c(start_date, end_date), breaks = "1 year") +
scale_y_continuous(breaks = seq(-0.1, max(round(event_df$coef), 3), by = 0.025)) +
labs(title = "Average Weekly Wage (County)", y = "Local Government") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title = element_text(size = 14, face = "bold"),
axis.title.x = element_blank(),
axis.title.y = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 12),
legend.text = element_text(size = 12),
plot.caption = element_text(size = 12, face = c("italic", "bold")),
axis.line = element_line(color = "black", size = 0.5),
panel.background = element_blank(),
panel.grid.major = element_line(color = "black", size = 0.1),
panel.grid.minor = element_blank())
pl11
grid.arrange(pl + theme(plot.title = element_blank()) + xlab(""),
pl1 + theme(plot.title = element_blank()) + xlab(""),
pl2 + theme(plot.title = element_blank()) + xlab(""),
pl3 + theme(plot.title = element_blank()) + xlab(""),
pl4 + theme(plot.title = element_blank()) + xlab(""),
pl5 + theme(plot.title = element_blank()) + xlab(""),
pl6 + theme(plot.title = element_blank()) + xlab(""),
pl7 + theme(plot.title = element_blank()) + xlab(""),
pl8 + theme(plot.title = element_blank()) + xlab(""),
pl9 + theme(plot.title = element_blank()) + xlab(""),
pl10 + theme(plot.title = element_blank()) + xlab(""),
pl11 + theme(plot.title = element_blank()) + xlab(""), nrow = 4,
left = textGrob("Average Weekly Wage
", rot = 90,
gp = gpar(fontface = "bold", fontsize = 15)),
bottom = textGrob("Year", gp = gpar(fontface = "bold", fontsize = 15)))