########################################################################################################### ##### FIGURE 1: LIST OF COUNTRIES BY YEAR OF ADOPTING FIRST COIN/NOTES WITH NATIONAL SYMBOL rm(list=ls()) library(knitr) library(MASS) library(mlogit) library(cquad) library(tidyverse) library(plm) library(stargazer) library(dplyr) library(lmtest) library(pcse) library(readstata13) library(brglm) library(sandwich) library(readxl) library(dygraphs) library(xts) library(readxl) library(stringr) df <- read_excel("~/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/Year_independence_Adoption_national_symbol.xlsx") str(df) df$independence_year <- str_sub(df$Independence_year, -4) df <- dplyr::select(df, Country, independence_year, Year_adoption_national_currency, Explanation, Type) df$independence_year <- as.numeric(df$independence_year) df$Year_adoption_national_currency <- as.numeric(df$Year_adoption_national_currency) df <- dplyr::mutate(df, duration = Year_adoption_national_currency-independence_year) library(ggplot2) df$duration <- as.character(df$duration) str(df) df <- mutate(df, duration = ifelse(is.na(duration) == T, "Censored", duration)) ggplot(df, aes(duration)) + geom_bar() + labs(caption = "Author's calculation", title="Fig.1: Years First Adoption since Indpendence 1945-2018", x ="Years", y = "Count" ) + theme(plot.title = element_text(face = "bold")) #ggsave("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/RIPE_Stats/Plots/FIG2.pdf") ########################################################################################################### ##### FIGURE 2: LIST OF COUNTRIES BY YEAR OF ADOPTING FIRST COIN/NOTES WITH NATIONAL SYMBOL ### Symbolic Dimension of Balkan nationalism 2011 survey df <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/Survey2011_complete.xlsx") as.data.frame(df) df$Country <- factor(df$Country,levels = c("Kosovo", "Albania", "Croatia", "Bosnia Herzegovina", "Macedonia", "Montenegro")) df <- dplyr::filter(df, Country != "Serbia") gg <- df %>% dplyr::filter(Type=="Strong_identification_with_Europe" | Type=="European_integration_good")%>% ggplot(df, mapping=aes(x=Country, y=Value, fill=factor(Type)))+ geom_bar(position="dodge", stat="identity")+ labs(title="Fig 2: Relationship with the EU: Western Balkans", y = "% Respondents", caption = "Source: Kolstø, 2016") + theme(axis.text.x=element_text(angle=45,hjust=1)) + scale_fill_discrete(name = "Legend", labels = c("EU Good Thing", "Strong European Feeling")) gg + theme(plot.title = element_text(face = "bold")) #ggsave("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/RIPE_Stats/Plots/FIG9.pdf") ########################################################################################################### ##### FIGURE 3 Inflation Performances: Balkan countries rm(list=ls()) library(knitr) library(MASS) library(mlogit) library(cquad) library(tidyverse) library(plm) library(stargazer) library(dplyr) library(lmtest) library(pcse) library(readstata13) library(brglm) library(sandwich) library(readxl) library(dygraphs) library(xts) #rm(list=ls()) infl <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/Inflationdata.xlsx", sheet = 5) balkan <- filter(infl, Country == "Kosovo" | Country == "Montenegro" | Country == "Macedonia, FYR" | Country == "Bosnia and Herzegovina" | Country == "Albania" | Country == "Slovenia" | Country == "Croatia") balkan2 <- dplyr::select(balkan, -"Indicator Type", -"Series Name", -"IMF Country Code") balkan2 <- reshape(balkan2, direction = "long", varying = list(names(balkan2)[3:51]), v.names = "Value", idvar = c("Country", "Country Code"), timevar = "Year", times = 1970:2018) kosovo <- read.csv("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/Kosovo_infl_WB.csv") # From World Bank kosovo <- kosovo %>% rename('Country Code' = Country.Code) balkan2 <- rbind(balkan2, kosovo) rm(balkan) df_balkan <- filter(balkan2, Year > 2001 & Year < 2018) df_balkan <- dplyr::rename(df_balkan, Inflation =Value ) g3 <- ggplot(df_balkan, aes(x = Year, y = Inflation)) + geom_line(aes(color = Country), size = 1) + theme_minimal() + labs(title = "Fig. 3: Inflation performance: Balkan Countries", caption = "Source: World Bank") + theme(plot.title = element_text(face = "bold")) g3 #ggsave("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/RIPE_Stats/Plots/FIG3.pdf") ########################################################################################################### ######################################################################################################### ## ################################### FIGURE 4 and 5 Import and Export ################################# rm(list=ls()) # On WITS: Country, year range, trade flow (import or export) library(readxl) library(dplyr) library(tidyr) # Albania albania_imp <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/AlbaniaWITS-Partner-Timeseries.xlsx", sheet="Partner-Timeseries") albania_exp <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/AlbaniaWITS-Partner-Timeseries-2.xlsx", sheet="Partner-Timeseries") albania <- rbind(albania_imp,albania_exp) rm(albania_imp,albania_exp) albania <- albania[,c(2,3,7:22)] albania <- albania %>% rename( country = "Partner Name", type = "Trade Flow") albania <- gather(albania, year, value, "2001":"2016", factor_key=TRUE) albania <- mutate(albania, export = ifelse(type == "Export", value, NA)) albania <- mutate(albania, import = ifelse(type == "Import", value, NA)) albania_total <- albania %>% group_by(year) %>% summarise(export_tot = sum(export, na.rm = TRUE), import_tot = sum(import, na.rm = TRUE)) albania$year <- as.numeric(albania$year) albania_euro <- filter(albania, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & year > 2006) | (country == "Cyprus" & year > 2007) | (country == "Malta" & year > 2007)) albania_euro <- albania_euro %>% group_by(year) %>% summarise(export_euro = sum(export, na.rm = TRUE), import_euro = sum(import, na.rm = TRUE)) %>% select(-year) albania_EU <- filter(albania, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & year > 2003) | (country == "Cyprus" & year > 2003) | (country == "Estonia" & year > 2003) | (country == "Hungary" & year > 2003) | (country == "Latvia" & year > 2003) | (country == "Lithuania" & year > 2003) | (country == "Poland" & year > 2003) | (country == "Slovakia" & year > 2003) | (country == "Slovenia" & year > 2003) | (country == "Malta" & year > 2003) | (country == "Bulgaria" & year > 2006) | (country == "Romania" & year > 2006)) albania_EU <- albania_EU %>% group_by(year) %>% summarise(export_EU = sum(export, na.rm = TRUE), import_EU = sum(import, na.rm = TRUE)) %>% select(-year) albania <- cbind(albania_total, albania_euro, albania_EU) rm(albania_total, albania_euro, albania_EU) albania <- albania %>% mutate(imp_EU_share = (import_EU) / import_tot, exp_EU_share = (export_EU) / export_tot, imp_euro_share = (import_euro) / import_tot, exp_euro_share = (export_euro) / export_tot) %>% dplyr::select(year, imp_EU_share, exp_EU_share, imp_euro_share, exp_euro_share) albania <- mutate(albania, country = "Albania") # Bosnia imports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/BosniaWITS-Partner-Timeseries-2.xlsx", sheet="Partner-Timeseries") exports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/BosniaWITS-Partner-Timeseries.xlsx", sheet="Partner-Timeseries") country <- rbind(imports,exports) rm(imports,exports) country <- country[,c(2,3,6:19)] country <- country %>% rename( country = "Partner Name", type = "Trade Flow") country <- gather(country, year, value, "2003":"2016", factor_key=TRUE) country <- mutate(country, export = ifelse(type == "Export", value, NA)) country <- mutate(country, import = ifelse(type == "Import", value, NA)) country_total <- country %>% group_by(year) %>% summarise(export_tot = sum(export, na.rm = TRUE), import_tot = sum(import, na.rm = TRUE)) country$year <- as.numeric(country$year) country_euro <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & year > 2006) | (country == "Cyprus" & year > 2007) | (country == "Malta" & year > 2007)) country_euro <- country_euro %>% group_by(year) %>% summarise(export_euro = sum(export, na.rm = TRUE), import_euro = sum(import, na.rm = TRUE)) %>% select(-year) country_EU <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & year > 2003) | (country == "Cyprus" & year > 2003) | (country == "Estonia" & year > 2003) | (country == "Hungary" & year > 2003) | (country == "Latvia" & year > 2003) | (country == "Lithuania" & year > 2003) | (country == "Poland" & year > 2003) | (country == "Slovakia" & year > 2003) | (country == "Slovenia" & year > 2003) | (country == "Malta" & year > 2003) | (country == "Bulgaria" & year > 2006) | (country == "Romania" & year > 2006)) country_EU <- country_EU %>% group_by(year) %>% summarise(export_EU = sum(export, na.rm = TRUE), import_EU = sum(import, na.rm = TRUE)) %>% select(-year) country <- cbind(country_total, country_euro, country_EU) rm(country_total, country_euro, country_EU) country <- country %>% mutate(imp_EU_share = (import_EU) / import_tot, exp_EU_share = (export_EU) / export_tot, imp_euro_share = (import_euro) / import_tot, exp_euro_share = (export_euro) / export_tot) %>% dplyr::select(year, imp_EU_share, exp_EU_share, imp_euro_share, exp_euro_share) bosnia <- mutate(country, country = "Bosnia") rm(country) # Croatia imports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/CroatiaWITS-Partner-Timeseries.xlsx", sheet="Partner-Timeseries") exports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/CroatiaWITS-Partner-Timeseries-2.xlsx", sheet="Partner-Timeseries") country <- rbind(imports,exports) rm(imports,exports) country <- country[,c(2,3,6:21)] country <- country %>% rename( country = "Partner Name", type = "Trade Flow") country <- gather(country, year, value, "2001":"2016", factor_key=TRUE) country <- mutate(country, export = ifelse(type == "Export", value, NA)) country <- mutate(country, import = ifelse(type == "Import", value, NA)) country_total <- country %>% group_by(year) %>% summarise(export_tot = sum(export, na.rm = TRUE), import_tot = sum(import, na.rm = TRUE)) country$year <- as.numeric(country$year) country_euro <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & year > 2006) | (country == "Cyprus" & year > 2007) | (country == "Malta" & year > 2007)) country_euro <- country_euro %>% group_by(year) %>% summarise(export_euro = sum(export, na.rm = TRUE), import_euro = sum(import, na.rm = TRUE)) %>% select(-year) country_EU <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & year > 2003) | (country == "Cyprus" & year > 2003) | (country == "Estonia" & year > 2003) | (country == "Hungary" & year > 2003) | (country == "Latvia" & year > 2003) | (country == "Lithuania" & year > 2003) | (country == "Poland" & year > 2003) | (country == "Slovakia" & year > 2003) | (country == "Slovenia" & year > 2003) | (country == "Malta" & year > 2003) | (country == "Bulgaria" & year > 2006) | (country == "Romania" & year > 2006)) country_EU <- country_EU %>% group_by(year) %>% summarise(export_EU = sum(export, na.rm = TRUE), import_EU = sum(import, na.rm = TRUE)) %>% select(-year) country <- cbind(country_total, country_euro, country_EU) rm(country_total, country_euro, country_EU) country <- country %>% mutate(imp_EU_share = (import_EU) / import_tot, exp_EU_share = (export_EU) / export_tot, imp_euro_share = (import_euro) / import_tot, exp_euro_share = (export_euro) / export_tot) %>% dplyr::select(year, imp_EU_share, exp_EU_share, imp_euro_share, exp_euro_share) croatia <- mutate(country, country = "Croatia") rm(country) ## # Montenegro library(readxl) library(dplyr) library(tidyr) imports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/MontenegroWITS-Partner-Timeseries-2.xlsx", sheet="Partner-Timeseries") exports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/MontenegroWITS-Partner-Timeseries.xlsx", sheet="Partner-Timeseries") country <- rbind(imports,exports) rm(imports,exports) country <- country[,c(2,3,6:16)] country <- country %>% rename( country = "Partner Name", type = "Trade Flow") country <- gather(country, year, value, "2006":"2016", factor_key=TRUE) country <- mutate(country, export = ifelse(type == "Export", value, NA)) country <- mutate(country, import = ifelse(type == "Import", value, NA)) country_total <- country %>% group_by(year) %>% summarise(export_tot = sum(export, na.rm = TRUE), import_tot = sum(import, na.rm = TRUE)) country$year <- as.numeric(country$year) country_euro <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & year > 2006) | (country == "Cyprus" & year > 2007) | (country == "Malta" & year > 2007)) country_euro <- country_euro %>% group_by(year) %>% summarise(export_euro = sum(export, na.rm = TRUE), import_euro = sum(import, na.rm = TRUE)) %>% select(-year) country_EU <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & year > 2003) | (country == "Cyprus" & year > 2003) | (country == "Estonia" & year > 2003) | (country == "Hungary" & year > 2003) | (country == "Latvia" & year > 2003) | (country == "Lithuania" & year > 2003) | (country == "Poland" & year > 2003) | (country == "Slovakia" & year > 2003) | (country == "Slovenia" & year > 2003) | (country == "Malta" & year > 2003) | (country == "Bulgaria" & year > 2006) | (country == "Romania" & year > 2006)) country_EU <- country_EU %>% group_by(year) %>% summarise(export_EU = sum(export, na.rm = TRUE), import_EU = sum(import, na.rm = TRUE)) %>% select(-year) country <- cbind(country_total, country_euro, country_EU) rm(country_total, country_euro, country_EU) country <- country %>% mutate(imp_EU_share = (import_EU) / import_tot, exp_EU_share = (export_EU) / export_tot, imp_euro_share = (import_euro) / import_tot, exp_euro_share = (export_euro) / export_tot) %>% dplyr::select(year, imp_EU_share, exp_EU_share, imp_euro_share, exp_euro_share) montenegro <- mutate(country, country = "Montenegro") rm(country) # Slovenia imports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/SloveniaWITS-Partner-Timeseries-2.xlsx", sheet="Partner-Timeseries") exports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/SloveniaWITS-Partner-Timeseries.xlsx", sheet="Partner-Timeseries") country <- rbind(imports,exports) rm(imports,exports) country <- country[,c(2,3,6:21)] country <- country %>% rename( country = "Partner Name", type = "Trade Flow") country <- gather(country, year, value, "2001":"2016", factor_key=TRUE) country <- mutate(country, export = ifelse(type == "Export", value, NA)) country <- mutate(country, import = ifelse(type == "Import", value, NA)) country_total <- country %>% group_by(year) %>% summarise(export_tot = sum(export, na.rm = TRUE), import_tot = sum(import, na.rm = TRUE)) country$year <- as.numeric(country$year) country_euro <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & year > 2006) | (country == "Cyprus" & year > 2007) | (country == "Malta" & year > 2007)) country_euro <- country_euro %>% group_by(year) %>% summarise(export_euro = sum(export, na.rm = TRUE), import_euro = sum(import, na.rm = TRUE)) %>% select(-year) country_EU <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & year > 2003) | (country == "Cyprus" & year > 2003) | (country == "Estonia" & year > 2003) | (country == "Hungary" & year > 2003) | (country == "Latvia" & year > 2003) | (country == "Lithuania" & year > 2003) | (country == "Poland" & year > 2003) | (country == "Slovakia" & year > 2003) | (country == "Slovenia" & year > 2003) | (country == "Malta" & year > 2003) | (country == "Bulgaria" & year > 2006) | (country == "Romania" & year > 2006)) country_EU <- country_EU %>% group_by(year) %>% summarise(export_EU = sum(export, na.rm = TRUE), import_EU = sum(import, na.rm = TRUE)) %>% select(-year) country <- cbind(country_total, country_euro, country_EU) rm(country_total, country_euro, country_EU) country <- country %>% mutate(imp_EU_share = (import_EU) / import_tot, exp_EU_share = (export_EU) / export_tot, imp_euro_share = (import_euro) / import_tot, exp_euro_share = (export_euro) / export_tot) %>% dplyr::select(year, imp_EU_share, exp_EU_share, imp_euro_share, exp_euro_share) slovenia <- mutate(country, country = "Slovenia") rm(country) # Macedonia imports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/MacedoniaWITS-Partner-Timeseries-2.xlsx", sheet="Partner-Timeseries") exports <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/MacedoniaWITS-Partner-Timeseries.xlsx", sheet="Partner-Timeseries") country <- rbind(imports,exports) rm(imports,exports) names(country) country <- country[,c(2,3,13:28)] country <- country %>% rename( country = "Partner Name", type = "Trade Flow") country <- gather(country, year, value, "2001":"2016", factor_key=TRUE) country <- mutate(country, export = ifelse(type == "Export", value, NA)) country <- mutate(country, import = ifelse(type == "Import", value, NA)) country_total <- country %>% group_by(year) %>% summarise(export_tot = sum(export, na.rm = TRUE), import_tot = sum(import, na.rm = TRUE)) country$year <- as.numeric(country$year) country_euro <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & year > 2006) | (country == "Cyprus" & year > 2007) | (country == "Malta" & year > 2007)) country_euro <- country_euro %>% group_by(year) %>% summarise(export_euro = sum(export, na.rm = TRUE), import_euro = sum(import, na.rm = TRUE)) %>% select(-year) country_EU <- filter(country, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & year > 2003) | (country == "Cyprus" & year > 2003) | (country == "Estonia" & year > 2003) | (country == "Hungary" & year > 2003) | (country == "Latvia" & year > 2003) | (country == "Lithuania" & year > 2003) | (country == "Poland" & year > 2003) | (country == "Slovakia" & year > 2003) | (country == "Slovenia" & year > 2003) | (country == "Malta" & year > 2003) | (country == "Bulgaria" & year > 2006) | (country == "Romania" & year > 2006)) country_EU <- country_EU %>% group_by(year) %>% summarise(export_EU = sum(export, na.rm = TRUE), import_EU = sum(import, na.rm = TRUE)) %>% select(-year) country <- cbind(country_total, country_euro, country_EU) rm(country_total, country_euro, country_EU) country <- country %>% mutate(imp_EU_share = (import_EU) / import_tot, exp_EU_share = (export_EU) / export_tot, imp_euro_share = (import_euro) / import_tot, exp_euro_share = (export_euro) / export_tot) %>% dplyr::select(year, imp_EU_share, exp_EU_share, imp_euro_share, exp_euro_share) macedonia <- mutate(country, country = "Macedonia") rm(country) ############### From Kosovo Central Bank kos_exp <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/Kosovo_exports_central_bank.xlsx") kos_exp <- kos_exp[-c(1,2,3),] kos_imp <- read_excel("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/Kosovo_Imports_central_bank.xlsx") kos_imp <- kos_imp[-c(1,2,3),] imp_total <- dplyr::select(kos_imp, Year, Total) imp_total <- dplyr::rename(imp_total, tot_import = Total) exp_total <- dplyr::select(kos_exp, Year, Total) exp_total <- dplyr::rename(exp_total, tot_export = Total) kos_exp <- dplyr::select(kos_exp, -Total) kos_imp <- dplyr::select(kos_imp, -Total) kos_imp <- gather(kos_imp, country, value, "Austria":"Others", factor_key=TRUE) kos_exp <- gather(kos_exp, country, value, "Austria":"Others", factor_key=TRUE) kos_imp$Year <- as.numeric(kos_imp$Year) kos_exp$Year <- as.numeric(kos_exp$Year) exp_euro <- filter(kos_exp, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & Year > 2006) | (country == "Cyprus" & Year > 2007) | (country == "Malta" & Year > 2007)) exp_euro <- exp_euro %>% group_by(Year) %>% summarise(export_euro = sum(value, na.rm = TRUE)) imp_euro <- filter(kos_imp, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | (country == "Slovenia" & Year > 2006) | (country == "Cyprus" & Year > 2007) | (country == "Malta" & Year > 2007)) imp_euro <- imp_euro %>% group_by(Year) %>% summarise(import_euro = sum(value, na.rm = TRUE)) imp_EU <- filter(kos_imp, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & Year > 2003) | (country == "Cyprus" & Year > 2003) | (country == "Estonia" & Year > 2003) | (country == "Hungary" & Year > 2003) | (country == "Latvia" & Year > 2003) | (country == "Lithuania" & Year > 2003) | (country == "Poland" & Year > 2003) | (country == "Slovakia" & Year > 2003) | (country == "Slovenia" & Year > 2003) | (country == "Malta" & Year > 2003) | (country == "Bulgaria" & Year > 2006) | (country == "Romania" & Year > 2006)) imp_EU <- imp_EU %>% group_by(Year) %>% summarise(import_EU = sum(value, na.rm = TRUE)) exp_EU <- filter(kos_exp, country == "Germany" | country == "Netherlands" | country == "Ireland" | country == "France" | country == "Austria" | country == "Belgium" | country == "Finland" | country == "Greece" | country == "Italy" | country == "Luxembourg" | country == "Portugal" | country == "Spain" | country == "Denmark" | country == "United Kingdom" | country == "Sweden" | (country == "Slovenia" & Year > 2003) | (country == "Cyprus" & Year > 2003) | (country == "Estonia" & Year > 2003) | (country == "Hungary" & Year > 2003) | (country == "Latvia" & Year > 2003) | (country == "Lithuania" & Year > 2003) | (country == "Poland" & Year > 2003) | (country == "Slovakia" & Year > 2003) | (country == "Slovenia" & Year > 2003) | (country == "Malta" & Year > 2003) | (country == "Bulgaria" & Year > 2006) | (country == "Romania" & Year > 2006)) exp_EU <- exp_EU %>% group_by(Year) %>% summarise(export_EU = sum(value, na.rm = TRUE)) df <- full_join(exp_EU, imp_EU) df <- full_join(exp_euro, df) df <- full_join(imp_euro, df) df <- full_join(exp_total, df) kosovo <- full_join(imp_total, df) rm(exp_EU); rm(imp_EU); rm(exp_euro); rm(imp_euro); rm(exp_total); rm(imp_total); rm(df) rm(kos_exp); rm(kos_imp) kosovo <- kosovo %>% mutate(imp_EU_share = (import_EU) / tot_import, exp_EU_share = (export_EU) / tot_export, imp_euro_share = (import_euro) / tot_import, exp_euro_share = (export_euro) / tot_export) %>% dplyr::select(Year, imp_EU_share, exp_EU_share, imp_euro_share, exp_euro_share) kosovo <- mutate(kosovo, country = "Kosovo") kosovo <- rename(kosovo, year = Year) kosovo$year <-as.factor(kosovo$year) trade <- full_join(albania, bosnia) trade <- full_join(croatia, trade) trade <- full_join(kosovo, trade) trade <- full_join(macedonia, trade) trade <- full_join(montenegro, trade) trade <- full_join(slovenia, trade) trade <- full_join(bosnia, trade) ### Linearly interpolating one obsrvation (for Macedonia) library(zoo); library(ggplot2) trade$exp_euro_share <- na.approx(trade$exp_euro_share) trade$exp_EU_share <- na.approx(trade$exp_EU_share) trade$year <- as.numeric(as.character(trade$year)) trade <- dplyr::filter(trade, year < 2017) # To make the Graph more discernible, let's increase size for Montenegro and Kosovo trade <- mutate(trade, Highlight= 1) trade <- trade %>% mutate(Highlight = ifelse(country == "Kosovo" | country == "Montenegro", 2, Highlight )) cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#CC79A7", "#FF0000") imports_euro <- ggplot(trade, aes(x = year, y = imp_euro_share)) + geom_line(aes(color = country), size = 1) + scale_color_manual(values = cbPalette) + xlab("Year") + ylab("Imports (% of total imports)") + labs(title = "Fig. 6: Imports from Eurozone countries (%)", caption = "Source: World Bank") imports_euro + theme(plot.title = element_text(face = "bold")) #ggsave("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/RIPE_Stats/Plots/FIG6.pdf") exports_euro <- ggplot(trade, aes(x = year, y = exp_euro_share)) + geom_line(aes(color = country), size = 1) + scale_color_manual(values = cbPalette) + xlab("Year") + ylab("Exports (% of total imports)") + theme(legend.position = "none") + labs(title = "Fig. 7: Exports from Eurozone countries (%)", caption = "Source: World Bank") exports_euro + theme(plot.title = element_text(face = "bold")) #ggsave("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/RIPE_Stats/Plots/FIG7.pdf") ###### PLEASE NOTICE THAT THE ANALYSIS BELOW WILL NOT REPLICATE TH ESTIAMTES OF TABLE 1 ACCURATELY ###### I AM AFRAID I CANNOT RECOVER WHAT I DID IN THE ORIGINAL ANALYSIS AND I CANNOT REPLICATE THE EXACT RESULTS ###### NOTICE, THOUGH, THAT THE ANLAYSIS IS CONSISTENT WITH EVERYTHING WRITTEN IN THE PAPER, (ACTUALLY THE RESULTS ARE EVEN MORE ##### STRONGLY IN FAVOR OF MY HYPOTHESIS). IN PARTICULAR IN P. 12 I WRITE: "Montenegro’s price co-movement is the least synchronised to the eurozone after that of Serbia. # On the output side, Montenegro is less synchronised with the eurozone than any other country in the sample.". THIS REMAINES TRUE. ########################################################################################################### ##### Table 1: Eurozone - Balkans co-movements library(readr) library(tidyr) rm(list=ls()) #Loading packages Packages <- c("tidytext", "data.table", "stringr", "rvest", "zoo", "quanteda", "tm.plugin.lexisnexis", "tm.plugin.factiva", "xml2", "ggplot2", "tm", "reshape2", "knitr", "DataCombine", "dplyr", "MASS", "qgraph", "stringr", "plyr", "NLP", "readr", "readxl", "EGAnet", "Hmisc") lapply(Packages, library, character.only = TRUE) # Notice that it is constant ($2017) gdp_ppp <- read_csv("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/API_NY.GDP.MKTP.PP.KD_DS2_en_csv_v2_5343796.csv", skip = 3) class(gdp_ppp$`Country Name`) gdp_ppp <- dplyr::filter(gdp_ppp, `Country Name` == "Albania" | `Country Name` == "Bosnia and Herzegovina" | `Country Name` == "Bulgaria" | `Country Name` == "Euro area" | `Country Name` == "Croatia" | #`Country Name` == "Kosovo" | `Country Name` == "North Macedonia" | `Country Name` == "Montenegro" | `Country Name` == "Serbia" ) gdp_ppp <- dplyr::select(gdp_ppp, "Country Name", "2008":"2021") gdp_ppp <- gather(gdp_ppp, year, gdp_ppp, "2008":"2021", factor_key=TRUE) gdp_ppp er_wb <- read_csv("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/API_PA.NUS.FCRF_DS2_en_csv_v2_5337029.csv", skip = 3) er_wb <- dplyr::filter(er_wb, `Country Name` == "Albania" | `Country Name` == "Bosnia and Herzegovina" | `Country Name` == "Bulgaria" | `Country Name` == "Croatia" | `Country Name` == "Euro area" | #`Country Name` == "Kosovo" | `Country Name` == "North Macedonia" | `Country Name` == "Montenegro" | `Country Name` == "Serbia" ) er_wb <- dplyr::select(er_wb, "Country Name", "2008":"2021") er_wb <- gather(er_wb, year, er, "2008":"2021", factor_key=TRUE) er_wb # Merge df <- full_join(gdp_ppp,er_wb ) # Notice that euro area has no ER with US prior to 1999 in the dataset from the World Bank. # Nevertheless, theoretical historical ER can be found here https://fxtop.com/en/historical-exchange-rates.php?A=1&C1=USD&C2=EUR&YA=1&DD1=01&MM1=01&YYYY1=1990&B=1&P=&I=1&DD2=24&MM2=03&YYYY2=2023&btnOK=Go%21 # I directly insert the values for 1998 and 1997 df <- mutate(df, er = ifelse(`Country Name` == "Euro area" & year == 1998, 0.898283, er)) df <- mutate(df, er = ifelse(`Country Name` == "Euro area" & year == 1997, 0.885013, er)) euroarea <- dplyr::filter(df, `Country Name` == "Euro area" ) euroarea_tmp <- dplyr::select(euroarea, year, er) euroarea_tmp <- dplyr::rename(euroarea_tmp, er_euro = er) df <- full_join(df,euroarea_tmp ) df <- mutate(df, er = ifelse(is.na(er), er_euro, er)) df <- dplyr::select(df, -er_euro) # Step 1: P_i = (PPP of GDP) / (ex. rate) measures how many units of U.S. output can with one unit of country i's output, # that is, it measures the relative price of output with respect to that of the df <- dplyr::mutate(df, P_i = gdp_ppp/er) # Step 2: P_j , i.e. same as above but for the anchor (eurozone) euroarea <- dplyr::filter(df, `Country Name` == "Euro area" ) df <- dplyr::filter(df, `Country Name` != "Euro area" ) euroarea <- dplyr::select(euroarea, year, P_i) euroarea <- dplyr::rename(euroarea, P_j = P_i) df <- full_join(df,euroarea ) # Step 3: relative prices between country and anchor, P_i / P_j, in log form df <- dplyr::mutate(df, P_ratios_log = log(P_i/P_j)) df <- dplyr::rename(df, country = "Country Name") # Step 4: estimate the second order autoregressive model library("plm") panel_df <- pdata.frame(df, index=c("country","year")) panel_df <- dplyr::select(panel_df, country, year, P_ratios_log) panel_df <- panel_df %>% dplyr::group_by(country) %>% dplyr::mutate(P_ratios_log1 = dplyr::lag(P_ratios_log, 1)) panel_df <- panel_df %>% group_by(country) %>% dplyr::mutate(P_ratios_log2 = dplyr::lag(P_ratios_log, 2)) panel_df <- dplyr::filter(panel_df, !is.na(P_ratios_log)) class(panel_df$year) emp.gmm <- pgmm(P_ratios_log~lag(P_ratios_log, 1) + lag(P_ratios_log, 2)| lag(P_ratios_log, 2:99), data = panel_df, effect = "individual", model = "onestep") summary(emp.gmm) # Step 6: calculate the RMSE of the residuals as in Alesina et al., 2002, p. 313 res <- as.data.frame(residuals(emp.gmm)) #res <- as.data.frame(t(res)) # Step 6a: squared residuals res2 <- res^2 # Step 6b: summation over time sum <- as.data.frame(colSums(res2)) # Step 6c: multiply by 1/(t-3) # Notice T = 13 for all countries sum <- dplyr::mutate(sum, t = 1/(13-3)) #sum[6,2] = 1/(14-3) sum <- dplyr::rename(sum, residuals_sq_sum = `colSums(res2)`) sum <- dplyr::mutate(sum, residuals_sq_sum_t = residuals_sq_sum * t) # Step 6d: square root comov <- dplyr::mutate(sum, comov_price = sqrt(residuals_sq_sum_t)) #Interpretation: the lower the value the greater the comovement with euro area ######## Now comovement in output rm(list = ls()) output <- read_csv("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/API_NY.GDP.PCAP.KD_DS2_en_csv_v2_5338219.csv", skip = 3) output <- dplyr::filter(output, `Country Name` == "Albania" | `Country Name` == "Bosnia and Herzegovina" | `Country Name` == "Bulgaria" | `Country Name` == "Euro area" | `Country Name` == "Croatia" | #`Country Name` == "Kosovo" | `Country Name` == "North Macedonia" | `Country Name` == "Montenegro" | `Country Name` == "Serbia" ) output <- dplyr::select(output, "Country Name", "2006":"2021") output <- gather(output, year, output, "2006":"2021", factor_key=TRUE) output euroarea <- dplyr::filter(output, `Country Name` == "Euro area" ) output <- dplyr::filter(output, `Country Name` != "Euro area" ) euroarea <- dplyr::rename(euroarea, output_euro = output) euroarea <- dplyr::select(euroarea, -`Country Name`) df <- left_join(output,euroarea ) # Step 3: relative prices between country and anchor, P_i / P_j, in log form df <- dplyr::mutate(df, Y_ratios_log = log(output/output_euro)) df <- dplyr::rename(df, country = "Country Name") # Step 4: estimate the second order autoregressive model library("plm") panel_df <- pdata.frame(df, index=c("country","year")) panel_df <- dplyr::select(panel_df, country, year, Y_ratios_log) panel_df <- panel_df %>% group_by(country) %>% dplyr::mutate(Y_ratios_log1 = dplyr::lag(Y_ratios_log, 1)) panel_df <- panel_df %>% group_by(country) %>% dplyr::mutate(Y_ratios_log2 = dplyr::lag(Y_ratios_log, 2)) emp.gmm <- pgmm(Y_ratios_log~lag(Y_ratios_log, 1) + lag(Y_ratios_log, 2)| lag(Y_ratios_log, 2:99), data = panel_df, effect = "individual", model = "onestep") summary(emp.gmm) # Step 6: calculate the RMSE of the residuals as in Alesina et al., 2002, p. 313 res <- as.data.frame(residuals(emp.gmm)) #res <- as.data.frame(t(res)) # Step 6a: squared residuals res2 <- res^2 # Step 6b: summation over time sum <- as.data.frame(colSums(res2)) # Step 6c: multiply by 1/(t-3) # Notice T = 25 for all countries but Kosovo (T = 14) sum <- dplyr::mutate(sum, t = 1/(16-3)) #sum[6,2] = 1/(14-3) sum <- dplyr::rename(sum, residuals_sq_sum = `colSums(res2)`) sum <- dplyr::mutate(sum, residuals_sq_sum_t = residuals_sq_sum * t) # Step 6d: square root comov <- dplyr::mutate(sum, comov_output = sqrt(residuals_sq_sum_t)) #Interpretation: the lower the value the greater the comovement with euro area ### TABLE 2: STATE CAPACITY rm(list=ls()) library(haven) library(dplyr) df <- read_dta("/Users/Nicola/Box Sync/Ideasss (nn6nc@Virginia.EDU)/PolEcon ideas/Montenegro/NEW POLITICAL ECONOMY/NPE R&R/FINAL_replication_package/StateCapacityDataset_v1.dta") df <- dplyr::select(df, cntrynum, country, year, Capacity) df <- dplyr::filter(df, country == "Montenegro" | country == "Cameroon" | country == "Senegal" | country == "Togo" | country == "Benin" | country == "Burkina Faso" |country == "Niger"|country == "Ivory Coast"|country == "Gabon" | country == "Mauritania" |country == "Liberia") df2 <- df %>% group_by(country) %>% arrange(country, year) %>% filter(row_number()==1:8) df4 <- df %>% group_by(country) %>% arrange(country, year) %>% filter(row_number()==2) df3 <- df2 %>% group_by(country) %>% summarise_at(vars(Capacity), list(name = mean)) # Manually insert into Table 2 the following numbers View(df4) View(df3)