Introduction

In this project I’m trying to address the relation between developed or developing country and it’s populations’ health.

Is there a linear relationship between the developing status of a country and it’s populations’ health?

We will be using the world health organization data set, the set contains world countries’ GDP/populations/BMI/status and more information to help find out the answer.

Methods

How were the data collected, gathered, or sourced? Data were collected from World Health Organization by uploading the who dataset CSV file to the R environment using the read_csv function, data were cleaned before the uploading, some data types were changed to numeric instead of characters, also removed the NA from the set.

What is your target variable?

The variables I’m targeting are country status developed or developing, BMI Body Mass Index, life expectancy.

Are there predictor variables of interest, or particular groups that you wish to compare?

The predictor variable of interest is life expectancy, I’m trying to compare it between developed and developing countries.

What statistical tests and models did you use?

I have used to correlation test.

The test have a coefficient scale of -1 to +1 where when the results closer to +1 there is a positive correlation and when it’s closer to -1 there will be a negative correlation.

Results

r = 0.59 p value < 0.001

Exploring the data

# Testing the correlation using the cor.test function.
cor.test(who1$life_expectancy, who1$bmi)
## 
##  Pearson's product-moment correlation
## 
## data:  who1$life_expectancy and who1$bmi
## t = 9.8288, df = 180, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.4874206 0.6781391
## sample estimates:
##      cor 
## 0.590977
# Now inserting a plot to show the correlation.
who1 %>% ggplot(aes(x = bmi, y= life_expectancy)) + geom_point()
## Warning: Removed 12 rows containing missing values (`geom_point()`).

# Then adding a line of best fit to the chart
who1 %>% ggplot(aes(x= bmi, y= life_expectancy)) + geom_point() + 
  geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 12 rows containing non-finite values (`stat_smooth()`).
## Removed 12 rows containing missing values (`geom_point()`).

# Then improving the chart information by adding the core test results as text
who1 %>% ggplot(aes(x= bmi, y= life_expectancy)) + geom_point() + 
  geom_smooth(method = "lm") + annotate("text", x= 30, y = 55, label = "r= 0.59, P< 0.001")
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 12 rows containing non-finite values (`stat_smooth()`).
## Removed 12 rows containing missing values (`geom_point()`).

# This linear regression code will help analyze the relationship between variables 
rlm_1 <- lm(life_expectancy ~ bmi + status, data = who1)
summary(rlm_1)
## 
## Call:
## lm(formula = life_expectancy ~ bmi + status, data = who1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -15.9742  -3.5299   0.4289   3.3864  15.5985 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       36.5597     5.0994   7.169 1.91e-11 ***
## bmi                1.6211     0.1866   8.689 2.27e-15 ***
## statusDeveloping  -8.0408     1.0667  -7.538 2.30e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.445 on 179 degrees of freedom
##   (12 observations deleted due to missingness)
## Multiple R-squared:  0.506,  Adjusted R-squared:  0.5005 
## F-statistic: 91.69 on 2 and 179 DF,  p-value: < 2.2e-16
# Insert a meaningful table or plot
who1 %>% ggplot(aes(x = bmi, y= life_expectancy, color= status))+ 
  geom_point() + facet_wrap(~status)
## Warning: Removed 12 rows containing missing values (`geom_point()`).

In addition to displaying polished plots and tables, discuss any patterns or relationships that are apparent in the data. Are there any missing or anomalous values? If so, how did you handle these data values?

Analyzing and interpreting the data

# This code will enhance the mlr_1 results, it will rescale the numeric variables 
## set reference groups for character variables, and excludes insignificant variables.
mlr_2 <- lm(life_expectancy~ scale(bmi) + fct_relevel(status, "developing") + 
              continent, data = who1)
## Warning: 1 unknown level in `f`: developing
summary(mlr_2)
## 
## Call:
## lm(formula = life_expectancy ~ scale(bmi) + fct_relevel(status, 
##     "developing") + continent, data = who1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -12.0727  -2.4733   0.1415   2.2083  11.5655 
## 
## Coefficients:
##                                             Estimate Std. Error t value
## (Intercept)                                  71.3528     1.5304  46.624
## scale(bmi)                                    2.2323     0.4938   4.520
## fct_relevel(status, "developing")Developing  -6.4443     1.3260  -4.860
## continentAsia                                 8.4288     0.9508   8.865
## continentEurope                               8.0124     1.5389   5.207
## continentEurope/Asia                          7.6128     3.2928   2.312
## continentNorth America                        7.9933     1.3706   5.832
## continentOceania                              4.0745     1.8331   2.223
## continentSouth America                        8.5315     1.5596   5.470
##                                             Pr(>|t|)    
## (Intercept)                                  < 2e-16 ***
## scale(bmi)                                  1.14e-05 ***
## fct_relevel(status, "developing")Developing 2.62e-06 ***
## continentAsia                               9.14e-16 ***
## continentEurope                             5.41e-07 ***
## continentEurope/Asia                          0.0220 *  
## continentNorth America                      2.63e-08 ***
## continentOceania                              0.0275 *  
## continentSouth America                      1.55e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.459 on 173 degrees of freedom
##   (12 observations deleted due to missingness)
## Multiple R-squared:  0.6798, Adjusted R-squared:  0.665 
## F-statistic: 45.91 on 8 and 173 DF,  p-value: < 2.2e-16
# Finally with this code chunk we will create an interactive plot chart using plotly
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.3.3
who_plot_1 <- who1 %>% ggplot(aes(x = bmi, y= life_expectancy, color= continent, size = pop_mil))+ 
  geom_point(alpha= 0.4) + facet_wrap(~status) + theme(legend.position = "none")+
  labs(x = "Body Mass Index (kg/m^2)",
             y = "Life Expectancy (years)",
             title = "Global Life Expectancy and BMI in 2015",
             subtitle = "Points sized by country population (in millions); color indicates continent",
             caption = "Source: World Health Organization") 

ggplotly(who_plot_1) 

Our data question was, does Body Mass Index and life expectancy have a correlation with the country development status?

The answer was yes, I have used the correlation test and the linear regression model.

There was a significant relationship between the life expectancy and the country status as developed or developing.

My analysis confirmed that humans in developed countries have a higher life expectancy rates.

Discussion

The most important finding was that there is a significant relationship between BMI and life expectancy.

being new to R limited my ability to digest the outcome of the tests I ran.

If someone wants to advance this work, they should consider getting more familiar with test models and how to interpret them.

References