As expressed in the title, this analysis centers around the economical effects different governmental policies have on countries around the world. This project will address whether countries with less invasive government tendencies have more productive economies, and will compare the rankings given to each country by The Heritage Foundation. The variables that will be included in this data collection are: Gross Domestic Product (GDP), Property Rights, Tax Burden, Business Freedom, Financial Freedom, World Ranking, and many others. This information will display any correlation between government policies and the well-being of that country’s economy. This is especially important in today’s world with increasing regulations and burdensome political structures.
The original data set that will be used in this study was collected by The Heritage Foundation, an influential research organization that gathers annual information on countries all over the world. The particular set examined in this analysis is an exhaustive agglomeration of economic and governmental variables gathered for this year, 2017. To access this data set, please click here.
In order to discover trends from this data, we will look at the highest ranked and lowest ranked countries and discover from where this differentiation comes. To most effectively visualize the information, we will use various scatterplots measuring the correlation of two (or more) variables.
By observing the contrasting elements of government tactics and the response to these policies by the economy, we can learn which type of political atmosphere is most conducive to a thriving economy. “Incentives Matter;” Understanding whom we elect and their role in creating an environment where wealth creation is encouraged is central to being an informed, constructive citizen.
In order to evaluate the Heritage Foundation Excel information you will need to load the following packages to be able to access and manipulate the dataset:
library(readxl) #Import Excel file to R
library(tidyverse) #Tidy up data
library(DT) #Print tables
library(magrittr) #Piping
library(tibble) #Creating tibbles
library(gridExtra) #Creating grids
library(scales) #Axis scales/formatting
As previously mentioned, for this project I am examining data from the second half of 2015 through the first half of 2016 collected by The Heritage Foundation titled, “2017 Index Data.” This dataset measures 186 countries’ Economic Freedom, which is defined as “the fundamental right of every human to control his or her own labor and property.” Measures of Economic Freedom are based on 12 factors, grouped into four broad categories : Rule of Law, Government Size, Regulatory Efficiency, and Open Markets. The Heritage Foundation argues that Economics Freedom brings prosperity; we will analyze this argument by examining correlations of differnt scores and graphing the data collected by the Heritage Foundation.
By exporting the data to an Excel spreadsheet we are able to locate the document for future referencing. Once we have loaded “readxl,” we can start the process of loading and tidying the data by viewing the Sheets in the Spreadsheet. I have labled my original exported Excel dataset “RData.xlsx.” This collection originally consisted of 34 variables (missing values = N/A), but we will limit our analysis to only the most critical measurements and get rid of duplicate data. I have replaced the N/A values with ‘0’ because I want to create a more full picture, using as much data as possible. There are numerous countries with only one variable missing, but with the rest of its data complete. By removing these N/A observtions wholly, we lose insight on the other important information provided by that nation.
#################
##Loading Data##
################
##Lists all Sheets in Excel Spreadsheet##
excel_sheets("RData.xlsx")
##Read in Dataset##
read_excel("RData.xlsx", sheet = "Sheet1")
##Assigns name to Dataset##
heritage_data <- read_excel("RData.xlsx", sheet = "Sheet1")
#################
##Cleaning Data##
#################
##Assigns Numeric and Character Variables##
char = c(2:4,25)
num = c(1,5:24,26:34)
heritage_data[,char]<-sapply(heritage_data[, char], as.character)
heritage_data[,num]<- sapply(heritage_data[, num], as.numeric)
##Replaces N/A with 0##
heritage_data[is.na(heritage_data)] <- 0
##Eliminates Unnecessary Variables##
clean_heritage <- heritage_data[c(-1,-3,-6,-25)]
##Creates Datatable for Cleaned Data##
datatable(clean_heritage, caption = 'Table 1: Clean Economic Data')
The purpose for this data exploration is to visually interpret the information obtained from the Heritage Foundation’s Economic Freedom index. We will focus on the differences between regions and learn how different variables effect a country’s economic well-being. From this analysis, we will have a better understanding of what factors impact a country’s Economic Freedom Score and that nation’s GDP
When first trying to assimilate all of the data contained in our research, the most preliminary question that provides a starting point for our study is, “Which country has the highest Economic Freedom Score?” This inquiry leads us to our first graph. Here, we use boxplots to show the dispersion of economic scores by region.
From this figure, we can conclude that countries in Europe have the highest average Economic Freedom Score, though the Asia-Pacific region has the highest outliers.
clean_heritage %>%
ggplot(aes(Region, `2017 Score`, color=Region)) + geom_boxplot() + geom_jitter()+
ggtitle("Figure 1: Distribution of Economic Freedom Score", subtitle = " by Region")
Of interest to the next part of our investigation is finding with which countries these outliers correspond. To do this, we created a datatable that displays the countries in descending World Rank (and therefore, Economic Freedom Score). In agreement with Figure 1, Asia-Pacific leads, with European and American countries dispersed throughout the ranking, as well.
top_rankdt <- clean_heritage[c(1,2,4,3)] %>%
filter(`World Rank` > 0)
datatable(head(top_rankdt, 186), class = 'cell-border stripe', caption = 'Highest Ranking/Scoring Countries to Lowest', options = list(
order = list(list(4, 'asc'))))
To further build off this datatable, and limit our focus even more, we will create a bar chart that shows only the absolute highest ranking countries by region. We successfully filtered our data to include only the top 10 percent of the highest ranking countries. [186*.10 = 18.6 -> 19] From the following graph, it can be inferred that the region with the most number of top ranking countries is Europe, with the next closest region, Asia-Pacific, having only half as many.
top_rank <- filter(clean_heritage, `World Rank` > 0, `World Rank` < 20)
top_rank %>%
ggplot(aes(Region, fill=`Country Name`)) + geom_bar() +
ggtitle("Figure 2: Top 10% Highest Ranking Countries", subtitle = "by Region")
Now that we’ve concluded that, overall, European nations generally have the highest measure of Economic Freedom, we will determine if these high scores/rankings are correlated to thriving economies. For this analysis, we will create a scatterplot with the dependent variable being the country’s GDP and the independent variable set to Economic Freedom Score. This visualization will display the relationship between the two variables, helping us to recognize any correlation that is present.
clean_heritage%>%
ggplot(aes(x=`2017 Score`, y=`GDP (Billions, PPP)`, color=Region)) +
geom_point() +
ggtitle("Figure 3: Economic Freedom and GDP",
subtitle = "By Region")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
gdpvscore <- clean_heritage[c(4,23,26)]
cor(gdpvscore$`2017 Score`, gdpvscore$`GDP (Billions, PPP)`)
## [1] 0.09660731
The above plot shows that there is not a very strong relationship between Economic Freedom Score and GDP. We would expect the values to be spread more horizontally, but instead the data is relatively vertical. If fact, if we calculate the correlation between these factors, the Economic Freedom Score has only a 10% impact on GDP.
However, if we look at this relationship using GDP per Capita, instead, we reach very different results. We’ll start by examining the scatterplot, then move on to the correlation coefficient.
clean_heritage%>%
ggplot(aes(x=`2017 Score`, y=`GDP per Capita (PPP)`, color=Region)) +
geom_point() +
ggtitle("Figure 4: Economic Freedom and GDP per Capita",
subtitle = "By Region")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
gdpvscore <- clean_heritage[c(4,23,26)]
cor(gdpvscore$`2017 Score`, gdpvscore$`GDP per Capita (PPP)`)
## [1] 0.501268
As is evident from comparing the two scatterplots, Economic Freedom Score has a much larger influence on GDP per Capita. The values have a much more positive, linear relationship without as much variance in the spread. The correlation coefficient is much higher, too (more than 5 times higher.) This leads us to the conclusion that Economic Freedom Score has a noticeable impact on a country’s GDP per Capita.
These findings lead to wondering what causes the difference between the relationship the Economic Freedom Score has with a nation’s GDP and GDP per Capita. If we look at the following boxplot, we will see that the region with the highest GDP is the Middle East/North Africa. In coordinance with our previous research on correlations, this was not a region that particularly stood out for having a high Economic score. So what is causing this part of the world to be so economically successful? I would argue that access to an abundance of valuable resources is what is most critical to this region’s economic well-being.
clean_heritage%>%
ggplot(aes(Region, `GDP (Billions, PPP)`, color = Region)) + geom_boxplot() + geom_jitter() +
ggtitle("Figure 5: Distribution of GDP (Billions)",
subtitle = "By Region") +
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
However, if we plot the same graph substituting GDP per Capita for overall GDP, the output is much more similar to the Economic Freedom Score boxplot (Figure 1). This is expected becuase of the high correlation between GDP per Capita and Economic score.
clean_heritage%>%
ggplot(aes(Region, `GDP per Capita (PPP)`, color = Region)) + geom_boxplot() + geom_jitter() +
ggtitle("Figure 6: Distribution of GDP per Capita",
subtitle = "By Region") +
scale_y_continuous(labels = scales::dollar)
Similar to our analysis of the top 10 percent of the highest ranking countries, we will now look into the top 10 percent of countries with the highest GDP per Capita. In order to limit our data to include only the countries with the highest GDP per Capita, we filtered the numbers for GDPs per Capita that are over $46,783 (the 20th highest value). This resulted in the 19 countries with the wealthiest citizen base. Again, this visual is akin to Figure 2 because of the strong correlation between GDP per Capita and Economic Freedom Score. However, there is a much higher count of countries in the Middle East/North Africa. Like we decided above, this could be due to the concentration of natural resources in that area.
top_gdpcap <- filter(clean_heritage, `GDP per Capita (PPP)` > 46783.0)
top_gdpcap %>%
ggplot(aes(Region, fill = `Country Name`)) + geom_bar() +
ggtitle("Figure 7: Top 10% GDP per Capita", subtitle = " by Region")
The following datatable ranks the countries with the highest GDP per Capita in descending order.
top_gdpcapdt <- clean_heritage[c(1,2,4,26)]
datatable(head(top_gdpcapdt, 186), class = 'cell-border stripe', caption = 'Highest GDP per Capita to Lowest', options = list(
order = list(list(4, 'desc'))))
Now that we have an understanding of the relationship between the Economic Freedom Score and both GDP and GDP per capita, we need to look at what factors of the Economic Freedom Score are most impactful. To do this, we must understand how the Economic Freedom Score is calculated. As previously sited, the Heritage Foundation states that:
“We measure economic freedom based on 12 quantitative and qualitative factors, grouped into four broad categories, or pillars, of economic freedom: 1.Rule of Law (property rights, government integrity, judicial effectiveness) 2.Government Size (government spending, tax burden, fiscal health) 3.Regulatory Efficiency (business freedom, labor freedom, monetary freedom) 4.Open Markets (trade freedom, investment freedom, financial freedom) Each of the twelve economic freedoms within these categories is graded on a scale of 0 to 100. A country’s overall score is derived by averaging these twelve economic freedoms, with equal weight being given to each.”
We will now observe how these four pillars of Economic Freedom correlate with GDP and GDP per Capita in order to determine if one is more influential than others.
rule_of_law <- clean_heritage[c(1,5:7,23)]
rule_of_law$mean <- rowMeans(subset(rule_of_law, select = c(2:4)), na.rm = TRUE)
p1 <- rule_of_law %>%
ggplot(aes(x=mean, y=`GDP (Billions, PPP)`)) +
geom_point() +
geom_smooth() +
ggtitle("Rule of Law and GDP",
subtitle = "average of property rights, government
integrity, judicial effectiveness")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
government_size <- clean_heritage[c(1,8:10,23)]
government_size$mean <- rowMeans(subset(government_size, select = c(2:4)), na.rm = TRUE)
p2 <- government_size%>%
ggplot(aes(x=mean, y=`GDP (Billions, PPP)`)) +
geom_point()+
geom_smooth() +
ggtitle("Government Size and GDP",
subtitle = "average of government spending, tax burden,
fiscal health")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
regulatory_efficiency <- clean_heritage[c(1,11:13,23)]
regulatory_efficiency$mean <- rowMeans(subset(regulatory_efficiency, select = c(2:4)), na.rm = TRUE)
p3 <- regulatory_efficiency%>%
ggplot(aes(x=mean, y=`GDP (Billions, PPP)`)) +
geom_point()+
geom_smooth() +
ggtitle("Regulatory Efficiency and GDP",
subtitle = "average of business freedom, labor freedom,
monetary freedom")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
open_markets <- clean_heritage[c(1,14:16,23)]
open_markets$mean <- rowMeans(subset(open_markets, select = c(2:4)), na.rm = TRUE)
p4 <- open_markets%>%
ggplot(aes(x=mean, y=`GDP (Billions, PPP)`)) +
geom_point()+
geom_smooth() +
ggtitle("Open Markets and GDP",
subtitle = "average of trade freedom, investment freedom,
financial freedom")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
grid.arrange(p1,p2,p3,p4, ncol = 2)
p1_cor <- cor(rule_of_law$mean, rule_of_law$`GDP (Billions, PPP)`)
p2_cor <- cor(government_size$mean, government_size$`GDP (Billions, PPP)`)
p3_cor <- cor(regulatory_efficiency$mean, regulatory_efficiency$`GDP (Billions, PPP)`)
p4_cor <-cor(open_markets$mean, open_markets$`GDP (Billions, PPP)`)
pillar <- c('Rule of Law', 'Government Size', 'Regulatory Efficiency','Open Markets')
GDP_cor <- c(p1_cor,p2_cor,p3_cor,p4_cor)
p_cor_df <- data.frame(pillar, GDP_cor)
p_cor_df
## pillar GDP_cor
## 1 Rule of Law 0.20378922
## 2 Government Size -0.03344900
## 3 Regulatory Efficiency 0.09153389
## 4 Open Markets 0.04125753
The most linear relationship shown in this set of graphs is the first plot. Here, it can be inferred that the most influential pillar on total GDP is Rule of Law (correlation coefficient = .204). This means that if a country wants to be prosperous, they should first focus their attention on establishing property rights, government integrity, and judicial effectiveness.
rule_of_law <- clean_heritage[c(1,5:7,23,26)]
rule_of_law$mean <- rowMeans(subset(rule_of_law, select = c(2:4)), na.rm = TRUE)
pc1 <- rule_of_law %>%
ggplot(aes(x=mean, y=`GDP per Capita (PPP)`)) +
geom_point() +
geom_smooth() +
ggtitle("Rule of Law and GDP per Capita",
subtitle = "average of property rights, government integrity,
judicial effectiveness")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
government_size <- clean_heritage[c(1,8:10,23,26)]
government_size$mean <- rowMeans(subset(government_size, select = c(2:4)), na.rm = TRUE)
pc2 <- government_size%>%
ggplot(aes(x=mean, y=`GDP per Capita (PPP)`)) +
geom_point()+
geom_smooth() +
ggtitle("Government Size and GDP
per Capita",
subtitle = "average of government spending, tax burden,
fiscal health")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
regulatory_efficiency <- clean_heritage[c(1,11:13,23,26)]
regulatory_efficiency$mean <- rowMeans(subset(regulatory_efficiency, select = c(2:4)), na.rm = TRUE)
pc3 <- regulatory_efficiency%>%
ggplot(aes(x=mean, y=`GDP per Capita (PPP)`)) +
geom_point()+
geom_smooth() +
ggtitle("Regulatory Efficiency and
GDP per Capita",
subtitle = "average of business freedom, labor freedom,
monetary freedom")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
open_markets <- clean_heritage[c(1,14:16,23,26)]
open_markets$mean <- rowMeans(subset(open_markets, select = c(2:4)), na.rm = TRUE)
pc4 <- open_markets%>%
ggplot(aes(x=mean, y=`GDP per Capita (PPP)`)) +
geom_point()+
geom_smooth() +
ggtitle("Open Markets and GDP
per Capita",
subtitle = "average of trade freedom, investment freedom,
financial freedom")+
scale_y_continuous(labels = scales::dollar, trans = 'log1p')
grid.arrange(pc1,pc2,pc3,pc4, ncol = 2)
pc1_cor <- cor(rule_of_law$mean, rule_of_law$`GDP per Capita (PPP)`)
pc2_cor <- cor(government_size$mean, government_size$`GDP per Capita (PPP)`)
pc3_cor <- cor(regulatory_efficiency$mean, regulatory_efficiency$`GDP per Capita (PPP)`)
pc4_cor <-cor(open_markets$mean, open_markets$`GDP per Capita (PPP)`)
Pillar <- c('Rule of Law', 'Government Size', 'Regulatory Efficiency','Open Markets')
GDP_capita_Cor <- c(pc1_cor,pc2_cor,pc3_cor,pc4_cor)
pc_cor_df <- data.frame(Pillar, GDP_capita_Cor)
pc_cor_df
## Pillar GDP_capita_Cor
## 1 Rule of Law 0.69855633
## 2 Government Size 0.04065282
## 3 Regulatory Efficiency 0.45788103
## 4 Open Markets 0.51166328
Unlike the first set of four plots measuring overall GDP, when comparing GDP per Capita with the four pillars of Economic Freedom, each graph is much more linear. This means that if a country can increase their scores in these four pillars, the citizens will likely experience an increase in their wealth. Again, the most influential pillar is Rule of Law. However, here, the correltion coefficient is narly .7. This conveys that the establishment of Rule of Law is more than three times as impactful on an individual’s GDP than it is on a nation’s.
To conclude our analysis, we will consider a variable that is not included in the scoring of Economic Freedom, but one in which I am interested in understanding the effect it has on the economic score a country receives.
This variable is a nation’s Tax Burden as a percentage of GDP.
tax_burden <- clean_heritage[c(1,2,4,20)]
tax_burden%>%
ggplot(aes(x=`Tax Burden % of GDP`, y=`2017 Score`)) +
geom_point()+
geom_smooth() +
ggtitle("Figure 8: Tax burden and Economic Score")
This output is very intersting because the shape is not linear. The curvature indicates that initially, as the tax burden increases the score does so, as well. But, as you continue across the x-axis, the Economic Freedom Score begins to decline. This presents meaningful information, demonstrating the importance of finding the right taxing percentage. Too high of a tax rate will have negative effects on the economy, but generating some tax revenue is necessary to a country’s economic health.
The research question we addressed in our analysis is, “what factors play the biggest role in determining a country’s economic well-being?” To do this, we inspected many different correlations provided by the data the Heritage Foundation collected. This dataset included many different, important variables that relate to the world’s economies, but we limited our analysis to only those that would provide the most relevant information on what creates a flourishing economy.
To understand just what factors play the largest roles on economies, we plotted many graphs and studied numerous correlations. We first began our analysis with the correlation between GDP and Economic Freedom Score, then comparing this result with GDP per Capita vs Score. We found that there is a much stronger relationship between GDP per Capita and a nation’s Economic Freedom Score. Next, we calculated the four pillars of economic freedom as described by the Heritage Foundation, and evaluated their impact on both GDP and GDP per Capita. Again, we see that GDP per Capita is much more responsive to these variables. It is evident through both sets of results that the most critical pillar for a country’s economy is Rule of Law. Finally, we looked at the interesting response of economic scores when the tax burden is increased. The present curvature suggests that if the tax rate is too high, economic scores will be negatively impacted.
In conclusion, we now know how the regions compare to one another based on Economic Freedom Score and what elements are most crucial to economies around the world. The biggest take away from our exploration is the importance of Rule of Law. The political environment around the world, especially now, is not always conducive to establishing this necessary component, but that does not diminish its importance. Not only does the data convey how paramount this pillar is, but from a purely fundamental standpoint it is one of the most just principles to be integrated into a nation’s political system.
To continue this research, we can study the effects of the establishment of Rule of Law over time in different areas of the world. We can track the countries’ progress and see just how improving Rule of Law has influenced the economy. This will show if the improvement of this economic pillar significantly effected the nation and improved its standing among fellow countries.