Taxes, Health, GDP: Understanding the Connection
1. Introduction
1.1 Overview and Motivations
Health has become a major concern in the past years, with lots of new resources and information available nowadays. More than ever, we are confronted everyday with choices to be made whether buying drinks or buying food for lunch. Furthermore, the variety of this type of product has exploded and has been growing for many years and this is not going to stop in a society that pushes consumption and opulence. We have a rough idea of what is “healthy” and what is “unhealthy”, but can we see patterns across countries?
As far as our personal motivations behind this research, is our shared interest in health from various aspects such as sports performance or just having a healthy lifestyle to better our lives. This merged with our current curriculum in HEC makes our team motivated to find economic links to health in various sectors.
Past papers have been written linking an individual’s health to his personal wealth, and the possible correlation these two have onto each other:
https://www.sciencedirect.com/science/article/pii/S0167629603000596 https://core.ac.uk/download/pdf/158607349.pdf
With this project we want to focus on the efforts carried by governments, the policies countries have and the impact these have on the individual. One would think that the more prosperous a country, the healthier than said country would be. This however does not seem to be the case, the United States serves as an example of this contradiction: obesity rates just like their GDP are higher than ever. We want to know what policies have an effect on the wellbeing of the individuals as well as understanding the aftermath of such political measures.
2. Research questions
1. How do taxes on sweet beverages impact the overall health of a country? Is it effective?
2. How do tobacco taxes affect the health of a country? Is taxation on tobacco prolific in correcting consumer behavior?
3. How do financial inequalities compare to health across countries? What are the social and economic consequences?
3. Data Wrangling
3.1 Where did we find our data
To have our base data, we had to go on different website to create one with all the information that we wanted. The main websites where we find what we wanted are :
- “Our World in Data” : https://ourworldindata.org
- The “World Health Organization” : https://www.who.int/data
- “The World Bank” : https://data.worldbank.org/
- The “World Health Organization: FCTC”https://untobaccocontrol.org/
3.2 Generic Data
In the pursuit of addressing various research questions, a comprehensive collection of generic data has been meticulously curated. This dataset serves as the foundational bedrock upon which the analytical framework is constructed. The data, carefully gathered, encapsulates a diverse spectrum of information, poised to unravel insights and patterns relevant to the research queries at hand. Through leveraging this rich repository of information, the exploration and subsequent analysis aim to extract meaningful narratives, uncover correlations, and ultimately contribute to a nuanced understanding of the underlying phenomena. The robustness of the collected data underscores its significance as a strategic asset in navigating the complex terrain of data science, offering a conduit to derive actionable intelligence and illuminate the intricacies inherent in the research landscape.
3.2.1 Life Expectancy
As we will be working with health data and trying to establish links between various factors and good health, life expectancy at birth (independently of infant mortality) is an essential indicator, as this article shows. However, this article also warns us about the limitations of interpreting this measure, so it will have to be coupled with other data to enable it to be an objective health indicator. We found a raw dataset, where both male and female were separated. Our analysis will be independent of the sex, so we required only one column representing the whole population. We had to use the mutate function to calculate the average life expectancy independently of the sex of the individual. Then, we removed the unnecessary columns to keep only the country, the period and the life expectancy for each observations. Finally, we wanted to check whether the quantity of data was sufficient, both in terms of the number of years available and the number of countries included. We used the function dfSummary of the package summarytools to get a good overview of our data. We therefore have data for 255 countries/regions over a 71-year period from 1950 to 2021.
| Code | Period | Life_Expectancy |
|---|---|---|
| AFG | 1950 | 27.8 |
Code
# Raw Data Importation
df_Life_Expectancy_Final <- read.csv(here::here("Data/Life_Expectancy_Final.csv"))
#3. Clean the data of the Life expectancy (df_Life_Expectancy_Final)
#3.1 Keep only the necessary columns
df_Life_Expectancy_Final <- df_Life_Expectancy_Final[,c(1,3,4,5)]
#3.2 Suppress the sex distinction
df_Life_Expectancy_Final <- df_Life_Expectancy_Final %>%
mutate(final_value = (df_Life_Expectancy_Final$Life.expectancy...Sex..male...Age..at.birth...Variant..estimates + df_Life_Expectancy_Final$Life.expectancy...Sex..female...Age..at.birth...Variant..estimates) / 2)
df_Life_Expectancy_Final <- df_Life_Expectancy_Final[,c(1,2,5)]
#3.3 Rename the columns
colnames(df_Life_Expectancy_Final)[c(1,2,3)] <- c("Country","Period", "Life_Expectancy")
#3.4 change value of life expectancy to numerical ones
df_Life_Expectancy_Final[, 3] <- as.numeric(df_Life_Expectancy_Final[, 3])
#3.5 Suppress potential missing values in our data
df_Life_Expectancy_Final <- na.omit(df_Life_Expectancy_Final)
#3.6 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Life_Expectancy_Final)
print(df_summary)3.2.2 Population
For various calculations, we will need to know the population of a country for a specific year. Additionally, we may choose to filter our data based on population to mitigate the impact of certain countries that are clear outliers due to their unique characteristics and very low population. We found a raw dataset that give us data about country name, its population and the year of the observation. We had to change the separation marks for the importation because of the characteristic of the .css files, using the parameter ” sep= “;” ” in the read() function so the file can be read correctly. To clean it, we first put all the years in the same column and all the population in another one with pivot_longer() function. The year, for some reason, had an X in front of them, so we had to remove it with the function gather(). We also had to convert the population to a numeric value. Finally we also removed the possible missing values. To check the state of our data we also used the dfSummary() function. We therefore have data for … countries/regions over a …-year period from … to ….
| Code | Period | Population |
|---|---|---|
| ABW | 1960 | 54608 |
Code
# Raw Data Importation
df_PopByYear <- read.csv(here::here("Data/Pop.csv"))
#1. df_PopByYear
#1.1 Keep only the necessary columns
df_PopByYear <- df_PopByYear[, -c(2,3,4)]
#1.2 Pivoting the data to get the year as row value in a column named Period
#1.2.1 Use the gather function to pivot the data as long
df_PopByYear <- gather(df_PopByYear, key = "Period", value = "Population", -Country.Name)
#1.2.2 Removing the undesired character in the year
df_PopByYear$Period <- gsub("X", "", df_PopByYear$Period)
#1.2.3 Removing potential missing value
df_PopByYear <- na.omit(df_PopByYear)
#1.2.4 Convert the population & Period as numeric number
df_PopByYear$Population <- as.numeric(df_PopByYear$Population, na.rm = TRUE)
df_PopByYear$Period <- as.numeric(df_PopByYear$Period, na.rm = TRUE)
#1.2.5 Rename the name of the column Country.Name to Country
colnames(df_PopByYear)[1] <- "Country"
#1.2.6 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_PopByYear)
print(df_summary)3.2.3 GDP
The GDP is an indispensable economic measure, being correlated both with the health of a population and with inequality within that same population. It would have been impossible not to include it in our research. Despite its imperfections, this indicator has the advantage of providing precise data for numerous countries and geographic areas, as well as across a broad temporal spectrum. In the realm of economic analysis and data science, GDP serves as a valuable metric due to its ability to offer insights into the economic well-being of a region and its population. Its widespread availability and historical data make it a robust tool for examining trends and patterns over time. While acknowledging its limitations, the inclusion of GDP in our research allows for a comprehensive understanding of the socio-economic landscape. we found a raw dataset that show a wide amount of GDP value by country and by year of observation. The cleaning step are almost the same as population raw data set in point 3.2.2
| Code | Period | GDP_by_head | |
|---|---|---|---|
| 2 | AFE | 1960 | 161.64 |
Code
# Raw Data Importation
df_GDP <- read.csv(here::here("Data/GDP_Final.csv"), sep=";")
#2. df_GDP
#2.1 Keep only the necessary columns
df_GDP <- df_GDP[,-c(2:4)]
#2.2 Rename the column country
colnames(df_GDP)[1] <- "Country"
#2.3 Use the gather function to pivot the data as long to remove the year as column
df_GDP <- gather(df_GDP, key = "Period", value = "GDP_by_head", -Country)
#2.4 Put the value of GDB by head as numeric ones
df_GDP$GDP_by_head <- as.numeric(gsub(",", ".", df_GDP$GDP_by_head))
#2.5 Removing potential missing value
df_GDP <- na.omit(df_GDP)
#2.6 Use the gsub function to remove the X before the year in the column period
df_GDP$Period <- gsub("X", "", df_GDP$Period)
#2.7 Use the gsub function to remove the X before the year in the column period
df_GDP$GDP_by_head <- round(df_GDP$GDP_by_head, digits = 0)
#2.8 Suppress potential missing values in our data
df_GDP$Period <- as.numeric(df_GDP$Period, na.rm = TRUE)
#2.9 Change Period as numeric
df_GDP <- na.omit(df_GDP)
#2.10 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_GDP)
print(df_summary)3.2.4 Health expenditure
Corriger selon data import de Fanny
As one can easily imagine, the health status of a country can be strongly linked to its level of health expenditure, our assumption was confirmed by this study. We have managed to obtain data that indicates the level of health expenditure as a percentage of the Gross Domestic Product (GDP), providing objectivity to this information and facilitating comparisons between countries. Moreover, we have observations spanning an extensive duration and covering a substantial number of countries.
| Code | Period | Health_Expenditure | |
|---|---|---|---|
| 10642 | AFE | 2000 | 5.666276 |
Code
# Raw Data Importation
df_Health_Expense_By_Country <- read.csv(here::here("Data/Health_Expense_By_Country.csv"),sep=";")
#5. df_Health_Expense
#5.1 Keep only the necessary columns
df_Health_Expense_By_Country <- df_Health_Expense_By_Country[,-c(2:4)]
#5.2 Rename the column country
colnames(df_Health_Expense_By_Country)[1] <- "Country"
#5.3 Use the gather function to pivot the data as long to remove the year as column
df_Health_Expense_By_Country <- gather(df_Health_Expense_By_Country, key = "Period", value = "Health_Expenditure", -Country)
#5.4 Use the gsub function to remove the X before the year in the column period
df_Health_Expense_By_Country$Period <- gsub("X", "", df_Health_Expense_By_Country$Period)
#5.5 Put the value of Health expense as numeric ones
df_Health_Expense_By_Country$Health_Expenditure <- as.numeric(gsub(",", ".", df_Health_Expense_By_Country$Health_Expenditure))
#5.6 Removing potential missing value
df_Health_Expense_By_Country <- subset(df_Health_Expense_By_Country, !is.na(Health_Expenditure))
#5.7 Change the Period as numeric
df_Health_Expense_By_Country$Period <- as.numeric(df_Health_Expense_By_Country$Period, na.rm = TRUE)
#5.8 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Health_Expense_By_Country)
print(df_summary)3.2.6 Rate of the infantile mortality
The infantile mortality can be linked to the health of a country’s population, it’s what we funded in this article. This article is trying to link various health factor(for example nutrition) to the child mortality. As before, we selected the columns of interest and rename them, change our value column as a numerical one and remove potential NA values.
| Code | Period | Infantile_Mortality |
|---|---|---|
| AFG | 1957 | 37.59054 |
Code
# Raw Data Importation
df_Child_Mortality_Rate <- read.csv(here::here("Data/Child-mortality-rate.csv"))
#4. df_Child_Mortality_Rate
#4.1 Keep only the necessary columns
df_Child_Mortality_Rate <- df_Child_Mortality_Rate[,c(1,3,4)]
#4.2 Rename the columns
colnames(df_Child_Mortality_Rate)[c(1,2,3)] <- c("Country", "Period", "Infantile_Mortality")
#4.3 change value of life expectancy to numerical ones
df_Child_Mortality_Rate[, 3] <- lapply(df_Child_Mortality_Rate[, 3], as.numeric)
#4.4 Suppress potential missing values in our data
df_Child_Mortality_Rate <- subset(df_Child_Mortality_Rate, !is.na(df_Child_Mortality_Rate))
#4.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Child_Mortality_Rate)
print(df_summary)3.2.7 Probability of dying from a Non-Communicable disease (NCD)
The Non-Communicable Diseases (NCDs) such as respiratory or cardiovascular one, prove to be a particularly interesting health indicator, as demonstrated by this WHO article. Therefore, we chose to include them to provide yet another perspective on health in addition to data such as life expectancy, which remains relatively incomplete, as previously explained. We successfully found a comprehensive raw dataset containing information on the probability of dying from a Non-Communicable Disease per country and per year. Our data is stratified by gender, but since our analysis does not focus on this dimension, we decided to retain the average value. Subsequently, we performed our usual data cleaning operations.
| Code | Period | Prob_Dying_NCD |
|---|---|---|
| CHL | 2019 | 10.04 |
Code
# Raw Data Importation
df_NCD_mortality_rate <- read.csv(here::here("Data/Age-standardized_NCD_mortality_rate.csv"))
#4. Clean the data of the probability of dying from a Non-Communicable disease [NCD] (df_Proba_Of_Dying_From_NCD)
#4.1 Keep only the necessary columns
df_Proba_Of_Dying_From_NCD <- df_Proba_Of_Dying_From_NCD[,c(8,10,13,24)]
#4.2 Keep only the necessary rows (both sexes,to remove the sex distinction)
df_Proba_Of_Dying_From_NCD <- df_Proba_Of_Dying_From_NCD[df_Proba_Of_Dying_From_NCD$Dim1 == "Both sexes",]
df_Proba_Of_Dying_From_NCD <- df_Proba_Of_Dying_From_NCD[,c(1,2,4)]
#4.3 change value of diabetes death rate to numerical ones
df_Proba_Of_Dying_From_NCD[, 3] <- lapply(df_Proba_Of_Dying_From_NCD[, 3], as.numeric)
#4.4 Suppress potential missing values in our data
df_Proba_Of_Dying_From_NCD <- subset(df_Proba_Of_Dying_From_NCD, !is.na(df_Proba_Of_Dying_From_NCD))
#4.5 Rename the columns
colnames(df_Proba_Of_Dying_From_NCD)[c(1,2,3)] <- c("Country", "Period", "Prob_Dying_NCD")3.2.8 The merged generic data dataset
Finally we selected every dataset containing generic data and merged them all together to have our final base dataset. Since we named every column the same way, the command merge did what we wanted. Some final changes have been made like modifying the values of the death due to obesity and high blood pressure in rates instead of absolute value. Also, we removed the NA values that were present. These values came from the fact that GDP or Health expenditure data wasn’t collected every year in some countries. We also needed to calculate 2 new variables, as all of our death rate is in ‰ we transformed the absolute value of death number for High blood Pressure and obesity to rate value ‰. We will use this dataset as a reference for our research questions, we will compute local merge to addition the required data to our analysis and EDA, this strategy has been implemented to guarantee that we don’t loose information because of the different range of date and country our our specific data. To present our data dynamically we choose the function datatable() from the package DT, to allow readers to browse our generic data.
Code
#####################################
## Merging the dataframes together ##
#####################################
#8. Merging the dataframe together
list_df <- list(df_GDP, df_Life_Expectancy_Final, df_Child_Mortality_Rate, df_Health_Expense_By_Country, df_Proba_Of_Dying_From_NCD, df_Share_of_population_with_cancer)
df_merged <- Reduce(function(x, y) merge(x, y, by = c("Country", "Period"), all = TRUE), list_df)
df_merged <- merge(x=df_merged,y=df_PopByYear,by=c("Country","Period"))
#9. Adding a primary key
df_merged[10] <- paste(df_merged$Country, df_merged$Period, sep = ".")
colnames(df_merged)[10] <- "Country.Period"
#10. Remove the rows where there's NA
df_merged <- na.omit(df_merged)
#11. Creating 4 classes based on the GPD level by country
df_merged <- df_merged[order(df_merged$Period, df_merged$GDP_by_head), ]
df_merged <- df_merged %>%
group_by(Period) %>%
mutate(Class_GDP = ntile(GDP_by_head, 4))
df_merged <- df_merged %>%
mutate(Class_GDP = case_when(
Class_GDP == 1 ~ "Low Income",
Class_GDP == 2 ~ "Medium-Low Income",
Class_GDP == 3 ~ "Medium-High Income",
Class_GDP == 4 ~ "High Income"
))
#12. Reorder df_merged
df_merged <- df_merged %>%
select(1,2,10,9,3,11,4,5,6,7,8)
#13. Checking any issues
summary(df_merged)
df_merged$Period <- as.numeric(df_merged$Period)
summary(df_merged)
#14 Create a dynamic table to present our data
#14.1 Round all our value for aesthetic purpose of presentation
df_merge <- round_numeric_columns(df=df_merge)
#14.2 Use the function datatable to create a dynamic table of data
DynamicDataTableGenericData <- datatable(df_merge, options = list(pageLength = 5))3.3 Specific data for question 1
3.3.1 Taxes about sweetened beverages
For our first research question, we needed the data of countries which have implemented or not taxes on sweetened beverages. We found a raw dataset set which indicates whether a country has implemented taxes or not. We have data for 3 different years : 2017, 2019 and 2021. But we also added the additional year of 2013 as the first implementation of taxes on sweetened beverages started in 2014. The year 2013 adds value to our regression as no country has yet implemented any kind of tax.To do so, we used a for loop too had for each unique country in our data set the value 0 for the tax for the year 2013. Then, we had to filter our data to remove missing values, such as “No response” or “Don’t know”. We also change our value of taxes from “Yes” and “No” to boolean values such as 1 for “Yes” and 0 for other values (that is all “No”). Our work was not finished, we wanted to use the package map to display interactive maps, and match our country name to the country name of the package map. This is because our raw data didn’t use the normalized names. We found it unfortunate to have a relatively small dataset in terms of the temporal dimension. However, given that this tax is relatively new, we had to settle for what was available. In the clean dataset, we can observe 179 country and as we discuss have only 4 times observations which is 2013, 2017, 2019, 2021. The spread of our data is going to constraint our future analysis for question 1. So if we wanted to analyse data for question 1 we will absolutely need value for those years.
| Code | Period | Tax_Sweetened_beverages |
|---|---|---|
| DZA | 2021 | 0 |
Code
# Raw Data Importation
df_Tax_Sweetened_Beverages<- read.csv(here::here("Data/Existence_Of_tax_on_sugar-sweetened_beverages.csv"))
#6. df_Tax_Sweetened_Beverages
#6.1 Keep only the necessary columns
df_Tax_Sweetened_Beverages <- df_Tax_Sweetened_Beverages[,c(8,10,30)]
#6.2 Keep only the necessary rows, Filtering the data that contain the value "Don't know" or "No response"
df_intermediate <- filter(df_Tax_Sweetened_Beverages,df_Tax_Sweetened_Beverages$Value =="Don't know"| df_Tax_Sweetened_Beverages$Value =="No response")
df_Tax_Sweetened_Beverages <- anti_join(df_Tax_Sweetened_Beverages, df_intermediate, by = "Location")
#6.3 Add the values for the year 2013
#6.3.1 Create a vector that contain each country present in the data
unique_vect <- unique(df_Tax_Sweetened_Beverages$Location)
#6.3.2 Loop to add the tax on sweetened beverage for each country
for (i in unique_vect) {
nouvelle_ligne <- data.frame(
Location = i,
Period = 2013,
Value = "No")
df_Tax_Sweetened_Beverages <- rbind(df_Tax_Sweetened_Beverages, nouvelle_ligne)
}
#6.4 Rename the columns
colnames(df_Tax_Sweetened_Beverages)[c(1,2,3)] <- c("Country", "Period", "Tax_Sweetened_beverages")
#6.5 Put boolean variables (if there's a tax -> 1 , if not -> 0)
df_Tax_Sweetened_Beverages$Tax_Sweetened_beverages <- ifelse(df_Tax_Sweetened_Beverages$Tax_Sweetened_beverages == "Yes", 1, 0)
#6.6 Change the country name to match the package map name's country
df_Tax_Sweetened_Beverages <- df_Tax_Sweetened_Beverages %>%
mutate(
Country = case_when(
Country == "Russian Federation" ~ "Russia",
Country == "Bolivia (Plurinational State of)" ~ "Bolivia",
Country == "Venezuela (Bolivarian Republic of)" ~ "Venezuela",
Country == "United Republic of Tanzania" ~ "Tanzania",
Country == "United States of America" ~ "USA",
Country == "United Kingdom of Great Britain and Northern Ireland" ~ "UK:Great Britain",
Country == "Türkiye" ~ "Turkey",
Country == "Democratic People's Republic of Korea" ~ "North Korea",
Country == "Republic of Korea" ~ "South Korea",
Country == "Côte d’Ivoire" ~ "Ivory Coast",
Country == "Viet Nam" ~ "Vietnam",
Country == "Iran (Islamic Republic of)" ~ "Iran",
Country == "Czechia" ~ "Czech Republic",
Country == "Republic of Moldova" ~ "Moldova",
TRUE ~ Country
)
)
#6.7 Removing potential missing value
df_Tax_Sweetened_Beverages <- subset(df_Tax_Sweetened_Beverages, !is.na(df_Tax_Sweetened_Beverages))
#6.8 Change the Period as numeric
df_Tax_Sweetened_Beverages$Period <- as.numeric(df_Tax_Sweetened_Beverages$Period, na.rm = TRUE)
#6.9 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Tax_Sweetened_Beverages)
print(df_summary)3.3.2 Number of deaths by risk factor
We were interested in two main risk factors for which we found literature indicating a serious link with the consumption of sugar or, more precisely, sweetened drinks. The first factor we were interested in was related to death rates from high blood pressure. The second was obesity rates. We wanted to have these two factors over several periods and for a wide range of geographical areas. We managed to find a raw dataset that contained numerous risk factors for several years and in many countries. Our main concern was that our data was in absolute numbers of deaths. So we would need the population of each country and also by date to be able to calculate a mortality rate and not bias our results because countries have different population sizes. To clean up the data of interest, we eliminated the columns that did not provide any information for our research questions. We then renamed the columns we had selected, with the colnames function. Then, by adding two operations, we ensured that our data were numerical values (necessary for future calculations) and were rounded to the nearest unit. We also made sure that there were no missing values, to drop this potential missing, we use the is.na() function. Finally, we wanted to check whether the quantity of data was sufficient, both in terms of the number of years available and the number of countries included. We used the function dfSummary of the package summarytools to get a good overview of our data. We therefore have data for 228 countries/regions over a 29-year period from 1990 to 2019.
| Code | Period | Death_Due_To_High_Blood_Pressure | Death_Due_To_Obesity |
|---|---|---|---|
| AFG | 1990 | 25633.13 | 9517.873 |
Code
# Raw Data Importation
df_Number_of_deaths_by_risk_factor <- read.csv(here::here("Data/Number_of_deaths_by_risk_factor.csv"))
#1. df_Number_of_deaths_by_risk_factor
#1. Clean the data of the number of deaths by risk factor (df_Number_of_deaths_by_risk_factor)
#1.1 Keep only the necessary columns
df_Number_of_deaths_by_risk_factor <- df_Number_of_deaths_by_risk_factor[,c(1,3,4,20)]
#1.2 Rename the columns
colnames(df_Number_of_deaths_by_risk_factor)[c(1,2,3,4)] <- c("Country", "Period", "Death_Due_To_High_Blood_Pressure","Death_Due_To_Obesity")
#1.3 Removing potential missing value
df_Number_of_deaths_by_risk_factor <- subset(df_Number_of_deaths_by_risk_factor, !is.na(df_Number_of_deaths_by_risk_factor))
#1.4 Change the Period as numeric
df_Number_of_deaths_by_risk_factor$Period <- as.numeric(df_Number_of_deaths_by_risk_factor$Period, na.rm = TRUE)
#1.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Number_of_deaths_by_risk_factor)
print(df_summary)3.3.3 Death rate from diabetes, malnutrition and liver disease
We wanted to have a rate encompassing several diseases linked with a poor diet and bad eating habits. First we get interested by diabetes, we found in this meta-analysis that consumption of sweetened beverages was closely related to the probability of contracting type 2 diabetes. We found a raw dataset that contain the death rate from diabetes in ‰. Firstly, we started by dropping column that wasn’t interesting for us, as always we wanted to keep data about Country,Year of the obesrvation and in this case, the death rate from diabetes. Finally, we used the function dfSummary of the package summarytools to get a good overview of our data. We therefore have data for 228 countries/regions over a 29-year period from 1990 to 2019
| Code | Period | Death_Diabetes |
|---|---|---|
| AFG | 1990 | 30.93 |
Code
# Raw Data Importation
df_Death_rate_from_diabetes <- read.csv(here::here("Data/Death-rate-from-diabetes.csv"))
#2. df_Death_rate_from_diabetes
#2.1 Keep only the necessary columns
df_Death_rate_from_diabetes <- df_Death_rate_from_diabetes[,c(1,3,4)]
#2.2 Rename the columns
colnames(df_Death_rate_from_diabetes)[c(1,2,3)] <- c("Country", "Period", "Death_Diabetes")
#2.3 Removing potential missing value
df_Death_rate_from_diabetes <- subset(df_Death_rate_from_diabetes, !is.na(df_Death_rate_from_diabetes))
#2.4 Change the Period as numeric
df_Death_rate_from_diabetes$Period <- as.numeric(df_Death_rate_from_diabetes$Period, na.rm = TRUE)
#2.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Death_rate_from_diabetes)
print(df_summary)We came across “amusing” articles that showed in certain countries, mostly impoverished ones, the price of Coca-Cola or other sugary beverages could be cheaper than water. This situation might lead a population with limited means to consume sugary drinks and consequently suffer from malnutrition out of necessity. This is why data on malnutrition appeared to be of significant interest in our research. We managed to find a raw dataset that illustrates the mortality rate in ‰ due to malnutrition by country and year.
| Code | Period | Death_Malnutrition |
|---|---|---|
| AFG | 1990 | 11.04 |
Code
# Raw Data Importation
df_Malnutrition_death_rate <- read.csv(here::here("Data/Malnutrition-death-rates.csv"))
#3. df_Malnutrition_death_rate
#3.1 Keep only the necessary columns
df_Malnutrition_death_rate <- df_Malnutrition_death_rate[,c(1,3,4)]
#3.2 Rename the columns
colnames(df_Malnutrition_death_rate)[c(1,2,3)] <- c("Country", "Period", "Death_Malnutrition")
#3.3 Removing potential missing value
df_Malnutrition_death_rate <- subset(df_Malnutrition_death_rate, !is.na(df_Malnutrition_death_rate))
#3.4 Change the Period as numeric
df_Malnutrition_death_rate$Period <- as.numeric(df_Malnutrition_death_rate$Period, na.rm = TRUE)
#3.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Malnutrition_death_rate)
print(df_summary)Third and last interest data was the liver disease, we saw in a fascinating meta-analysis that the consumption of sweetened beverages could lead to serious liver disease and more precisely on fatty liver disease. So with these evidence of the existing link we can’t let out the liver disease data. We found a raw dataset that included countries data, year and mortality rate due to liver disease in ‰. This data was pretty clean and we only had to perform the same cleaning operations as before.
| Code | Period | Death_Liver_disease |
|---|---|---|
| AFG | 1990 | 2673 |
Code
# Raw Data Importation
df_Liver_Disease_death_rate <- read.csv(here::here("Data/Deaths-from-liver-disease.csv"))
#4. df_Liver_Disease_death_rate
#4.1 Keep only the necessary columns
df_Liver_Disease_death_rate <- df_Liver_Disease_death_rate[,c(1,3,4)]
#4.2 Rename the columns
colnames(df_Liver_Disease_death_rate)[c(1,2,3)] <- c("Country", "Period", "Death_Liver_disease")
#4.3 Removing potential missing value
df_Liver_Disease_death_rate <- subset(df_Liver_Disease_death_rate, !is.na(df_Liver_Disease_death_rate))
#4.4 Change the Period as numeric
df_Liver_Disease_death_rate$Period <- as.numeric(df_Liver_Disease_death_rate$Period, na.rm = TRUE)
#4.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Liver_Disease_death_rate)
print(df_summary)3.3.4 Dataset for question 1 merged
For question 1 EDA and analysis, we merged our generic dataframe to all this new one. We compute some small operation to recalculate some column to get value of death in rate and not as absolute value, using the population data. Then we recreate a dynamic table to show our results
Code
#7. merging df_merged and these new dataframe
list_dfQ1 <- list(df_Number_of_deaths_by_risk_factor, df_Death_rate_from_diabetes, df_Malnutrition_death_rate, df_Liver_Disease_death_rate, df_Death_rate_from_digestive_diseases, df_Tax_Sweetened_Beverages)
df_mergedQ1 <- Reduce(function(x, y) merge(x, y, by = c("Country", "Period"), all = TRUE), list_dfQ1)
df_mergedQ1 <- merge(x=df_merged,y=df_mergedQ1,by=c("Country","Period"))
#8. remove NA value
df_mergedQ1 <- na.omit(df_mergedQ1)
#9. modify columns to have a rate rather than an absolute value for high blood pressure death and obesity death
df_mergedQ1 <- df_mergedQ1 %>%
mutate(
Death_Obesity = (Death_Due_To_Obesity/as.numeric(df_mergedQ1$Population)*100000),
Death_HBP = (Death_Due_To_High_Blood_Pressure/as.numeric(df_mergedQ1$Population)*100000)
) %>%
select(-Death_Due_To_Obesity, -Death_Due_To_High_Blood_Pressure)
#10 Create a dynamic table to present our data
#10.1 Round all our value for aesthetic purpose of presentation
df_mergedQ1 <- round_numeric_columns(df=df_mergedQ1)
#10.2 Use the function datatable to create a dynamic table of data
DynamicDataTableDataQ1 <- datatable(df_mergedQ1, options = list(pageLength = 5))3.4 Specific data for question 2
3.4.1 Tobacco consumption
For our second research question we needed the data concerning the consumption of tobacco by country and its evolution by year. The raw dataset was pretty clean, we only had to remove the irrelevant columns, renames our column names, change our number of tobacco consumption to numerical value (note that here the value is in % of population) and finally discard missing values.
| Code | Period | Tobacco_Consumption |
|---|---|---|
| AFG | 2000 | 36.9 |
Code
# Raw Data Importation
df_Tobacco_Consumption <- read.csv(here::here("Data/prevalence-of-tobacco-use-sdgs.csv"))
#3. df_Tobacco_Consumption
# 3.1 Keep only necessary columns
df_Tobacco_Consumption <- df_Tobacco_Consumption[,-c(2)]
# 3.2 Rename the columns
colnames(df_Tobacco_Consumption)[c(1,2,3)] <- c("Country", "Period","Tobacco_Consumption")
# 3.3 Removing potential missing value
df_Tobacco_Consumption <- subset(df_Tobacco_Consumption, !is.na(df_Tobacco_Consumption))
# 3.4 Change the Period as numeric
df_Tobacco_Consumption$Period <- as.numeric(df_Tobacco_Consumption$Period, na.rm = TRUE)
# 3.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Tobacco_Consumption)
print(df_summary)3.4.2 Death rate due to tobacco
We also required to know tobacco’s death toll in the world. This raw dataset was also pretty clean, we computed the same operation as before, removing one column and renaming it to match our needs.
| Code | Period | Percentage_Death_From_Smoking |
|---|---|---|
| AFG | 1990 | 4.018696 |
Code
# Raw Data Importation
df_Death_From_Smoking_By_Country <- read.csv(here::here("Data/share-deaths-smoking.csv"))
#1. df_Death_From_Smoking_By_Country
# 1.1 Keep only necessary columns
df_Death_From_Smoking_By_Country <- df_Death_From_Smoking_By_Country[,-c(2)]
# 1.2 Rename the columns
colnames(df_Death_From_Smoking_By_Country)[c(1,2,3)] <- c("Country", "Period", "Percentage_Death_From_Smoking")
# 1.3 Removing potential missing value
df_Tax_Sweetened_Beverages <- subset(df_Tax_Sweetened_Beverages, !is.na(df_Tax_Sweetened_Beverages))
# 1.4 Change the Period as numeric
df_Death_From_Smoking_By_Country$Period <- as.numeric(df_Death_From_Smoking_By_Country$Period, na.rm = TRUE)
# 1.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Death_From_Smoking_By_Country)
print(df_summary)3.4.3 Taxes on tobacco
Our question relies mainly on the tax’s potential effect on our different factors. So we also needed the data regarding tax on tobacco products. In the end we have a column containing the tax force by country. A number going from 1 to 5 which indicates the importance of this tax. 1 is less than 10% tax, 2 is between 10 to 25%. 3 is from 26 to 50%,4 is from 51 to 75%,and 5 is for taxes above 75%. The raw dataset were also pretty clean, we only computed simple operations to transform them as we wanted.
| Code | Period | Percentage_Death_From_Smoking |
|---|---|---|
| AFG | 1990 | 4.018696 |
Code
# Raw Data Importation
df_Tax_On_Tobacco <- read.csv(here::here("Data/share-of-tobacco-retail-price-that-is-tax.csv"))
#2. df_Tax_On_Tobacco
# 2.1 Keep only necessary columns
df_Tax_On_Tobacco <- df_Tax_On_Tobacco[,-c(2)]
# 2.2 Rename the columns
colnames(df_Tax_On_Tobacco)[c(1,2,3)] <- c("Country", "Period","Taxes_On_Tobacco")
# 2.3 Removing potential missing value
df_Tax_On_Tobacco <- subset(df_Tax_On_Tobacco, !is.na(df_Tax_On_Tobacco))
# 2.4 Change the Period as numeric
df_Tax_On_Tobacco$Period <- as.numeric(df_Tax_On_Tobacco$Period, na.rm = TRUE)
# 2.5 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Tax_On_Tobacco)
print(df_summary)3.4.4 Banning advertising on tobacco
To add a control variable and another dimension to our analysis we choose to include the data about the banning of tobacco advertisements. The raw dataset was a bit more disorganised, we had to change all our column names, proceed to a pivot longer to have our year as row attributed in a new column period. Finally, we removed all the lacking values.
| Period | Advertising_Banned | Code |
|---|---|---|
| 2020 | No | AFG |
Code
# Raw Data Importation
df_Banning_Advertising_On_Tobacco <- read.csv(here::here("Data/Banning_Advertising_OnTobacco.csv"))
#4. df_Banning_Advertising_On_Tobacco
#4.1 Renaming the columns
colnames(df_Banning_Advertising_On_Tobacco) <- c("Country", "2020", "2018", "2016")
#4.2 Pivot longer to have our year by row in a new column Period
df_Banning_Advertising_On_Tobacco <- pivot_longer(df_Banning_Advertising_On_Tobacco, cols = starts_with("20"), names_to = "Period", values_to = "Advertising_Banned")
#4.3 changing Period as numeric
df_Banning_Advertising_On_Tobacco$Period <- as.numeric(df_Banning_Advertising_On_Tobacco$Period)
#4.4 Removing value with no interest for us
df_Banning_Advertising_On_Tobacco <- df_Banning_Advertising_On_Tobacco %>%
filter(df_Banning_Advertising_On_Tobacco$Advertising_Banned != "Answer not provided" & df_Banning_Advertising_On_Tobacco$Advertising_Banned != "Report not provided" )
#4.5 Removing potential missing value
df_Banning_Advertising_On_Tobacco <- subset(df_Banning_Advertising_On_Tobacco, !is.na(df_Banning_Advertising_On_Tobacco))
#4.6 Change the Period as numeric
df_Banning_Advertising_On_Tobacco$Period <- as.numeric(df_Banning_Advertising_On_Tobacco$Period, na.rm = TRUE)
#4.7 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Banning_Advertising_On_Tobacco)
print(df_summary)3.4.5 Dataset for question 2 merged
As for the first research question, we merged our new data to the generic ones, to use this as a data base for the EDA and Analysis for question 2. We also reuse the function datatable to show dynamic results
Code
# Raw Data Importation
df_Banning_Advertising_On_Tobacco <- read.csv(here::here("Data/Banning_Advertising_OnTobacco.csv"))
#5. merging df_merged and these new dataframe
list_dfQ2 <- list(df_Death_From_Smoking_By_Country, df_Tax_On_Tobacco, df_Tobacco_Consumption, df_Banning_Advertising_On_Tobacco)
df_mergedQ2 <- Reduce(function(x, y) merge(x, y, by = c("Country", "Period"), all = TRUE), list_dfQ2)
df_mergedQ2 <- merge(x=df_merged,y=df_mergedQ2,by=c("Country","Period"))
#6. remove NA value
df_mergedQ2 <- na.omit(df_mergedQ2)
#7 Create a dynamic table to present our data
#7.1 Round all our value for aesthetic purpose of presentation
df_mergedQ2 <- round_numeric_columns(df=df_mergedQ2)
#7.2 Use the function datatable to create a dynamic table of data
DynamicDataTableDataQ2 <- datatable(df_mergedQ2, options = list(pageLength = 5))3.5 Specific data for question 3
3.2.10 Gini Coefficient
For our third research question, we needed an indicator representing the inequalities within a population. We choose the Gini index as it encompasses inequality through a variety of environments (income, wealth and consumption) which allows us to understand and analyse our data more thoroughly. The raw dataset was quiet messy.We first needed to remove unuseful rows. We started by deleting the first 3 rows and used the fourth as the headline for our columns. We also dropped unnecessary columns. We renamed our main columns, using the function gather to pivot our date as rows. Finally we had to remove potential missing values and transform our values for the Gini coefficient as numeric ones.
| Code | Period | Gini_Index |
|---|---|---|
| USA | 1963 | 37.6 |
Code
# Raw Data Importation
df_Gini_Index <- read.csv(here::here("Data/Gini_Index.csv"),sep=";")
#1. df_Gini_Index
#1.1 Suppress unnecessary rows
df_Gini_Index <- df_Gini_Index[-c(1, 2), ]
#1.2 Use the third line as headline
colnames(df_Gini_Index) <- as.character(unlist(df_Gini_Index[1,]))
#1.3 Keep only the necessary columns and rows
df_Gini_Index <- df_Gini_Index[-1,-c(2:4) ]
#1.5 Rename the column country
colnames(df_Gini_Index)[1] <- "Country"
#1.5 Use the gather function to pivot the data as long to remove the year as column
df_Gini_Index <- gather(df_Gini_Index, key = "Period", value = "Gini_Index", -Country)
# 1.6 Delete all the lines that have no value
df_Gini_Index <- df_Gini_Index %>% filter(df_Gini_Index$Gini_Index != "")
#1.7 Transfrom the value as numeric ones
df_Gini_Index$Gini_Index <- as.numeric(gsub(",", ".", df_Gini_Index$Gini_Index))
#1.8 Removing potential missing value
df_Gini_Index <- subset(df_Gini_Index, !is.na(df_Gini_Index))
#1.9 Summarize our data using the package dfSummary
df_summary <- dfSummary(df_Gini_Index)
print(df_summary)4. Exploratory Data Analysis
4.1 Exploratory Data Analysis for Generic Data
4.1.1 Generic Health data
We had to find elements to indicate health. When trying to find a good health indicator we could not find a relevant health indicator for all countries across our time periods. This is why we chose different indicators to judge the health level of a country. We choose these: Life expectancy at birth, People who contracted cancer, Death rates from malnutrition, Death rates from digestive diseases, Death rate from obesity and Child mortality. Mettre a jour
Mettre des conclusions ici ?
We also looked at how much countries spend on healthcare.
We can clearly see the impact of COVID as health expenses exploded
What can we conclude from these graphs: Some data seems logical and is not cause of concern, for example the overall life expectancy keeps increasing even though there is a slight dip in 2020, possibly because of COVID. As people get older and the population larger the number of people with cancer keeps increasing even though at a slight decreasing tendency. Child mortality and deaths from malnutrition decreases as countries become more developed. However, two graphs are worth analysing further. First, the death of digestive diseases which has increased since 2013 at a dangerous rate. This might be due to an increase in highly processed food, fast foods and sweet beverages at the international level. Second is the obesity death rate which had a very clear drop and stabilisation as of 2005. This might be due to an increasing awareness of food consumption and increased medical attention to the issue.
4.1.2 Countries classify by GDP
Firstly, we collected data to create four separate classes based on GDP. The data stems from the World Bank and is compared through three different years to evaluate the evolution of the different countries. We ranked the four classes by quartile such as Q1 is the 25% of countries with the lowest GDP per capita. We used GDP per capita as this is a better metric to measure wealth across countries as this measures the baskets of goods one person can buy in a country compared to another one. (1) We first downloaded the CSV dataset and uploaded it on R. (2) After checking for missing values, we cleaned up the dataset to leave the countries that had values. (3) Using the function we ordered the countries in four distinct parts: Low income, Medium low income, Medium high income, High income.
Code
# Graph of the Class distribution
# Define the color palette
palette_bleus <- colorRampPalette(c("#A9CCE3", "#99C2D5", "#66A2D5", "#2C7BB6"))(4)
#subsetting for year 2019 from df_merged
df_merged2019 <- subset(df_merged, Period == 2019)
# Create the bar plot with adjusted colors, thicker bars, and more space
Class_Repartition <- ggplot2::ggplot(df_merged2019, ggplot2::aes(x = Class_GDP, fill = Class_GDP)) +
ggplot2::geom_bar(color = "black", linewidth = 0.5, width = 0.7) +
ggplot2::scale_fill_manual(
values = palette_bleus,
breaks = unique(df_merged2019$Class_GDP),
labels = unique(df_merged2019$Class_GDP),
name = "Class"
) +
ggplot2::labs(
title = "Distribution of country by Class for 2019",
x = "Class",
y = "Number of countries"
) +
ggplot2::theme_minimal() +
ggplot2::theme(
plot.title = ggplot2::element_text(hjust = 0.5)
)
Class_Repartition4.2 Exploratory Data Analysis for Question 1
4.2.1 Our data on an interactive map
We also desired to design an interactive map to visualise our data per country to explore it dynamically. Here we can see the Countries which have implemented taxes for 2021 in green and the ones which have not in red, we also see the country for which we don’t have data in grey. We can also access the data of population, GDP and category of each country by clicking on it. We choose the most recent date for the demonstration. Our strategy here was to use the ISO code of the country to join them to the data frame of the package world who contain the polygonal data to draw up on the map created with the leaflet package. As we can observe, our map is quiet full,this mean that we have a lot of country responses in our data.
Code
# Data transforming
# Creating a special data frame for the map
df_Tax_Sweetened_Beverages_Map <- df_GDP %>%
full_join(df_PopByYear, by = c("Code", "Period")) %>%
full_join(df_Tax_Sweetened_Beverages, by = c("Code", "Period"))
# Adding the class by GDP to this data
df_Tax_Sweetened_Beverages_Map <- df_Tax_Sweetened_Beverages_Map[order(df_Tax_Sweetened_Beverages_Map$Period, df_Tax_Sweetened_Beverages_Map$GDP_by_head), ]
df_Tax_Sweetened_Beverages_Map <- df_Tax_Sweetened_Beverages_Map %>%
group_by(Period) %>%
mutate(Class_GDP = ntile(GDP_by_head, 4))
df_Tax_Sweetened_Beverages_Map <- df_Tax_Sweetened_Beverages_Map %>%
mutate(Class_GDP = case_when(
Class_GDP == 1 ~ "Low Income",
Class_GDP == 2 ~ "Medium-Low Income",
Class_GDP == 3 ~ "Medium-High Income",
Class_GDP == 4 ~ "High Income"
))
# Changing the name of the value from 1 and 0 to Yes and No to improve understanding
df_Tax_Sweetened_Beverages_Map$Tax_Sweetened_beverages <- ifelse(df_Tax_Sweetened_Beverages_Map$Tax_Sweetened_beverages == "1", "Taxes", "No Taxes")
#Filter the data for the year of interest
Tax_on_sweetened_beverages <- filter(df_Tax_Sweetened_Beverages_Map, Period == "2021") %>% arrange()
# Get data from our package wolrd
world <- ne_countries(returnclass = "sf")
#Rename the column for the merge
colnames(world)[11] <- "Code"
# merging our data
world_data <- merge(x=world,y=Tax_on_sweetened_beverages,by="Code")
# Set a color palette
color_pal <- colorFactor(c("red", "green"), domain = c("Taxes", "No Taxes"))
# Create the interactive map
inter_graph <- leaflet(world_data) %>%
addProviderTiles(providers$OpenStreetMap.Mapnik) %>%
addPolygons(color = ~color_pal(world_data$Tax_Sweetened_beverages),
weight = 1,
popup = ~paste("Country: ", name, "<br>", "Tax: ", world_data$Tax_Sweetened_beverages, "<br>", "Population: ", world_data$Population, "<br>","GDP by head: ", world_data$GDP_by_head, "<br>","Class: ", world_data$Class_GDP, "<br>"),
highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = TRUE)) %>%
addLegend("bottomright", pal = color_pal, values = unique(world_data$Tax_Sweetened_beverages),
title = "Legend", opacity = 1, labels = unique(world_data$Tax_Sweetened_beverages)) %>%
setView(lng = -39.443407, lat = 35.649315, zoom = 2.4)
# Display the map
inter_graph4.2.2 Evolution of taxation of sweet beverages
The next graph describes the evolution of taxation of sweet beverages across countries. As we can observe we have only 4 different year of observation, which will quiet limit our possibility to affirm potenital efficency of them.
The taxation started as of 2013, indicating a recent awareness of this issue. As of today, the evolution of countries that put taxes in place to regulate sweet beverages is constant with a slight increase in 2017. This allows us to legitimise this paper as to corroborate the effectiveness of such taxation in regards to health.
Ajouter qqch ?
4.2 Exploratory Data Analysis for question 2
4.2.1 Evolution of tobacco consumption
We first looked at the evolution of tobacco consumption over time. We can see a drop from 2000 to 2020 of nearly 10% with a slight plateau in 2018.
Code
# Calculate the yearly mean consumption
df_average_Tobacco_Consumption <- df_Tobacco_Consumption %>%
group_by(Period) %>%
summarise(Average_Tobacco_Consumption = mean(Tobacco_Consumption))
# Create an interactive plot using plot_ly
Average_tobacco_Cons_int <- plotly::plot_ly(
data = df_average_Tobacco_Consumption,
x = ~Period,
y = ~Average_Tobacco_Consumption,
type = "scatter",
mode = "lines+markers",
marker = list(size = 10)
) %>%
layout(
title = "Mean evolution of tobacco consumption",
xaxis = list(title = "Year"),
yaxis = list(
title = "Average of tobacco consumption (% population)",
range = c(10, 35),
ticksuffix = "%"
)
)
Average_tobacco_Cons_int4.2.2 Evolution of deaths due to tobacco consumption
We compare the number of deaths due to tobacco consumption and the evolution of tobacco consumption over time.
Code
# Calculate the mean death from tobacco by year
df_average_Death_From_Smoking <- df_Death_From_Smoking_By_Country%>%
group_by(Period) %>%
summarise(Average_Death_From_Smoking = mean(Percentage_Death_From_Smoking))
# Create an interactive plot using plot_ly
interactive_death_from_smoking <- plotly::plot_ly(
data = df_average_Death_From_Smoking,
x = ~Period,
y = ~Average_Death_From_Smoking,
type = "scatter",
mode = "lines+markers",
marker = list(size = 10)
) %>%
plotly::layout(
title = "Mean evolution of death due to tobacco",
xaxis = list(title = "Year"),
yaxis = list(
title = "Death rate from tobacco",
range = c(11, 14),
ticksuffix = "%"
)
)
interactive_death_from_smoking4.2.3 Evolution of number of country that banned advertising
We wanted also to include control variable as the banishment of advertising, we found interisting data about it, but as we can see, we only have 3 year included in them.
Code
# Convert the column on advertising banishment
df_Banning_Advertising_On_Tobacco$Advertising_Banned <- as.factor(df_Banning_Advertising_On_Tobacco$Advertising_Banned)
# Create the bar plot
bar_plot_Banning_Advertisment <- ggplot(df_Banning_Advertising_On_Tobacco, aes(x = Period, fill = Advertising_Banned)) +
geom_bar(stat = "count", position = "stack") +
labs(
title = "Evolution of the number of advertising banishment",
x = "Year",
y = "Number of Country"
) +
scale_fill_manual(values = c("Yes" = "#B4D88B", "No" = "#FF6347")) +
theme_minimal()+
ggplot2::theme(
plot.title = ggplot2::element_text(hjust = 0.5)
)+ guides(fill = guide_legend(title = "Advertising Banned",))+
scale_x_continuous(breaks = unique(df_Banning_Advertising_On_Tobacco$Period))
bar_plot_Banning_Advertisment4.2.4 Exploring our data with an interactive map
On this interactive map we can observe the evolution of the tax percentage on tobacco products around the world as well as compare the evolution of prices over time. We also see by clicking on the country if he has banned or not the advertising on tobacco products. We reuse the same strategy as before, using the ISO code of country to join our data to the world data package that contain the polygonal data useful to draw the country on the interactive map of the leaflet package. Here you can observe the taxation level for the year 2018.
Code
# Data transforming
df_Tobacco_Map <- df_Tax_On_Tobacco %>%
full_join(df_Tobacco_Consumption, by = c("Code", "Period")) %>%
full_join(df_Death_From_Smoking_By_Country, by = c("Code", "Period")) %>%
full_join(df_GDP, by = c("Code", "Period")) %>%
full_join(df_Banning_Advertising_On_Tobacco, by = c("Code", "Period"))
# Keep only the value for 2018
df_Tobacco_Map <- filter(df_Tobacco_Map, Period == "2018") %>% arrange()
# Get data from our package
world <- ne_countries(returnclass = "sf")
colnames(world)[11] <- "Code"
# Join our data
world_data <- merge(x = world, y = df_Tobacco_Map, by = "Code")
# Map tax levels to categories
world_data$Tax_Category <- factor(world_data$Taxes_On_Tobacco, levels = 1:5, labels = c("Low Tax (<25%)","Low Tax (<25%)", "Medium Tax (26-50%)", "Medium-High Tax (51-75%)", "High Tax (>75%)"))
# Create the interactive map
Interactive_map_Tobacco_data <- leaflet(world_data) %>%
addProviderTiles(providers$OpenStreetMap.Mapnik) %>%
addPolygons(
color = ~colorFactor(palette = "YlOrRd", domain = world_data$Tax_Category)(world_data$Tax_Category),
weight = 1,
popup = ~paste("Country: ", name, "<br>", "Tax: ", Tax_Category, "<br>", "Percentage smoking: ", Tobacco_Consumption, "<br>", "Death From Smoking: ", Percentage_Death_From_Smoking, "<br>", "Advertising banned : ", Advertising_Banned, "<br>"),
highlightOptions = highlightOptions(color = "black", weight = 2, bringToFront = TRUE)
) %>%
addLegend(
"bottomright",
pal = colorFactor(palette = "YlOrRd", domain = world_data$Tax_Category),
values = ~Tax_Category,
title = "Tax Level",
opacity = 1,
labels = ~Tax_Category
) %>%
setView(lng = -39.443407, lat = 35.649315, zoom = 2.4)
# Display the map
#Interactive_map_Tobacco_dataBy analyzing parts of the world, we can note that Europe taxes tobacco the heaviest (>75%). America follows with on average 50%-75% taxes. Asia has on average low taxes on tobacco (25%-50%). The continent which taxes tobacco products the least is Africa. (A vérifier)
4.3 Exploratory Data Analysis for question 3
What are the social and economic consequences? When talking about income inequalities, we often refer to the Gini or Theil index as a measure of wealth distribution across the country.
4.3.1 Gini index over the time
We find interesting to show how wide our data is in terms of time width.. develop
Code
# Mean of the Gini index by country and by year
mean_gini_index <- aggregate(Gini_Index ~ Period, data = df_Gini_Index, FUN = mean)
# Convert the Period as numeric value to slice them for the graphic labels
mean_gini_index$Period <- as.numeric(as.character(mean_gini_index$Period))
# Graphic about the Gini coefficent evolution
plot_Evolution_Ginni_Index <- ggplot2::ggplot(mean_gini_index, ggplot2::aes(x = Period, y = Gini_Index)) +
ggplot2::geom_line(color = "#4682B4", group = 1) +
ggplot2::geom_point(color = "#4682B4") +
ggplot2::labs(title = "Mean evolution of Gini coefficient",
x = "Year",
y = "Gini Coefficient") +
ggplot2::theme_minimal() +
ggplot2::theme(
plot.title = ggplot2::element_text(hjust = 0.5),
axis.text.x = ggplot2::element_text(angle = 45, hjust = 1) # Incline the x-axis labels
) +
ggplot2::scale_x_continuous(breaks = seq(min(mean_gini_index$Period), max(mean_gini_index$Period), by = 5))
# Convert ggplot to plotly
plotly_plot <- plotly::ggplotly(plot_Evolution_Ginni_Index)
# Display the interactive plot
plotly_plot4.3.2 Interactive map
We also find interesting to display our data on an interactive map so we can explore our data intuitively and also seeing how much country we can find in our data.. develop
Code
# Data transforming
# Creating a special data frame for the map
df_Gini_Index_Map <- df_GDP %>%
full_join(df_PopByYear, by = c("Code", "Period")) %>%
full_join(df_Gini_Index, by = c("Code", "Period"))
# Adding the class by GDP to this data
df_Gini_Index_Map <- df_Gini_Index_Map[order(df_Gini_Index_Map$Period, df_Gini_Index_Map$GDP_by_head), ]
df_Gini_Index_Map <- df_Gini_Index_Map %>%
group_by(Period) %>%
mutate(Class_GDP = ntile(GDP_by_head, 4))
df_Gini_Index_Map <- df_Gini_Index_Map %>%
mutate(Class_GDP = case_when(
Class_GDP == 1 ~ "Low Income",
Class_GDP == 2 ~ "Medium-Low Income",
Class_GDP == 3 ~ "Medium-High Income",
Class_GDP == 4 ~ "High Income"
))
#Filter the data for the year of interest
df_Gini_Index_Map_2018 <- filter(df_Gini_Index_Map, Period == 2018)
# Get data from our package wolrd
world <- ne_countries(returnclass = "sf")
#Rename the column for the merge
colnames(world)[11] <- "Code"
# merging our data
world_data_2 <- merge(x=world,y=df_Gini_Index_Map_2018,by="Code")
# Define a color palette
color_pal_Gini <- c("#FFEF9D", "#FFA500", "#FF6347", "#8B0000")
# Créer une fonction de couleurs pour Gini_Index
color_numeric <- colorNumeric(palette = color_pal_Gini, domain = world_data_2$Gini_Index)
# Créer la carte interactive
inter_graph_Gini_Index <- leaflet(world_data_2) %>%
addProviderTiles(providers$OpenStreetMap.Mapnik) %>%
addPolygons(color = ~color_numeric(world_data_2$Gini_Index),
weight = 1,
popup = ~paste("Country: ", name, "<br>", "Gini Index: ", world_data_2$Gini_Index, "<br>","<br>", "Population: ", world_data_2$Population, "<br>", "GDP: ", world_data_2$GDP_by_head, "<br>", "Class: ", world_data_2$Class_GDP, "<br>"),
highlightOptions = highlightOptions(color = "black", weight = 3, bringToFront = TRUE)) %>%
addLegend("bottomright", pal = color_numeric, values = unique(world_data_2$Gini_Index),
title = "Legend", opacity = 1, labels = unique(world_data_2$Gini_Index)) %>%
setView(lng = -39.443407, lat = 35.649315, zoom = 2.4)
# Display the map
inter_graph_Gini_Index4.3.3 Gini index by class
We also wanted to approch our data with our past class design, so we ploted our different class with the gini coefficient to see if we were having something to go deeper with
Code
#Define a color palette for aesthetics prupose
palette_bleus <- colorRampPalette(c("#A9CCE3", "#99C2D5", "#66A2D5", "#2C7BB6"))(4)
#Data Transforming
df_mergedQ3_Graph_Gini <- df_mergedQ3
df_mergedQ3_Graph_Gini$Class_GDP <- factor(df_mergedQ3$Class_GDP, levels = c("Low Income", "Medium-Low Income", "Medium-High Income", "High Income"))
# Convert the Period as factor
df_mergedQ3_Graph_Gini$Period <- factor(df_mergedQ3$Period)
#Adding the country name
df_mergedQ3_Graph_Gini$Country <- countrycode(df_mergedQ3_Graph_Gini$Code, "iso3c", "country.name")
# Create an interactiv graph
plot_Gini_Index_Class <- plot_ly(
data = df_mergedQ3_Graph_Gini,
x = ~Class_GDP,
y = ~Gini_Index,
type = 'box',
boxpoints = 'all', # Afficher tous les points
jitter = 0.3, # Ajouter un jitter pour éviter l'overlap des points
color = ~Class_GDP, # Colorer les points en fonction de la période
colors = palette_bleus, # Utiliser la palette définie précédemment
marker = list(size = 5), # Ajuster la taille des points
text = ~paste("Country: ", Country, "<br>", "Period: ", Period, "<br>", "Gini: ", Gini_Index)
) %>%
layout(
title = "Gini coefficient by class of revenue",
xaxis = list(title = "Class"),
yaxis = list(title = "Gini Coefficient"),
showlegend = TRUE
)
# Display the graph
plot_Gini_Index_Class4.3.4 Gini index regarding life expectancy
We also mixed the gini coefficient regarding the life expectancy to know if we were having something to dig here.
Code
# Create an interactive graph with a single regression line
plot_Gini_Index_LF_2<- plot_ly(
data = df_mergedQ3_Graph_Gini,
x = ~Life_Expectancy,
y = ~Gini_Index,
type = 'scatter',
mode = 'markers',
marker = list(size = 5, color = "#4682B4"), # Set the color for scatter points
text = ~paste("Country: ", Country, "<br>", "Period: ", Period, "<br>", "Gini: ", Gini_Index)
) %>%
add_trace(
type = 'scatter', # Use scatter type for regression line
mode = 'lines', # Show a line
x = ~Life_Expectancy,
y = ~fitted(lm(Gini_Index ~ Life_Expectancy)), # Add the regression line
line = list(color = "#4682B4", width = 5), # Set the color and width for the line
hoverinfo = 'none',
showlegend = FALSE # Remove legend for this trace
) %>%
layout(
title = "Gini coefficient by life expectancy",
xaxis = list(title = "Life Expectancy"),
yaxis = list(title = "Gini Coefficient")
)
# Display the graph
#plot_Gini_Index_LF_25. Analysis
5.1 Creation of a nomralised Health Score
In order to simplify our analysis, we had the idea to combine all our health data to create one robust indicator of health by country based on our information. To justify our weightings, we searched the scientific literature. We quickly realised that creating a health indicator was much more complicated than we had imagined. After going through several research papers and investigating different drafts of a ‘robust’ health indicator, we had to resign ourselves to abandoning our attempt. However, we wanted to share all this with you because we had spent an enormous amount of time developing this health indicator, without being able to come up with a satisfactory result. Nevertheless, we’re going to share our train of thought with you and show you the draft code we’ve produced:
1. Normalisation of our Data ::: {.justify} We began by normalising our data with a score per variable ranging from 1 to 100. The first challenge we encountered was life expectancy. This variable behaves inversely to the others, i.e. the higher it is the better, unlike all the other indicators where the opposite is true.
2. Weighting the health input ::: {.justify} Then, we had to add weight on this indicator, as we can imagine the life expectancy of a country is probably more describing the health of the population than the Death rate form high blood pressure issue. To justify our weightings, we searched the scientific literature. We quickly realised that creating a health indicator was much more complicated than we had imagined. After going through several research papers and investigating different drafts of a ‘robust’ health indicator, we had to resign ourselves to abandoning our attempt. However, we wanted to share all this with you because we had spent an enormous amount of time developing this health indicator, without being able to come up with a satisfactory result. :::
3. Calculate a nomralised health score ::: {.justify} We then calculated a standardised health score (ranging from 1 to 100) for each country. We selected the 10 best and worst health scores and displayed them in a graph. Here is the result : :::
As we can easily see, it’s not really likely that the 10 first country is not the usual one we found in the health ranking.
So we decided to reconsidering the weighting steps, but after many attempt, we weren’t able to propose one satisfying result.
Code
#Data normalization
scale <- 100
# Data Transforming
df_merge_HI <- df_mergedQ1
df_merge_HI <- df_merge_HI[df_merge_HI$Period == "2019",]
# noramlize the Life expectancy
df_merge_HI <- df_merge_HI %>%
arrange(desc(Life_Expectancy))
df_merge_HI$normalized_LE <- (df_merge_HI[, 8] - min(df_merge_HI[, 8])) /
(max(df_merge_HI[, 8]) - min(df_merge_HI[, 8])) * scale
# Weighting definition
poids_indicateurs <- c(0.8,0.5,1, 0.2, 0.3, 0.3, 0.2, 0.2, 0.3, 0.4)
# Loop to get the weigting of our normalized data
for (i in seq_along(poids_indicateurs)) {
col_num <- c(4, 9, 10, 11, 12, 13, 14, 15,17,18)[i]
col_name <- colnames(df_merge_HI)[col_num]
poids <- poids_indicateurs[i]
df_merge_HI[[paste0(col_name, "_normalise")]] <- poids*(max(df_merge_HI[, col_num]) - df_merge_HI[, col_num]) /
(max(df_merge_HI[, col_num]) - min(df_merge_HI[, col_num])) * scale
}
# Apply the weight for life expectancy
df_merge_HI$normalized_LE <- df_merge_HI$normalized_LE *1.5
# Calculate the Health score
last_10_columns <- df_merge_HI[, (ncol(df_merge_HI) - 9):ncol(df_merge_HI)]
sum_by_row <- rowSums(last_10_columns)
df_merge_HI$HealthScore <- sum_by_row
# Normalize the health score
df_merge_HI$HealthScore <- (df_merge_HI$HealthScore - min(df_merge_HI$HealthScore)) /
(max(df_merge_HI$HealthScore) - min(df_merge_HI$HealthScore)) * echelle_reference
df_merge_HI <- df_merge_HI %>%
arrange(desc(HealthScore))
df_merge_HI$Country <- countrycode(df_merge_HI$Code, "iso3c", "country.name")
# Select the top 10 best and worst countries
top_best <- head(df_merge_HI, 10)
top_worst <- tail(df_merge_HI, 10)
# Combine the top 10 best and worst
selected_countries <- rbind(top_best, top_worst)
# Create a scatter plot
plot_Health_Indicator <- scatter_plot <- ggplot(selected_countries, aes(x = HealthScore, y = reorder(Country, HealthScore))) +
geom_point(color = "#4682B4", size = 3) +
labs(title = "Top 10 Best and Worst Health Scores by Country",
x = "Health Score",
y = "Country") +
theme_minimal()
plot_Health_Indicator5.2 Analysis of taxes on sweetened beverages
5.2.1 Influence of a country’s GDP on life expectancy
For us it was interesting to see how can potentially impact the GDP on life expectancy Develop..
Code
#Create a color palette for our graph
palette_lf <- colorRampPalette(c("#99C2D5", "#4D90E4", "#005CBF", "#003366"))(4)
# Create the graph of the evolution of life expectancy by class
Life_Expectancy_Evolution_By_Class <- ggplot2::ggplot(df_merged, ggplot2::aes(x = Period, y = Life_Expectancy, group = Class_GDP, color = Class_GDP)) +
ggplot2::stat_summary(fun = "mean", geom = "line", linewidth = 1.3) + # Increase line width
ggplot2::stat_summary(fun = "mean", geom = "point", size = 3, shape = 16, fill = "white") + # Add points
ggplot2::labs(title = "Mean evolution of life expectancy by class",
x = "Year",
y = "Life Expectancy") +
ggplot2::scale_color_manual(values = palette_lf) + # Apply the custom color palette
ggplot2::scale_y_continuous(limits = c(55, 85)) + # Adjust the y-axis range
ggplot2::theme_minimal()+
ggplot2::theme(
plot.title = ggplot2::element_text(hjust = 0.5) # Centrer le titre horizontalement
)
# Convert ggplot object to plotly
Life_Expectancy_Evolution_By_Class_plotly <- plotly::ggplotly(Life_Expectancy_Evolution_By_Class)
# Display the interactive plot
#Life_Expectancy_Evolution_By_Class_plotlyAs we can see, there is clearly a difference ….
5.2.2 Link between GDP and Health expense
For us it was interesting to see how can potentially impact the GDP on the average of health expense Develop..
As we can see, there is clearly a difference, the more country has an high revenue the more the have large health expense….
Code
# Average Health Expenditure by class of revenue
moyennes_HealthExpenditure_class <- aggregate(Health_Expenditure ~ Period + Class_GDP, data = df_merged, FUN = mean)
# Set the desired order for Class_GDP
class_order <- c("Low Income", "Medium-Low Income", "Medium-High Income", "High Income")
# Convert Class_GDP to factor with the specified order
moyennes_HealthExpenditure_class$Class_GDP <- factor(
moyennes_HealthExpenditure_class$Class_GDP,
levels = class_order
)
# Create an interactiv graph
plotly_Moy_Health_Exp_By_Class <- plot_ly(
data = moyennes_HealthExpenditure_class,
x = ~Class_GDP,
y = ~Health_Expenditure,
type = 'box',
boxpoints = 'all',
jitter = 0.3,
color = ~Class_GDP,
colors = palette_bleus,
marker = list(size = 5),
text = ~paste("Period: ", Period, "<br>", "HE: ", Health_Expenditure,"<br>","Class:",Class_GDP,"<br>")
) %>%
layout(
title = "Gini coefficient by class of revenue",
xaxis = list(title = "Class"),
yaxis = list(title = "Gini Coefficient"),
showlegend = TRUE
)
# Display the graph
plotly_Moy_Health_Exp_By_Class5.2.3 Influence of a country’s GDP from dying of a NCD
We chose to look at NCDs (non-communicable diseases) as this eliminates outliers where a epidemie would have taken place. We looked at the death rates from NCDs per quartile as described in 2.1.1. We used a box plot for each country to center the observations and eliminate any outlier that could falsely alter the results.
Code
# Set a color palette
palette_bleus <- colorRampPalette(c("#A9CCE3", "#99C2D5", "#66A2D5", "#2C7BB6"))(4)
# Set the desired order for Class_GDP
class_order <- c("Low Income", "Medium-Low Income", "Medium-High Income", "High Income")
# Convert Class_GDP to factor with the specified order
df_merged$Class_GDP <- factor(
df_merged$Class_GDP,
levels = class_order
)
# Create an interactiv graph
NCD_plot <- plot_ly(
data = df_merged,
x = ~Class_GDP,
y = ~Prob_Dying_NCD,
type = 'box',
boxpoints = 'all',
jitter = 0.3,
color = ~Class_GDP,
colors = palette_bleus,
marker = list(size = 5),
text = ~paste("Period: ", Period, "<br>", "Prob of dying from NCD: ", Prob_Dying_NCD,"<br>")
) %>%
layout(
title = "Probability of dying from a Non-Communicable Disease",
xaxis = list(title = "Class"),
yaxis = list(title = "Probability of dying from NCD"),
showlegend = TRUE
)
# Display the graph
NCD_plotWe see a perfect correlation between GDP and deaths by NCDs. Furthermore, we can observe that the two low income groups have a higher spread in the box plot. This indicates that low income countries are more affected by different metrics as just financial means. We will explore some possible reasons later on in this paper.
5.2.4 Taxation per income level
Next we looked at the evolution of taxation between 2017 and 2019 across different income levels. This will allow us to evaluate whether the income level has an influence across time.
Code
# Creating the dataframe to plot histogram based on the taxation and class of level
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "Low Income" & df_mergedQ1$Period=="2017")
Sum_Low_Income <- sum(df_test2$Tax_Sweetened_beverages)
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "Medium-Low Income" & df_mergedQ1$Period=="2017")
Sum_Medium_Low_Income <- sum(df_test2$Tax_Sweetened_beverages)
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "Medium-High Income" & df_mergedQ1$Period=="2017")
Sum_Medium_Income <- sum(df_test2$Tax_Sweetened_beverages)
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "High Income" & df_mergedQ1$Period=="2017")
Sum_High_Income <- sum(df_test2$Tax_Sweetened_beverages)
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "Low Income" & df_mergedQ1$Period=="2019")
Sum_Low_Income_2019 <- sum(df_test2$Tax_Sweetened_beverages)
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "Medium-Low Income" & df_mergedQ1$Period=="2019")
Sum_Medium_Low_Income_2019 <- sum(df_test2$Tax_Sweetened_beverages)
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "Medium-High Income" & df_mergedQ1$Period=="2019")
Sum_Medium_Income_2019 <- sum(df_test2$Tax_Sweetened_beverages)
df_test2 <- filter(df_mergedQ1,df_mergedQ1$Class_GDP == "High Income" & df_mergedQ1$Period=="2019")
Sum_High_Income_2019 <- sum(df_test2$Tax_Sweetened_beverages)
# Create a dataframe with the previous calculation
df_hist_1 <- data.frame(c(Sum_Low_Income,Sum_Medium_Low_Income,Sum_Medium_Income,Sum_High_Income,Sum_Low_Income_2019,Sum_Medium_Low_Income_2019,Sum_Medium_Income_2019,Sum_High_Income_2019),
c("Low Income","Medium Low_Income 17","Medium Income 17","High Income 17","Low Income 19","Medium Low Income 19","Medium Income 19","High Income 19"),
c("2017","2017","2017","2017","2019","2019","2019","2019"))
df_hist_1 <- data.frame(c(Sum_Low_Income,Sum_Low_Income_2019,Sum_Medium_Low_Income,Sum_Medium_Low_Income_2019,Sum_Medium_Income,Sum_Medium_Income_2019,Sum_High_Income,Sum_High_Income_2019),
c("Low Income 17","Low Income 19","Medium Low Income 17","Medium Low Income 19","Medium Income 17","Medium Income 19","High Income 17","High Income 19"),
c("2017","2019","2017","2019","2017","2019","2017","2019"))
# Rename the columns
colnames(df_hist_1) <- c("Total_Taxes_number", "Class_GDP", "Year")
period_colors <- c("#A9CCE3", "#4682B4")
# Calculate the percentage increase
df_hist_1$Percentage_Increase <- with(df_hist_1, c(NA, diff(Total_Taxes_number) / Total_Taxes_number[-length(Total_Taxes_number)] * 100))
df_hist_1$Percentage_Increase[df_hist_1$Percentage_Increase < 0] <- NA
# Create the ggplot object with our variables
Number_Of_Taxes_OverTime_By_Class <- ggplot2::ggplot(data = df_hist_1, ggplot2::aes(x = Class_GDP, y = Total_Taxes_number, fill = as.factor(Year))) +
geom_bar(stat = "identity", width = 0.7) +
scale_fill_manual(values = period_colors, name = "Years of observation") +
labs(x = "Class", y = "Sum of Tax on Sweetened beverages") +
ggtitle("Sum of Taxes on sweetened beverages by year") +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
panel.border = element_blank()) +
scale_x_discrete(limits = unique(df_hist_1$Class_GDP)) +
ggplot2::theme(
plot.title = ggplot2::element_text(hjust = 0.5) # Center the title horizontally
)
# Annotate bars with the percentage increase (excluding NA values)
Number_Of_Taxes_OverTime_By_Class <- Number_Of_Taxes_OverTime_By_Class +
geom_text(data = df_hist_1[!is.na(df_hist_1$Percentage_Increase), ], # Exclude NA values
aes(label = paste0("+", format(Percentage_Increase, digits = 3), "%")),
position = position_stack(vjust = 0.8), color = "black", size = 4,
angle = 90, hjust = 0.5) # Rotate the text vertically
# Display the graph
#Number_Of_Taxes_OverTime_By_ClassIn 2017 both low income and high income had a similar number of countries taxing sweet beverages. As of 2019 the differences flatten with similar levels except for low income which is lower. High income had the highest jump, indicating that there was a need for this tax to be put in place in countries of high income.
5.2.5 PCA Analysis
Compléter l’analyse PCA
Code
#Create the df for PCA
df_PCA <- df_mergedQ1
#Keep only the numerical column of the dataframe and delete the Period and population data which is not relevant
df_PCA <- df_PCA %>%
select_if(is.numeric) %>%
select(-Period,-Population)
#Remove the class
#Remove all potential parasite values
df_PCA <- na.omit(df_PCA)
#Compute the PCA analysis
pca_result <- prcomp(df_PCA, scale. = TRUE)
# Create a graph for the PCA analysis --> with arrow
PCA_Arrow <- factoextra::fviz_pca_var(pca_result,
col.var = "contrib",
col.circle = "lightblue",
col.axis = "lightblue",
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE,
arrowsize = 1,
labelsize = 4,
title = "PCA - All Variables",
label.var = "",
label.repel = TRUE) +
theme_minimal() +
theme(legend.position = "left")
PCA_Arrow <- PCA_Arrow +
theme_minimal() +
theme(legend.position = "left",
panel.grid.major = element_line(color = "lightblue", linewidth =0.5),
panel.grid.minor = element_blank())
# Create a graph for the PCA analysis --> scatterplot
PCA_Scatter <- factoextra::fviz_pca_ind(pca_result,
geom.ind = "point",
col.ind = "cos2",
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE,
title = "PCA - Scatterplot of all observations")
# Convert to plotly plot
PCA_Scatter_plotly <- ggplotly(PCA_Scatter)
# Display the interactive plot
PCA_Scatter_plotly5.2.6 Correlation Matrix
The correlation matrix permits us to find correlation between our different variables. The color scale allows us to find the intensity of correlation or negative correlation.
First, we can confirm important theories. Correlation between Life expectancy and Infantile death rate, malnutrition death rate, deaths from NCDs are - ≥ 0.8. However the correlation is much lower between Life expectancy and Diabetes death rate where correlation is -0.4 which indicates that having diabetes is not strongly linked to a lower life expectancy. We can confirm the importance of high GDP per capita for a country’s life expectancy and deaths by NCDs. The correlation between GDP per head and Probability of dying of an NCD is -0.6. The correlation between GDP per head and Life expectancy is 0.7. This results explains that GDP per capita is responsible for a high life expectancy and a lower probability of dying of an NCD. Looking at known correlation between types of deaths we can understand some mechanics of roles of different variables. The correlation between Infantile death rate and Deaths from malnutrition is 0.7. The correlation between GDP per head and infantile death rate is -0.6. With these results we can observe that infantile death is positively correlated to the death rate of malnutrition which is negatively correlated to GDP per capita. This allows us to say that a country with a higher GDP per capita will have fewer deaths by malnutrition and thus implicating a lower infancy death rate. Finally we observe the link between obesity and deaths due to high blood pressure which is one consequence from obesity. The correlation between death rate of obesity and death rate from high blood pressure is 0.9 which confirms known consequences of obesity.
5.2.7 Predictive modeling
We built a predictive model to estimate whether a country taxes sweet beverages by regressing linearly on different health variables. We split our dataset in two, the first slice tests the predictability of the model and the second tests its robustness.
Développer….
| Characteristic | OR1 | 95% CI1 | p-value |
|---|---|---|---|
| Life_Expectancy | 1.02 | 0.93, 1.12 | 0.7 |
| Prob_Dying_NCD | 0.94 | 0.87, 1.00 | 0.052 |
| Death_Diabetes | 0.99 | 0.98, 1.01 | 0.3 |
| Death_Malnutrition | 1.01 | 0.93, 1.08 | 0.8 |
| Percentage_Cancer | 1.00 | 0.89, 1.12 | >0.9 |
| Death_Digestive_Diseases | 1.01 | 0.98, 1.03 | 0.7 |
| Health_Expenditure | 0.94 | 0.82, 1.07 | 0.4 |
| Death_Obesity | 1.03 | 1.01, 1.05 | 0.003 |
| Death_HBP | 0.98 | 0.97, 0.99 | 0.001 |
| GDP_by_head | 1.00 | 1.00, 1.00 | 0.035 |
| 70% of the total data | |||
| 1 OR = Odds Ratio, CI = Confidence Interval | |||
5.3 Anylsis of taxes effect on Tobacco consumption
5.3.1 Tobacco consumption compared to GDP per capita
We will now take a look at the consumption of tobacco compared to GDP per capita over three time years which are 2015, 2018 and 2020.
The two variables Tobacco consumption and GDP per capita are slightly positively correlated. However, in the data we find two outliers that might be flashing these results. Monaco and Luxembourg are two very small countries that seem to be outliers. As their population is small compared to the global population we will omit their results in order to find a clearer correlation in the world population.
When we omit Luxembourg and Monaco we find the following results:
The results do not change significantly. The correlation between the two still correlates only slightly positively. This indicates that the habit of tobacco consumption is not a function of purchasing power. We can suggest that tobacco consumption is caused by cultural and social differences between countries and not from income differences.
5.3.2 Taxation of tobacco as a function of GDP
We now look at the correlation between taxation of tobacco and GDP per head.
There is a positive correlation between these two variables in 2014 and 2018. There are no major changes between these two dates. This allows us to state that the higher the GDP per capita in a country, the higher the taxes on tobacco products.
5.3.3 Deaths from tobacco consumption to GDP Across 2014, 2018 and 2020
There is a positive correlation between Deaths from tobacco and GDP by head.
5.3.4 Correlation matrix between our variable about tobacco and health data
We decided to analyse the correlation between our variables
5.3.5 Compare mortality based on the advertising banning
We found interesting to see if there is difference on country/contient on mortality compared to the banishment of advertising
5.3.6 Compare mortality based on the taxation level
add text
then we wanted to see if there were difference in time..developp
what we can conclude ….
5.4 Anylsis of Gini coefficient
5.4.2 Correlation matrix - with Gini coefficient
5.4.3 Linear regression of the gini index
We wanted to see if our variable allow us to well predict our Gini coefficient.
6. Discussion
6.1 Conclusion
6.2 Limitations
6.2.1 Availability and quality of Data
Securing access to comprehensive and relevant datasets proved to be a significant hurdle. Despite meticulous planning and defined project scopes, locating datasets that encompassed all necessary variables was a formidable challenge. The intricacies stemmed from data silos, disparate sources, and proprietary constraints, limiting the accessibility to a consolidated and holistic dataset.
In a landscape where the data ecosystem is often fragmented, the endeavor to aggregate, clean, and align datasets from diverse origins demanded extensive effort. Navigating through data repositories, APIs, and collaboration with data providers became imperative to bridge gaps in the availability of essential information.
Even when datasets were procured, ensuring their quality emerged as an intricate task. The inherent variability in data formats, missing values, outliers, and inconsistencies posed formidable obstacles. Robust data cleaning processes became indispensable to enhance the reliability and accuracy of subsequent analyses.
Quality assessment tools, anomaly detection algorithms, and domain-specific knowledge were leveraged to identify and rectify discrepancies within the datasets. This phase involved iterative cycles of validation, cleaning, and refinement to align the data with the requisite standards for robust analytical modeling.
6.2.2 No data on sweetened beverages consumption
The quest for information on sugary beverage consumption posed intricate hurdles, primarily stemming from the unavailability of dedicated datasets or repositories addressing this specific domain. The scarcity of centralized databases capturing detailed and up-to-date information on the consumption patterns of sugary drinks presented a substantial impediment to the research endeavor.
6.2.3 Challenges in Establishing Causality Amidst Multifactorial Dynamics
The complexities arose from the daunting task of discerning the most pertinent variables from a multitude of potential influencers, a task exacerbated by the intricate nature of the subject matter. This narrative elucidates the difficulties faced in making informed choices among a plethora of factors, a conundrum that significantly hindered the establishment of robust causal relationships.
The enormity of our analytical landscape demanded meticulous consideration of numerous factors, each purportedly wielding an influence on the phenomena under investigation. From the outset, the challenge lay in the judicious selection of variables that held substantive relevance to the research question. Despite an exhaustive review of diverse studies and an extensive exploration of the existing literature, the conundrum persisted, rendering the task of isolating salient factors a formidable endeavor.
The intricacy of the multifactorial landscape was further compounded by the dynamic nature of the data, requiring a nuanced understanding of temporal trends and contextual fluctuations. The plethora of potential confounders, moderators, and mediators introduced layers of complexity that made it arduous to disentangle the true drivers of the observed phenomena.
While literature reviews and empirical studies provided invaluable insights into the relationships among various factors, the inherent limitations of observational studies and the challenges of establishing causality in complex systems became apparent. The interplay of numerous covariates and the potential for confounding variables presented hurdles in establishing a causal link between our variables of interest.
Navigating this intricate terrain required a delicate balance between theoretical understanding, statistical rigor, and domain expertise. Despite employing sophisticated statistical techniques and leveraging advanced modeling approaches, the elusive quest for clear causal pathways persisted. Sensitivity analyses and robustness checks were conducted diligently, yet the underlying complexity of the system thwarted endeavors to isolate causal effects definitively.
- Impossible de generalisé l’analyse
- Conclusion abusives
6.3 Proposition for future work
- Possibilité d’utilisé des données sur la santé dentaire pour voir si une reduction de la conso des boissons sucrée a une incidence
Reference List (“GDP per capita (current US\() | Data”) Work Cited “GDP per capita (current US\)) | Data.” World Bank Data, https://data.worldbank.org/indicator/NY.GDP.PCAP.CD. Accessed 15 November 2023.
https://www.aeaweb.org/articles?id=10.1257/jep.33.3.202
```{r child = c(‘intro.qmd’, ‘data.qmd’, ‘eda.qmd’, ‘analysis.qmd’, ‘concl.qmd’)}