jueves, 9 de agosto de 2018

Life Expectancy and Fertility Data Analyst

Is this chapter I analyze the relations between fertility, life expectancy and incomes in the world, I hope you find some interesting tips about how to analyze this kinds of data.

The original dataset is here.

Was necessary to cleaned the data and working with it previously for this analysis, all of the full code is here.

The libraries that I used were:











 We have 5 datasets :

  • Clean_life_expectancy : The provided dataset for life expectancy, cleaned and updated
  • Clean_life_expectancy_Melt : Contains the same info that clean_life_expectancy but with the years columns melting into rows
  • Clean_fertility : The provided dataset for Fertility, cleaned and updated
  • Clean_fertility_Melt : Contains the same info that Clean_fertility but with the years columns melting into rows
  • metadata : Special dataset that contains information that link the country with regions an incomes types

Quick Inspection of the datasets

 












Merging life_expectancy, fertility and metadata datasets



By region and income

Grouping life and fertility by its median

 



Verifying Life expectancy over the years

 

As we noticed the life expectancy are incremental with the time

 

Verifying Fertility over the years

 

 


Fertility is decrementing over the years , this suggest a negative correlation with life expectancy

 

Verifying the relation between life expectancy and fertility over the years

 

This confirms the idea that life expectancy and fertility are negative correlated

 

Verifying if the correlation is negative in all the regions

Obtaining all the regions

 


Displaying the life expectancy and fertility over the years by region, also showing the correlation by region

 



As we can see the life expectancy- fertility relation is stable from 20-60 years but passing this threshold, the fertility starts an aggressive decrement, we could check this specially in North America and Europe

 

Verifying if the correlation is negative with incomes types

Obtaining all the incomes types


Displaying the life expectancy and fertility over the years by incomes types, also showing the correlation by incomes

 


As we can see the relations between life expectancy and fertility with the incomes types keeps the same behavior like the regions. Here we can noticed that when the income increase the life expectancy increase too and  fertility decrement, again with the threshold of 60 years

 

Verifying Central Tendency measures by regions





Apparently the most stable region is North America, in the opposite, Asia and Africa suffers by outliers,this could be explain because some countries of this regions are rich and others poor, for example in Africa the differences between South Africa and Somalia are too bigger

 

Verifying which group(region or income) affect more the relation fertility-life expectancy

 

Creating a 7 centroids knn cluster (simulating the 7 regions)


 

Creating a 4 centroids knn cluster (simulating the 4 incomes)

 

The cluster that obtains a better inertia was the 7 centroid, now we create a hierarchical cluster and determine which distance could provide us similar number of clusters

 


As we can see with a distance of 9 we have been able to obtain the exact number of desired clusters (7)

 

Now is time to analyze the information provided by the hierarchical clustering

The next table shows the joining info between the hierarchical clustering and the data provided by the metadata


Grouping the info by income

 




Grouping the info by Region

 



Interpretations :

  • We can group the cluster 6 and 7 into one because they are affected in the same manner by the region and the income (Sub-Saharan Africa, South Asia)(Low income,Lower middle income).
  • The clusters 1 and 4 explain better its fertility-life relation for its incomes that for its regions.
  • Both, regions and incomes can explain in certain way the relation fertility - life expectancy, this is possible because some regions has a clearly determine kind of income, for example the mayority of the countries of africa has low incomes in comparision with europe
  • When the income increase, the fertility suffer a decrease and the life expectancy increase
  • When the income decrease, the fertility suffer an increment and the life expectancy decrease
  • Based of this results apparently is more important the incomes , that is to say, the relation between fertility-life expectancy by region is just explained by the incomes of the region

Finally I show the top 20 countries ordered by life expectancy and fertility (here the data was normalized)

By Max Agrupation




Plotting life expectancy and fertility into one single dimension

 


The countries displaying in the graph above will have the most establish growing in the future (which not mean that will have the most population)


In the other side the countries showing above will have apparently a negative growing in the future.

 

The chart below shows the countries that are located in the 75% percentile, this location means that this countries will have a better growing population because they combines a good fertility rate with a high life expectancy. Notice the case of France , this country has a high life expectancy (between 75-80 years) but its fertility technically does not have variation over the years and keeping in a good rate up to 2






Here the same data but with life expectancy and fertility normalize







Creating a process that tries to determine under the same conditions which country will have more population in 50 years. Approximately 26.3% of the global population is aged under 15, while 65.9% is aged 15–64 and 7.9% is aged 65 or over.[67] The median age of the world's population was estimated to be 29.7 years in 2014,[69] and is expected to rise to 37.9 years by 2050 



The results of the last exercise were just for fun, because exits a lot of extra factors that is necessary to consider for this, but at least we can have a perspective.

 

Bibliography





 

No hay comentarios:

Publicar un comentario