MyNixOS website logo
Description

Creating Actuarial Life Tables.

Contains data and functions that can be used to make actuarial life tables. Each function adds a column to the inputted dataset for each intermediate calculation between mortality rate and life expectancy. Users can run any of our functions to complete the life table until that step, or run lifetable() to output a full life table that can be customized to remove optional columns. Methods for creating lifetables are as described in Zedstatistics (2021) <https://www.youtube.com/watch?v=Dfe59glNXAQ>.

actLifer

R-CMD-check CRANstatus

The actLifer package contains functions that create a life table based on mortality data, and ultimately calculates life expectancy from data on annual deaths for given ages/age groups. This package also contains mortality data from CDC wonder.

This package will be useful for actuaries, epidemiologists, or any data scientists working with mortality data.

Installation

You can install the development version of actLifer from GitHub with:

# install.packages("devtools")
devtools::install_github("g-rade/actLifer")

You can install the reslease version of actLifer from CRAN with:

#install.packages("actLifer")

How to use actLifer

library(actLifer)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

## Take a look at the mortality2 data fram
head(mortality2)
#> # A tibble: 6 × 3
#>   age_group deaths population
#>   <chr>      <dbl>      <dbl>
#> 1 < 1 year   23161    3970145
#> 2 1 year      1568    3995008
#> 3 2 years     1046    3992154
#> 4 3 years      791    3982074
#> 5 4 years      640    3987656
#> 6 5 years      546    4032515

## Use the lifetable function to make a custom life table with just
## CentralDeathRate, PropToSurvive, and LifeExpectancy by setting includeAllSteps = FALSE

lifetable(mortality2, "age_group", "population", "deaths", FALSE, TRUE, TRUE)
#> # A tibble: 85 × 6
#>    age_group deaths population CentralDeathRate PropToSurvive LifeExpectancy
#>    <chr>      <dbl>      <dbl>            <dbl>         <dbl>          <dbl>
#>  1 < 1 year   23161    3970145         0.00583          1               75.9
#>  2 1 year      1568    3995008         0.000392         0.994           75.3
#>  3 2 years     1046    3992154         0.000262         0.994           74.4
#>  4 3 years      791    3982074         0.000199         0.994           73.4
#>  5 4 years      640    3987656         0.000160         0.993           72.4
#>  6 5 years      546    4032515         0.000135         0.993           71.4
#>  7 6 years      488    4029655         0.000121         0.993           70.4
#>  8 7 years      511    4029991         0.000127         0.993           69.4
#>  9 8 years      483    4159114         0.000116         0.993           68.4
#> 10 9 years      462    4178524         0.000111         0.993           67.4
#> # ℹ 75 more rows


## Or show everything by setting includeAllSteps=TRUE, includeCDR=TRUE, and includePS=TRUE which are the default values
lifetable(mortality2, "age_group", "population", "deaths")
#> # A tibble: 85 × 11
#>    age_group deaths population CentralDeathRate ConditionalProbDeath
#>    <chr>      <dbl>      <dbl>            <dbl>                <dbl>
#>  1 < 1 year   23161    3970145         0.00583              0.00582 
#>  2 1 year      1568    3995008         0.000392             0.000392
#>  3 2 years     1046    3992154         0.000262             0.000262
#>  4 3 years      791    3982074         0.000199             0.000199
#>  5 4 years      640    3987656         0.000160             0.000160
#>  6 5 years      546    4032515         0.000135             0.000135
#>  7 6 years      488    4029655         0.000121             0.000121
#>  8 7 years      511    4029991         0.000127             0.000127
#>  9 8 years      483    4159114         0.000116             0.000116
#> 10 9 years      462    4178524         0.000111             0.000111
#> # ℹ 75 more rows
#> # ℹ 6 more variables: ConditionalProbLife <dbl>, NumberToSurvive <dbl>,
#> #   PropToSurvive <dbl>, PersonYears <dbl>, TotalYears <dbl>,
#> #   LifeExpectancy <dbl>

Contributors

Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows