I have spent most of my reading time on “Social Science”. As a young girl and prepare to have my own family in the near future, I reall go into deep with the issue of how to live longer and longer.
And in this assignment, I would like to show you how a woman having less children can live longer and how the fertility rate was changing through years and its trend. In other word, having two or one children a family is one of the best policy that has seen as an effective catalyst to the improvement in terms of woman’s life expectancy and their health. My report is aimed to refer to Asean countries, specifically.
In my assignment, I would like to use the data from WDI package, starts from 1990 to 2015, with two indicators namely : * “SP.DYN.LE00.FE.IN” is Life expectancy of women(years) * “SP.DYN.TFRT.IN” is Fertility rate or the number of children per woman.
# Loading packages
library(ggplot2)
library(ggthemes)
library(tidyverse)
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
## The following objects are masked from 'package:readr':
##
## col_factor, col_numeric
library(ggrepel)
library(WDI)
## Loading required package: RJSONIO
library(googleVis)
##
## Welcome to googleVis version 0.6.1
##
## Please read the Google API Terms of Use
## before you start using the package:
## https://developers.google.com/terms/
##
## Note, the plot method of googleVis will by default use
## the standard browser to display its output.
##
## See the googleVis package vignettes for more details,
## or visit http://github.com/mages/googleVis.
##
## To suppress this message use:
## suppressPackageStartupMessages(library(googleVis))
library(plyr)
## -------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## -------------------------------------------------------------------------
##
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following object is masked from 'package:purrr':
##
## compact
library(dplyr)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
theme_set(theme_minimal())
# Loading the WDIcache to find indicators then loading data:
d <- WDIcache()
d1 <- data.frame(d[[1]])
d2 <- data.frame(d[[2]])
lifeExpectancy= WDI(indicator='SP.DYN.LE00.FE.IN', country="all",start=1990, end=2015)
childPerwoman = WDI(indicator='SP.DYN.TFRT.IN', country="all",start=1990, end=2015)
names(lifeExpectancy)[3]="lifeExp"
names(childPerwoman)[3]="fertility"
# Join two seperate datasets into one new dataset called mydf
j1 <- join(childPerwoman,lifeExpectancy)
## Joining by: iso2c, country, year
j2 <- merge(j1, d2, by= "country", all.x=TRUE)
mydf <- j2[-c(2,6,7,9,10,11,13)]
inter <- intersect(j2$country, d2$country)
# Filter mydf as removing missing data
mydf <- mydf %>%
filter(country %in% inter) %>%
arrange(country) %>%
mutate(country = as.character(country,is.na))
mydf <- na.omit(mydf)
# Create the list of Asian countries that joined the Asean Group:
asean <- c("Brunei", "India", "China","Cambodia","Indonesia", "Laos","Malaysia","Myanmar", "Philippines","Singapore", "Thailand")
# Create a new data files called "mf" which just contains specific countries:
mf <- mydf %>% filter(country %in% c( "China","Malaysia","Singapore", "Thailand", "Vietnam"))
mf %>% na.omit()
## country fertility year lifeExp region
## 1 China 1.617 2015 77.667 East Asia & Pacific
## 2 China 1.610 2014 77.503 East Asia & Pacific
## 3 China 1.604 2013 77.342 East Asia & Pacific
## 4 China 1.599 2012 77.180 East Asia & Pacific
## 5 China 1.594 2011 77.015 East Asia & Pacific
## 6 China 1.590 2010 76.837 East Asia & Pacific
## 7 China 1.586 2009 76.641 East Asia & Pacific
## 8 China 1.581 2008 76.418 East Asia & Pacific
## 9 China 1.577 2007 76.166 East Asia & Pacific
## 10 China 1.572 2006 75.884 East Asia & Pacific
## 11 China 1.565 2005 75.569 East Asia & Pacific
## 12 China 1.554 2004 75.223 East Asia & Pacific
## 13 China 1.540 2003 74.853 East Asia & Pacific
## 14 China 1.524 2002 74.469 East Asia & Pacific
## 15 China 1.508 2001 74.079 East Asia & Pacific
## 16 China 1.497 2000 73.693 East Asia & Pacific
## 17 China 1.494 1999 73.320 East Asia & Pacific
## 18 China 1.503 1998 72.967 East Asia & Pacific
## 19 China 1.527 1997 72.637 East Asia & Pacific
## 20 China 1.571 1996 72.334 East Asia & Pacific
## 21 China 1.639 1995 72.060 East Asia & Pacific
## 22 China 1.739 1994 71.816 East Asia & Pacific
## 23 China 1.868 1993 71.595 East Asia & Pacific
## 24 China 2.021 1992 71.388 East Asia & Pacific
## 25 China 2.187 1991 71.192 East Asia & Pacific
## 26 China 2.350 1990 71.002 East Asia & Pacific
## 27 Malaysia 2.056 2015 77.543 East Asia & Pacific
## 28 Malaysia 2.074 2014 77.376 East Asia & Pacific
## 29 Malaysia 2.092 2013 77.200 East Asia & Pacific
## 30 Malaysia 2.110 2012 77.014 East Asia & Pacific
## 31 Malaysia 2.129 2011 76.820 East Asia & Pacific
## 32 Malaysia 2.149 2010 76.624 East Asia & Pacific
## 33 Malaysia 2.169 2009 76.434 East Asia & Pacific
## 34 Malaysia 2.191 2008 76.253 East Asia & Pacific
## 35 Malaysia 2.217 2007 76.085 East Asia & Pacific
## 36 Malaysia 2.249 2006 75.930 East Asia & Pacific
## 37 Malaysia 2.293 2005 75.783 East Asia & Pacific
## 38 Malaysia 2.355 2004 75.637 East Asia & Pacific
## 39 Malaysia 2.438 2003 75.487 East Asia & Pacific
## 40 Malaysia 2.539 2002 75.324 East Asia & Pacific
## 41 Malaysia 2.657 2001 75.147 East Asia & Pacific
## 42 Malaysia 2.784 2000 74.955 East Asia & Pacific
## 43 Malaysia 2.913 1999 74.749 East Asia & Pacific
## 44 Malaysia 3.036 1998 74.533 East Asia & Pacific
## 45 Malaysia 3.145 1997 74.311 East Asia & Pacific
## 46 Malaysia 3.238 1996 74.084 East Asia & Pacific
## 47 Malaysia 3.313 1995 73.853 East Asia & Pacific
## 48 Malaysia 3.372 1994 73.618 East Asia & Pacific
## 49 Malaysia 3.422 1993 73.379 East Asia & Pacific
## 50 Malaysia 3.466 1992 73.134 East Asia & Pacific
## 51 Malaysia 3.510 1991 72.884 East Asia & Pacific
## 52 Malaysia 3.554 1990 72.627 East Asia & Pacific
## 53 Singapore 1.240 2015 84.900 East Asia & Pacific
## 54 Singapore 1.250 2014 84.800 East Asia & Pacific
## 55 Singapore 1.190 2013 84.500 East Asia & Pacific
## 56 Singapore 1.290 2012 84.300 East Asia & Pacific
## 57 Singapore 1.200 2011 84.100 East Asia & Pacific
## 58 Singapore 1.150 2010 84.000 East Asia & Pacific
## 59 Singapore 1.220 2009 83.700 East Asia & Pacific
## 60 Singapore 1.280 2008 83.300 East Asia & Pacific
## 61 Singapore 1.290 2007 82.900 East Asia & Pacific
## 62 Singapore 1.280 2006 82.600 East Asia & Pacific
## 63 Singapore 1.260 2005 82.500 East Asia & Pacific
## 64 Singapore 1.260 2004 82.000 East Asia & Pacific
## 65 Singapore 1.270 2003 81.600 East Asia & Pacific
## 66 Singapore 1.370 2002 80.600 East Asia & Pacific
## 67 Singapore 1.410 2001 80.300 East Asia & Pacific
## 68 Singapore 1.600 2000 80.000 East Asia & Pacific
## 69 Singapore 1.470 1999 79.600 East Asia & Pacific
## 70 Singapore 1.480 1998 79.400 East Asia & Pacific
## 71 Singapore 1.610 1997 79.100 East Asia & Pacific
## 72 Singapore 1.660 1996 78.900 East Asia & Pacific
## 73 Singapore 1.670 1995 78.600 East Asia & Pacific
## 74 Singapore 1.710 1994 78.400 East Asia & Pacific
## 75 Singapore 1.740 1993 78.300 East Asia & Pacific
## 76 Singapore 1.720 1992 78.200 East Asia & Pacific
## 77 Singapore 1.730 1991 77.900 East Asia & Pacific
## 78 Singapore 1.830 1990 77.600 East Asia & Pacific
## 79 Thailand 1.498 2015 78.953 East Asia & Pacific
## 80 Thailand 1.512 2014 78.747 East Asia & Pacific
## 81 Thailand 1.524 2013 78.505 East Asia & Pacific
## 82 Thailand 1.534 2012 78.226 East Asia & Pacific
## 83 Thailand 1.542 2011 77.910 East Asia & Pacific
## 84 Thailand 1.547 2010 77.561 East Asia & Pacific
## 85 Thailand 1.551 2009 77.182 East Asia & Pacific
## 86 Thailand 1.553 2008 76.788 East Asia & Pacific
## 87 Thailand 1.557 2007 76.393 East Asia & Pacific
## 88 Thailand 1.561 2006 76.010 East Asia & Pacific
## 89 Thailand 1.568 2005 75.654 East Asia & Pacific
## 90 Thailand 1.580 2004 75.339 East Asia & Pacific
## 91 Thailand 1.595 2003 75.067 East Asia & Pacific
## 92 Thailand 1.616 2002 74.840 East Asia & Pacific
## 93 Thailand 1.641 2001 74.657 East Asia & Pacific
## 94 Thailand 1.671 2000 74.513 East Asia & Pacific
## 95 Thailand 1.705 1999 74.400 East Asia & Pacific
## 96 Thailand 1.742 1998 74.305 East Asia & Pacific
## 97 Thailand 1.781 1997 74.214 East Asia & Pacific
## 98 Thailand 1.823 1996 74.118 East Asia & Pacific
## 99 Thailand 1.867 1995 74.018 East Asia & Pacific
## 100 Thailand 1.911 1994 73.923 East Asia & Pacific
## 101 Thailand 1.956 1993 73.831 East Asia & Pacific
## 102 Thailand 2.003 1992 73.735 East Asia & Pacific
## 103 Thailand 2.055 1991 73.616 East Asia & Pacific
## 104 Thailand 2.113 1990 73.439 East Asia & Pacific
## 105 Vietnam 1.958 2015 80.713 East Asia & Pacific
## 106 Vietnam 1.960 2014 80.555 East Asia & Pacific
## 107 Vietnam 1.959 2013 80.405 East Asia & Pacific
## 108 Vietnam 1.957 2012 80.263 East Asia & Pacific
## 109 Vietnam 1.953 2011 80.126 East Asia & Pacific
## 110 Vietnam 1.946 2010 79.992 East Asia & Pacific
## 111 Vietnam 1.936 2009 79.856 East Asia & Pacific
## 112 Vietnam 1.923 2008 79.714 East Asia & Pacific
## 113 Vietnam 1.911 2007 79.562 East Asia & Pacific
## 114 Vietnam 1.901 2006 79.395 East Asia & Pacific
## 115 Vietnam 1.894 2005 79.214 East Asia & Pacific
## 116 Vietnam 1.894 2004 79.019 East Asia & Pacific
## 117 Vietnam 1.901 2003 78.811 East Asia & Pacific
## 118 Vietnam 1.920 2002 78.593 East Asia & Pacific
## 119 Vietnam 1.954 2001 78.364 East Asia & Pacific
## 120 Vietnam 2.010 2000 78.122 East Asia & Pacific
## 121 Vietnam 2.096 1999 77.868 East Asia & Pacific
## 122 Vietnam 2.213 1998 77.599 East Asia & Pacific
## 123 Vietnam 2.359 1997 77.317 East Asia & Pacific
## 124 Vietnam 2.529 1996 77.022 East Asia & Pacific
## 125 Vietnam 2.714 1995 76.715 East Asia & Pacific
## 126 Vietnam 2.904 1994 76.399 East Asia & Pacific
## 127 Vietnam 3.089 1993 76.074 East Asia & Pacific
## 128 Vietnam 3.260 1992 75.743 East Asia & Pacific
## 129 Vietnam 3.415 1991 75.409 East Asia & Pacific
## 130 Vietnam 3.553 1990 75.072 East Asia & Pacific
## income
## 1 Upper middle income
## 2 Upper middle income
## 3 Upper middle income
## 4 Upper middle income
## 5 Upper middle income
## 6 Upper middle income
## 7 Upper middle income
## 8 Upper middle income
## 9 Upper middle income
## 10 Upper middle income
## 11 Upper middle income
## 12 Upper middle income
## 13 Upper middle income
## 14 Upper middle income
## 15 Upper middle income
## 16 Upper middle income
## 17 Upper middle income
## 18 Upper middle income
## 19 Upper middle income
## 20 Upper middle income
## 21 Upper middle income
## 22 Upper middle income
## 23 Upper middle income
## 24 Upper middle income
## 25 Upper middle income
## 26 Upper middle income
## 27 Upper middle income
## 28 Upper middle income
## 29 Upper middle income
## 30 Upper middle income
## 31 Upper middle income
## 32 Upper middle income
## 33 Upper middle income
## 34 Upper middle income
## 35 Upper middle income
## 36 Upper middle income
## 37 Upper middle income
## 38 Upper middle income
## 39 Upper middle income
## 40 Upper middle income
## 41 Upper middle income
## 42 Upper middle income
## 43 Upper middle income
## 44 Upper middle income
## 45 Upper middle income
## 46 Upper middle income
## 47 Upper middle income
## 48 Upper middle income
## 49 Upper middle income
## 50 Upper middle income
## 51 Upper middle income
## 52 Upper middle income
## 53 High income
## 54 High income
## 55 High income
## 56 High income
## 57 High income
## 58 High income
## 59 High income
## 60 High income
## 61 High income
## 62 High income
## 63 High income
## 64 High income
## 65 High income
## 66 High income
## 67 High income
## 68 High income
## 69 High income
## 70 High income
## 71 High income
## 72 High income
## 73 High income
## 74 High income
## 75 High income
## 76 High income
## 77 High income
## 78 High income
## 79 Upper middle income
## 80 Upper middle income
## 81 Upper middle income
## 82 Upper middle income
## 83 Upper middle income
## 84 Upper middle income
## 85 Upper middle income
## 86 Upper middle income
## 87 Upper middle income
## 88 Upper middle income
## 89 Upper middle income
## 90 Upper middle income
## 91 Upper middle income
## 92 Upper middle income
## 93 Upper middle income
## 94 Upper middle income
## 95 Upper middle income
## 96 Upper middle income
## 97 Upper middle income
## 98 Upper middle income
## 99 Upper middle income
## 100 Upper middle income
## 101 Upper middle income
## 102 Upper middle income
## 103 Upper middle income
## 104 Upper middle income
## 105 Lower middle income
## 106 Lower middle income
## 107 Lower middle income
## 108 Lower middle income
## 109 Lower middle income
## 110 Lower middle income
## 111 Lower middle income
## 112 Lower middle income
## 113 Lower middle income
## 114 Lower middle income
## 115 Lower middle income
## 116 Lower middle income
## 117 Lower middle income
## 118 Lower middle income
## 119 Lower middle income
## 120 Lower middle income
## 121 Lower middle income
## 122 Lower middle income
## 123 Lower middle income
## 124 Lower middle income
## 125 Lower middle income
## 126 Lower middle income
## 127 Lower middle income
## 128 Lower middle income
## 129 Lower middle income
## 130 Lower middle income
head(mydf)
## country fertility year lifeExp region income
## 1 Afghanistan 4.802 2015 64.613 South Asia Low income
## 2 Afghanistan 4.981 2014 64.197 South Asia Low income
## 3 Afghanistan 5.174 2013 63.778 South Asia Low income
## 4 Afghanistan 5.380 2012 63.354 South Asia Low income
## 5 Afghanistan 5.595 2011 62.924 South Asia Low income
## 6 Afghanistan 5.816 2010 62.476 South Asia Low income
Viet nam is represented as the red bubble
# Checking correlation value of life expectancy and fertility
cor(mydf$lifeExp, mydf$fertility)
## [1] -0.8768023
=> The correlation value is negative and very high. That means, the living years a womancan be increased at a decrease of her fertility. And let’s use visualization to confirm that again:
# Visualization For 1990
h1 <- mydf %>%
ggplot(aes(fertility, lifeExp)) +
geom_point(alpha = 0.1, color = "purple") +
geom_point(
data = mydf %>% filter(country == "Vietnam" & year == 1990),
color = "red",
size = 4
) +
geom_text_repel(
data = mydf %>% filter(country == "Vietnam" & year == 1990),
aes(label = country),
force = 5
) +
geom_point(
data = mydf %>% filter(country %in% asean & year == 1990),
color = "orange",
size = 2
) +
geom_text_repel(
data = mydf %>% filter(country %in% asean & year == 1990),
aes(label = country),
force = 5, direction = "y"
) +
geom_smooth(method = "loess", fill = "blue", alpha = 0.2) +
labs(x = "Fertility",
y = "Life Expectancy of woman at Birth",
title = "Vietnam and Asean Countries in 1990",
caption = "Data Source: World Development Indicators")
h1
# Visualiation of those countries in 2014
h2 <- mydf %>%
ggplot(aes(fertility, lifeExp)) +
geom_point(alpha = 0.1, color = "purple") +
geom_point(
data = mydf %>% filter(country == "Vietnam" & year == 2014),
color = "red",
size = 4
) +
geom_text_repel(
data = mydf %>% filter(country == "Vietnam" & year == 2014),
aes(label = country),
force = 10
) +
geom_point(
data = mydf %>% filter(country %in% asean & year == 2014),
color = "orange",
size = 2
) +
geom_text_repel(
data = mydf %>% filter(country %in% asean & year == 2014),
aes(label = country),
force = 10,
direction = "y"
) +
geom_smooth(method = "loess", fill = "blue", alpha = 0.2) +
labs(x = "Fertility",
y = "Life Expectancy of woman at Birth",
title = "Vietnam and Asean Countries in 2014",
caption = "Data Source: World Development Indicators")
h2
# Grid two graphs to see the difference:
grid.arrange(h1, h2, nrow = 1)
One thing easily can be seen from these graphs is the improvement of women’s ages in all countries. The fertility rate was changing so much. It is meant that if every woman has less than three children, they can live much longer. In 1990, the data distributed gradually along the line and there was a big gap between Asean countries in term of life expectancy at birth rate but they were getting closer in 2014. It is happy to say the average ages increased when the fertility decreased.
## Visualize the fertility
h3 <- mf %>%
ggplot(aes(year, fertility, color = country)) +
geom_line(show.legend = FALSE) +
geom_point(show.legend = FALSE) +
facet_wrap(~country, scales = "free", nrow = 1) +
labs(x = NULL, y = NULL,
title = "Overall fertility rate through years( from 1990 to 2015) ",
caption = "Data Source: WDI")
h3
My conclusion:
From this analysis, I do believe that every family in this world should have one or two children then mothers can live longer and healthier with their children.
This assignment was judged by my professor James Baglin, BAppSc (Psych - Hons), PhD Senior Lecturer, Statistics Program Manager, Master of Analytics and Master of Statistics and Operations Research School of Science, Mathematical Sciences, RMIT University Melbourne, Australia Office: Building 8, Level 9, Room 69, City campus Tel. +61 3 9925 6118 Fax: +61 3 9925 6107 Email: james.baglin@rmit.edu.au | LinkedIn | Profile Program Portal - MC242 & MC004 | Book a student consultation
Here is his comment: * You chose an interesting story and data set to explore. No need to mention the specifics of how the visualisation was created/data was modified - it’s alright to just mention the correlation values found, and focus on the visualisation itself. The plot used was appropriate, and including the regression lines with confidence bands was effective. Adjusting the labels in your x-axis for the time series plots would be a minor tweak to improve it. Just be a bit wary about making really direct statements for your conclusion.