The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Using lifepack

Introduction

The lifepack package provides functions for actuarial calculations, including calculating reserves and equivalence premiums.

Example Usage

Here’s an example of how to calculate an equivalence premium:

Lambda <- function(x) {

  A <- matrix(0, 3, 3)
  

  A[1, 2] <- (0.0004 + 10^(4.54 + 0.06*(x+30)-10))*ifelse(x <= 35, 1, 0)
  A[1,3]  <- A[1,2]
  A[2,1] <- 2.0058 * exp(-0.117*(x+30)) * ifelse(x <= 35,1,0)
  A[2,3] <- A[1,3]*(1+ifelse(x <= 35,1,0))

  row_sums <- rowSums(A)
  diag(A) <- -row_sums
  
  return(A)
}


R <- function(x, mu) {
  if (x <= 35) {
    return(diag(c(-mu , 400000, 0)))
  } else {
    return(diag(c(400000, 400000,0)))
  }
}

dR <- function(x, mu) {
  if (x <= 35) {
    return(diag(c(-1, 0,0)))
  } else {
    return(diag(c(0,0,0)))
  }
}

rentefun <- function(x) { 0.01 + 0.001 * x }  # Dynamic interest rate


prodint(Lambda, 0,80, 1000)
##           [,1]      [,2]      [,3]
## [1,] 0.6572258 0.1359935 0.2067807
## [2,] 0.2598361 0.4465930 0.2935709
## [3,] 0.0000000 0.0000000 1.0000000
reserve(0, 80, Lambda, R, mu = 200000, r = 0.01, n = 1000)
##         [,1]    [,2]      [,3]
## [1,] 2834211 1037175 -863849.8
## [2,] 2142376 9268142 1904721.3
## [3,]       0       0       0.0
sreserve(0,80, Lambda, R, mu=200000, r = rentefun, 1000)
##            [,1]       [,2]      [,3]
## [1,] -1619148.8  -30521.54 -777564.2
## [2,]   345286.6 5079828.40 1707474.1
## [3,]        0.0       0.00       0.0
equiv_premium(0, 1, Lambda, R, dR, mu = 0.05, r = 0.03, n = 1000)
## [1] 378206.6

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.