Contents

R for Life Assurances

ref: Actuarial Mathematics for Life Contingent Risks

Life Assurances
  1. Whole Life Insurance: $A_x$

  2. Temporary Life Insurance: $A_{\mathop{1\ \ \ }\limits_{x:\overline n|}}$

  3. Pure Endowment: $A_{\mathop{\ \ 1} \limits_{x:\overline n|}}$

  4. Endowment Insurance: $A_{x:\overline n|}$

  5. Deferred Whole Life Insurance: $_{u|}A_x$

  6. Increasing Whole Life Insurance: $(IA)_x$

Argument List

life_table: A life table with mortality rates $q_x$ from age 0.

age: The individual’s age at this moment.

i: A given constant interest rate.

n: A given period of temporary products.

Whole Life Insurance

1whole_life_insurance <- function(age, i, life_table){
2  qx <- life_table$qx
3  px <- 1-qx
4  kpx <- c(1,cumprod(px[(age+1):(length(px)-1)]))
5  k_qx <- kpx*qx[(age+1):length(qx)]
6  discount_factors <- (1+i) ^ - (1:(length(k_qx)))
7  sum(discount_factors * k_qx)
8}

Temporary Life Insurance

1temporary_life_insurance <- function(age, n, i, life_table){
2  qx <- life_table$qx
3  px <- 1-qx
4  kpx <- c(1,cumprod(px[(age+1):(age+n-1)]))
5  k_qx <- kpx*qx[(age+1):(age+n)]
6  discount_factors <- (1+i) ^ - (1:(length(k_qx)))
7  sum(discount_factors * k_qx)
8}

Pure Endowment

1pure_endowment <- function(age, n, i, life_table){
2  px <- 1-life_table$qx
3  npx <- prod(px[(age+1):(age+n)])
4  discount_factor <- (1+i) ^ (-n)
5  discount_factor * npx
6}

Endowment Insurance

Note
$$A_{x:\overline n|} = A_{\mathop{1\ \ \ }\limits_{x:\overline n|}} + A_{\mathop{\ \ 1} \limits_{x:\overline n|}}$$
 1endowment_insurance <- function(age, n, i, life_table){
 2  qx <- life_table$qx
 3  px <- 1-qx
 4  # temporary_life_insurance
 5  kpx <- c(1,cumprod(px[(age+1):(age+n-1)]))
 6  if ((age+1)>(age+n-1)) {kpx <- c(1)}      # fix 1
 7  k_qx <- kpx*qx[(age+1):(age+n)]
 8  discount_factors <- (1+i) ^ - (1:(length(k_qx)))
 9  # pure_endowment
10  npx <- prod(px[(age+1):(age+n)])
11  discount_factor <- (1+i) ^ (-n)
12  # output
13  discount_factor * npx + sum(discount_factors * k_qx)
14}

Deferred Whole Life Insurance

Note
The benefits are 0 if the assured dies in the first u years.
1deferred_life_insurance <- function(age, u, i, life_table){
2  qx <- life_table$qx
3  px <- 1-qx
4  kpx <- c(1,cumprod(px[(age+1):(length(px)-1)]))
5  k_qx <- kpx*qx[(age+1):(length(qx))]
6  discount_factors <- (1+i) ^ - (1:(length(k_qx)))
7  benefits <- c(rep(0,u),rep(1,(length(k_qx)-u)))
8  sum(benefits * discount_factors * k_qx)
9}

Increasing Whole Life Insurance

Note
An whole life assurance commencing at 1 and increasing 1 per annum.
1increasing_life_insurance <- function(age, i, life_table){
2  qx <- life_table$qx
3  px <- 1-qx
4  kpx <- c(1,cumprod(px[(age+1):(length(px)-1)]))
5  k_qx <- kpx*qx[(age+1):length(qx)]
6  discount_factors <- (1+i) ^ - (1:(length(k_qx)))
7  benefits <- c(1:(length(k_qx)))
8  sum(benefits * discount_factors * k_qx)
9}