<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/building-a-life-table/"></div></div><div><a data-url="http://www.r-bloggers.com/building-a-life-table/" data-counturl="http://www.r-bloggers.com/building-a-life-table/" data-count="horizontal" data-text="Building a Life Table" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.exegetic.biz/blog/2016/07/building-life-table/"> R – Exegetic Analytics</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>After writing my previous post, <a target="_blank" href="http://www.exegetic.biz/blog/2016/07/mortality-year-age/">Mortality by Year and Age</a>, I’ve become progressively more interested in the mortality data. Perhaps those actuaries are onto something? I found <a target="_blank" href="http://apps.who.int/iris/handle/10665/62916">this report</a>, which has a wealth of pertinent information. On p. 13 the report gives details on constructing a <a target="_blank" href="https://en.wikipedia.org/wiki/Life_table">Life Table</a>, which is one of the fundamental tools in Actuarial Science. The <a target="_blank" href="https://github.com/DataWookie/lifespan">lifespan package</a> has all of the data required to construct a Life Table, so I created a <code>lifetable</code> data frame which has those data broken down by gender.</p>
<pre>
> library(lifespan)
> subset(lifetable, sex == &quot;M&quot;) %>% head
  x sex     lx      dx         qx
1 0   M 100000 596.534 0.00596534
2 1   M  99403 256.848 0.00258389
3 2   M  99147 174.077 0.00175575
4 3   M  98973 114.213 0.00115398
5 4   M  98858  83.082 0.00084041
6 5   M  98775  71.536 0.00072423
> subset(lifetable, sex == &quot;F&quot;) %>% head
    x sex     lx      dx         qx
133 0   F 100000 452.585 0.00452585
134 1   F  99547 203.525 0.00204450
135 2   F  99344 130.223 0.00131083
136 3   F  99214  84.746 0.00085418
137 4   F  99129  62.055 0.00062600
138 5   F  99067  54.475 0.00054988
</pre>
<p>The columns in the data above should be interpreted as follows:</p>
<ul>
<li> <code>lx</code> is the number of people who have survive to age <code>x</code>, based on an initial cohort of 100 000 people;
<li> <code>dx</code> is the expected number of people in the cohort who die aged <code>x</code> on their last birthday; and
<li> <code>qx</code> is the probability that someone aged <code>x</code> will die before reaching age <code>x+1</code>.
</ul>
<p>A plot gives a high level overview of the data. Below <code>lx</code> is plotted as a function of age. Click on the image to access an interactive <a target="_blank" href="https://plot.ly/~collierab/463/life-table/">Plotly</a> version. The cohort size has been renormalised so that <code>lx</code> is expressed as a percent. It’s readily apparent that the attrition rate is much higher for males than females, and that very few people survive beyond the age of 105.</p>
<p><a target="_blank" href="https://plot.ly/~collierab/463/life-table/"><img alt="life-table" class="wp-image-3795" src="http://i1.wp.com/www.exegetic.biz/blog/wp-content/uploads/2016/07/life-table.png?resize=456%2C342" data-recalc-dims="1"></a></p>
<p>Using these data we can also calculate some related conditional probabilities. For example, what is the probability that a person aged 70 will live for at least another 5 years?</p>
<pre>
> survival(70, 5)
      F       M 
0.87916 0.80709 
</pre>
<p>Another example, what is the probability that a person aged 70 will live for at least another 5 years but then die in the 10 years after that?</p>
<pre>
> survival(70, 5, 10)
      F       M 
0.37472 0.46714
</pre>
<p>Interesting stuff! Everything indicates that in terms of longevity, females have the upper hand.</p>
<p>Somebody made the following witty comment on LinkedIn in response to my previous post:</p>
<blockquote><p>
Just good to know that death risk visibly decreases after 100y/o. This helps.
</p>
</blockquote>
<p>Well, yes and no. In an absolute sense your risk of dying after the age of 100 is relatively low. But the reason for this is that the probability of you actually making it to the age of 100 is low. If, however, you do manage to achieve this monumental age, then your risk of dying is rather high.</p>
<pre>
> survival(100)
      F       M 
0.65813 0.60958
</pre>
<p>So men aged 100 have 39% probability of dying before reaching the age of 101, while the probability for women is 34%.</p>
<p>Note that there are also life table data in the <a target="_blank" href="https://github.com/hadley/babynames">babynames package</a>.</p>
<p>The post <a target="_blank" rel="nofollow" href="http://www.exegetic.biz/blog/2016/07/building-life-table/">Building a Life Table</a> appeared first on <a target="_blank" rel="nofollow" href="http://www.exegetic.biz/blog">Exegetic Analytics</a>.</p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/building-a-life-table/"></div></div><div><a data-url="http://www.r-bloggers.com/building-a-life-table/" data-counturl="http://www.r-bloggers.com/building-a-life-table/" data-count="vertical" data-text="Building a Life Table" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.exegetic.biz/blog/2016/07/building-life-table/"> R – Exegetic Analytics</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/EzPRv0x941I"></a></div>