Plot Function Format

with.overlay = function(est, s) { attr(est,'overlay') = s; est }

estimators = function(sdid,sc,s) {
  estimator.list = list(with.overlay(sdid, s), sc, sdid)
  names(estimator.list)=c('SDID+fixed effect', 'synth. control', 'synth. diff-in-diff') #some of this need to remove but i still dont get it
  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'))
}

Manufacturing

MAN <- read_excel(" Manufacturing Hourly Earning.xlsx")
MAN$date<-as.Date(MAN$date)
MAN<-arrange(MAN,date,fips)

MAN_Change<-MAN%>%filter(date=="2005-01-01"|date=="2008-01-01")
MAN_Change<-MAN_Change%>%
  group_by(fips)%>%
  mutate(Change=(value[2]-value[1])/value[1]*100)

MAN_Change%>%filter(abbr=="LA")%>%select(-series_id)
## # A tibble: 2 × 7
## # Groups:   fips [1]
##   date       value title                                State fips  abbr  Change
##   <date>     <dbl> <chr>                                <chr> <chr> <chr>  <dbl>
## 1 2005-01-01  17.0 Average Hourly Earnings of Producti… Loui… 22    LA      16.0
## 2 2008-01-01  19.7 Average Hourly Earnings of Producti… Loui… 22    LA      16.0
MAN<-select(MAN,abbr,value,date)

dumy_date=seq.Date(from = as.Date("2001-01-01"),to = as.Date("2008-01-01"),by = "month")
Fix_df<-data_frame(STATE=rep(unique(MAN$abbr),length(dumy_date)))
Fix_df<-arrange(Fix_df,STATE)
Fix_df$DATE<-rep(dumy_date,length(unique(MAN$abbr)))

MAN<-left_join(Fix_df,MAN,by=c("STATE"="abbr","DATE"="date"))

MAN<-MAN %>% # Remove All NA STATE
  group_by(STATE) %>%  
  filter(DATE<="2008-01-01",!any(is.na(value)))

MAN$Treat<-ifelse(between(MAN$DATE,as.Date("2005-08-01"),as.Date("2022-06-01"))
                        &MAN$STATE=="LA",1,0)
MAN<-as.data.frame(MAN)
MAN$STATE<-factor(MAN$STATE)


# SDID PAN
matx<-panel.matrices(MAN,unit = 1,time = 2,outcome = 3,treatment = 4)

sdid.MAN<-synthdid_estimate(matx$Y, matx$N0, matx$T0)
sc.MAN = sc_estimate(matx$Y, matx$N0, matx$T0)

p4 = plot.estimators(estimators(sdid = sdid.MAN,sc = sc.MAN,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 = 9),axis.text = element_text(size=7),axis.title = element_text(size=7))

#tit=ggtitle(label = NM[NM$VAR=="MAN",]$Variable) #Change this

pl.MAN<-p4 + plot.theme+ xlab("Year") + ylab("Manufacturing")#+ scale_x_continuous(labels = c("2000-02","2002-11","2005-08","2008-05"))


pl.MAN

- NOTE : After Huricane in Lousiana there is 16.01% Change of Hourly earning in Manufacturing sectors.

Construction

CON <- read_excel("Construction Hourly Earning.xlsx")

CON$date<-as.Date(CON$date)
CON<-arrange(CON,date,fips)

# SInce the oldest observation we got in 2007-01-01 we will compare with that time.
CON_Change<-CON%>%filter(date=="2007-01-01"|date=="2008-01-01")
CON_Change<-CON_Change%>%
  group_by(fips)%>%
  mutate(Change=(value[2]-value[1])/value[1]*100)

CON_Change%>%filter(abbr=="LA")%>%select(-series_id)
## # A tibble: 2 × 7
## # Groups:   fips [1]
##   date       value title                                State fips  abbr  Change
##   <date>     <dbl> <chr>                                <chr> <chr> <chr>  <dbl>
## 1 2007-01-01  20.4 Average Hourly Earnings of All Empl… Loui… 22    LA     -1.86
## 2 2008-01-01  20   Average Hourly Earnings of All Empl… Loui… 22    LA     -1.86
ES <- read_excel("Education and Health Services Hourly Earning.xlsx")

ES$date<-as.Date(ES$date)
ES<-arrange(ES,date,fips)

# SInce the oldest observation we got in 2007-01-01 we will compare with that time.
ES_Change<-ES%>%filter(date=="2007-01-01"|date=="2008-01-01")
ES_Change<-ES_Change%>%
  group_by(fips)%>%
  mutate(Change=(value[2]-value[1])/value[1]*100)

