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=.5, 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.
# Excluding all LA MSAs except New Orleans
# 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") %>%
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()
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=c(.2, .25),
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
mc_estimate = function(Y, N0, T0) {
N1=nrow(Y)-N0
T1=ncol(Y)-T0
W <- outer(c(rep(0,N0),rep(1,N1)),c(rep(0,T0),rep(1,T1)))
mc_pred <- mcnnm_cv(Y, 1-W, num_lam_L = 20)
mc_fit <- mc_pred$L + outer(mc_pred$u, mc_pred$v, '+')
mc_est <- sum(W*(Y-mc_fit))/sum(W)
mc_est
}
mc_placebo_se = function(Y, N0, T0, replications=200) {
N1 = nrow(Y) - N0
theta = function(ind) { mc_estimate(Y[ind,], length(ind)-N1, T0) }
sqrt((replications-1)/replications) * sd(replicate(replications, theta(sample(1:N0))))
}
difp_estimate = function(Y, N0, T0) {
synthdid_estimate(Y, N0, T0, weights=list(lambda=rep(1/T0, T0)), eta.omega=1e-6)
}
sc_estimate_reg = function(Y, N0, T0) {
sc_estimate(Y, N0, T0, eta.omega=((nrow(Y)-N0)*(ncol(Y)-T0))^(1/4))
}
difp_estimate_reg = function(Y, N0, T0) {
synthdid_estimate(Y, N0, T0, weights=list(lambda=rep(1/T0, T0)))
}
estimators <- list(did = did_estimate,
sc = sc_estimate,
sdid = synthdid_estimate,
difp = difp_estimate,
mc = mc_estimate,
sc_reg = sc_estimate_reg,
difp_reg = difp_estimate_reg)
## Calculating the Unit Weights for each county
estimates <- lapply(estimators, function(estimator) {
estimator(setup$Y, setup$N0, setup$T0)
})
unit.weights <- synthdid_controls(estimates[1:3], weight.type = 'omega', mass = 1)
unit.df <- as.data.frame(round(unit.weights[rev(1:nrow(unit.weights)), ], 3)) %>%
rownames_to_column(var = "CountyName")
head(unit.df, 10)
## CountyName did sc sdid
## 1 Abbeville County, South Carolina 0 0 0.001
## 2 Accomack County, Virginia 0 0 0.000
## 3 Ada County, Idaho 0 0 0.000
## 4 Adair County, Iowa 0 0 0.000
## 5 Adair County, Kentucky 0 0 0.000
## 6 Adair County, Missouri 0 0 0.000
## 7 Adair County, Oklahoma 0 0 0.000
## 8 Adams County, Colorado 0 0 0.000
## 9 Adams County, Idaho 0 0 0.000
## 10 Adams County, Illinois 0 0 0.000
map_df <- unit.df %>%
mutate(sc_mp = ifelse(sc > 0, 1, 0),
sdid_mp = ifelse(sdid > 0, 1, 0))
map_sdid <- map_df %>%
filter(sdid_mp == 1)
head(map_sdid)
## CountyName did sc sdid sc_mp sdid_mp
## 1 Abbeville County, South Carolina 0 0 0.001 0 1
## 2 Adams County, Mississippi 0 0 0.001 0 1
## 3 Adams County, North Dakota 0 0 0.001 0 1
## 4 Antelope County, Nebraska 0 0 0.001 0 1
## 5 Archer County, Texas 0 0 0.001 0 1
## 6 Archuleta County, Colorado 0 0 0.001 0 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 Alabama Bibb County, Alabama 386
## 2 1998 1 1998-1 Alabama Choctaw County, Alabama 712
## 3 1998 1 1998-1 Alabama Conecuh County, Alabama 445
## 4 1998 1 1998-1 Alaska Northwest Arctic Borough, A… 766
## 5 1998 1 1998-1 Alaska Valdez-Cordova Census Area,… 806
## 6 1998 1 1998-1 Alaska Yukon-Koyukuk Census Area, … 510
## # ℹ 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.02060526 0.011259277 0.04267344 -0.001462927
## 2 2000-04-01 0.02190535 0.009998939 0.04150327 0.002307432
## 3 2000-07-01 0.01476917 0.010823745 0.03598371 -0.006445369
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.03012003 0.01711529 0.06366599 -0.003425926
## 2 2000-04-01 0.02626794 0.01458433 0.05485323 -0.002317347
## 3 2000-07-01 0.04136742 0.01652060 0.07374780 0.008987049
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.01195786 0.02912638 0.06904556 -0.04512985
## 2 2000-04-01 0.01139154 0.02571860 0.06179999 -0.03901692
## 3 2000-07-01 0.02753160 0.02635034 0.07917825 -0.02411506
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.02362403 0.02657751 0.07571595 -0.02846789
## 2 2000-04-01 0.01575925 0.02653544 0.06776871 -0.03625020
## 3 2000-07-01 0.03613649 0.02637120 0.08782404 -0.01555106
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.04548679 0.02456704 0.09363818 -0.002664614
## 2 2000-04-01 0.02450319 0.01840270 0.06057248 -0.011566093
## 3 2000-07-01 0.04912702 0.01900214 0.08637122 0.011882821
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.03358019 0.01504716 0.06307263 0.004087755
## 2 2000-04-01 0.02345352 0.01263454 0.04821721 -0.001310175
## 3 2000-07-01 0.01504569 0.01194263 0.03845324 -0.008361858
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.04999927 0.02105944 0.09127577 0.008722762
## 2 2000-04-01 0.01697024 0.01555011 0.04744845 -0.013507963
## 3 2000-07-01 0.01867935 0.01642867 0.05087955 -0.013520841
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.008864392 0.01726640 0.02497776 -0.042706545
## 2 2000-04-01 0.031659142 0.02098380 0.07278740 -0.009469115
## 3 2000-07-01 0.005688229 0.01637061 0.03777462 -0.026398167
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.010642352 0.03443135 0.05684309 -0.07812779
## 2 2000-04-01 -0.007211703 0.03775034 0.06677897 -0.08120237
## 3 2000-07-01 0.028172359 0.03444329 0.09568120 -0.03933648
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.003607818 0.01570301 0.027170087 -0.03438572
## 2 2000-04-01 -0.022492078 0.01587042 0.008613939 -0.05359810
## 3 2000-07-01 -0.026453502 0.01724584 0.007348352 -0.06025536
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.003732533 0.02395177 0.050678001 -0.04321294
## 2 2000-04-01 0.011714613 0.02320560 0.057197596 -0.03376837
## 3 2000-07-01 -0.041238179 0.02098405 -0.000109433 -0.08236692
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.018791301 0.01902594 0.01849954 -0.05608214
## 2 2000-04-01 0.004996636 0.02075366 0.04567381 -0.03568053
## 3 2000-07-01 -0.024853628 0.02230791 0.01886988 -0.06857714
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)))