Tidy Tools for Actuarial Mathematics and Life Contingencies

Provides tidyverse-aligned tools for actuarial mathematics and life contingencies, including life tables, survival probabilities, actuarial present values of cash flows, life annuities, life insurance, premiums, reserves, multiple-life calculations, Monte Carlo simulation, and deterministic cash-flow diagrams. The package emphasizes clear actuarial notation, reproducible workflows, and pipe-friendly tools for actuarial education and applied actuarial analysis.


Overview

tidyactuarial is a comprehensive R package for financial mathematics and life contingencies. It bridges the gap between classical actuarial notation (SOA/CAS standards) and the modern tidyverse workflow.

The package is designed for actuaries, students, and researchers who need reproducible, vectorized, and “tidy” actuarial calculations.

Key Features

  • Life Contingencies: Valuation of life insurance, annuities, and premiums for single and multiple lives.
  • Flexible Assumptions: Supports UDD (Uniform Distribution of Deaths), Constant Force, and Balducci assumptions for fractional ages.
  • Financial Math: Bond pricing (including callable bonds), yield curve interpolation (Spot/Forward rates), and immunization (Redington/Full).
  • Tidy Design: All main functions return tibble objects and are compatible with the native R pipe |> or %>%.

Installation

Once the package is on CRAN, you can install it with:

install.packages("tidyactuarial")
#> Installing package into 'C:/Users/LENOVO/AppData/Local/Temp/RtmpAPk2YU/temp_libpath1ae0798e3dc8'
#> (as 'lib' is unspecified)
#> 
#>   There is a binary version available but the source version is later:
#>               binary source needs_compilation
#> tidyactuarial  0.1.1  0.1.2             FALSE
#> installing the source package 'tidyactuarial'

Alternatively, you can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("julian.fajardo1908/tidyactuarial")

Quick Start

1. Life Tables and Premiums

Building a life table and calculating a net level premium for a 20-year endowment insurance:

library(tidyactuarial)

# 1. Create a life table (ensure qx has the same length as x)
ages <- 0:110
probs <- rep(0.002, length(ages)) 

lt <- lifetable(x = ages, qx = probs, radix = 100000)

# 2. Calculate net premium for a 35-year-old (20-year endowment)
# Added benefit = 100000
premium_x(
  lt = lt, 
  x = 35, 
  n = 20, 
  i = 0.05, 
  product = "endowment", 
  benefit = 100000,
  tidy = TRUE
)
#> # A tibble: 1 × 15
#>       x     m     n product benefit     k frac  premium_timing prem_start n_prem
#>   <int> <int> <int> <chr>     <dbl> <int> <chr> <chr>          <chr>       <int>
#> 1    35     0    20 endowm…  100000     1 UDD   due            issue          20
#> # ℹ 5 more variables: woolhouse <chr>, premium <dbl>, premium_annual <dbl>,
#> #   apv_benefits <dbl>, apv_premiums <dbl>

2. Bond Cash Flows

Generate a tidy schedule for a coupon bond:

bond_cash_flows(
  face = 1000, 
  coupon_rate = 0.06, 
  years_to_maturity = 5, 
  coupons_per_year = 2
)
#> # A tibble: 11 × 5
#>    cashflow_id period  time cash_flow type      
#>          <int>  <int> <dbl>     <dbl> <chr>     
#>  1           1      1   0.5        30 coupon    
#>  2           2      2   1          30 coupon    
#>  3           3      3   1.5        30 coupon    
#>  4           4      4   2          30 coupon    
#>  5           5      5   2.5        30 coupon    
#>  6           6      6   3          30 coupon    
#>  7           7      7   3.5        30 coupon    
#>  8           8      8   4          30 coupon    
#>  9           9      9   4.5        30 coupon    
#> 10          10     10   5          30 coupon    
#> 11          11     10   5        1000 redemption

References

Mathematical formulas and actuarial notation follow:

  • Finan, M. B. A Reading of the Theory of Life Contingencies.
  • Kellison, S. G. The Theory of Interest.
  • Dickson, D. C., Hardy, M. R., & Waters, H. R. Actuarial Mathematics for Life Contingent Risks.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("tidyactuarial")

0.1.6 by Julian Fajardo, 2 months ago


https://github.com/JulianFajardo1908/tidyactuarial


Report a bug at https://github.com/JulianFajardo1908/tidyactuarial/issues


Browse source code at https://github.com/cran/tidyactuarial


Authors: Julian Fajardo [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports dplyr, ggplot2, rlang, scales, stats, tibble, utils

Suggests purrr, testthat


See at CRAN