ES_Change%>%filter(abbr=="LA")%>%select(-series_id)
## # A tibble: 2 × 7
## # Groups:   fips [1]
##   date       value title                                State fips  abbr  Change
##   <date>     <dbl> <chr>                                <chr> <chr> <chr>  <dbl>
## 1 2007-01-01  15.5 Average Hourly Earnings of All Empl… Loui… 22    LA      2.90
## 2 2008-01-01  16.0 Average Hourly Earnings of All Empl… Loui… 22    LA      2.90

Financial Activities

FI <- read_excel("Financial Activities Hourly Earning.xlsx")

FI$date<-as.Date(FI$date)
FI<-arrange(FI,date,fips)

# SInce the oldest observation we got in 2007-01-01 we will compare with that time.
FI_Change<-FI%>%filter(date=="2007-01-01"|date=="2008-01-01")
FI_Change<-FI_Change%>%
  group_by(fips)%>%
  mutate(Change=(value[2]-value[1])/value[1]*100)

FI_Change%>%filter(abbr=="LA")%>%select(-series_id)
## # A tibble: 2 × 7
## # Groups:   fips [1]
##   date       value title                                State fips  abbr  Change
##   <date>     <dbl> <chr>                                <chr> <chr> <chr>  <dbl>
## 1 2007-01-01  19.8 Average Hourly Earnings of All Empl… Loui… 22    LA     0.101
## 2 2008-01-01  19.8 Average Hourly Earnings of All Empl… Loui… 22    LA     0.101

Professional and Business Services

PBS <- read_excel("Professional and Business Services Hourly Earning.xlsx")

PBS$date<-as.Date(PBS$date)
PBS<-arrange(PBS,date,fips)

# SInce the oldest observation we got in 2007-01-01 we will compare with that time.
PBS_Change<-PBS%>%filter(date=="2007-01-01"|date=="2008-01-01")
PBS_Change<-PBS_Change%>%
  group_by(fips)%>%
  mutate(Change=(value[2]-value[1])/value[1]*100)

PBS_Change%>%filter(abbr=="LA")%>%select(-series_id)
## # A tibble: 2 × 7
## # Groups:   fips [1]
##   date       value title                                State fips  abbr  Change
##   <date>     <dbl> <chr>                                <chr> <chr> <chr>  <dbl>
## 1 2007-01-01  22.5 Average Hourly Earnings of All Empl… Loui… 22    LA      3.34
## 2 2008-01-01  23.2 Average Hourly Earnings of All Empl… Loui… 22    LA      3.34
PH <- read_excel("Total Private Hourly Earning.xlsx")

PH$date<-as.Date(PH$date)
PH<-arrange(PH,date,fips)

# SInce the oldest observation we got in 2007-01-01 we will compare with that time.
PH_Change<-PH%>%filter(date=="2007-01-01"|date=="2008-01-01")
PH_Change<-PH_Change%>%
  group_by(fips)%>%
  mutate(Change=(value[2]-value[1])/value[1]*100)

PH_Change%>%filter(abbr=="LA")%>%select(-series_id)
## # A tibble: 2 × 7
## # Groups:   fips [1]
##   date       value title                                State fips  abbr  Change
##   <date>     <dbl> <chr>                                <chr> <chr> <chr>  <dbl>
## 1 2007-01-01  18.0 Average Hourly Earnings of All Empl… Loui… 22    LA      5.77
## 2 2008-01-01  19.1 Average Hourly Earnings of All Empl… Loui… 22    LA      5.77

Trade, Transportation, and Utilities

TWU <- read_excel("Trade, Transportation, and Utilities Hourly Earning.xlsx")

TWU$date<-as.Date(TWU$date)
TWU<-arrange(TWU,date,fips)

# SInce the oldest observation we got in 2007-01-01 we will compare with that time.
TWU_Change<-TWU%>%filter(date=="2007-01-01"|date=="2008-01-01")
TWU_Change<-TWU_Change%>%
  group_by(fips)%>%
  mutate(Change=(value[2]-value[1])/value[1]*100)

TWU_Change%>%filter(abbr=="LA")%>%select(-series_id)
## # A tibble: 2 × 7
## # Groups:   fips [1]
##   date       value title                                State fips  abbr  Change
##   <date>     <dbl> <chr>                                <chr> <chr> <chr>  <dbl>
## 1 2007-01-01  15.5 Average Hourly Earnings of All Empl… Loui… 22    LA    -0.902
## 2 2008-01-01  15.4 Average Hourly Earnings of All Empl… Loui… 22    LA    -0.902