16 October 2015

Agenda

  • Introduction to R

  • Mortality Overview

  • Mortality Models
    • Classical
    • Stochastic
  • Workshop: Stochastic Mortality Models in R
    • Models Fitting
    • Mortality Projection - Forecasting
    • Portfolio Analysis of BEL and SCR
  • Case Studies

What is R?

R Highlights

  • Free, open source, community based statistical software and programming language
  • Main usage: Statistical and numerical computing, Data Analysis, Data Visualisation
  • Under GNU GPL (General Public License) allowing commercial usage
  • Power of R in its packages
  • Enterprise version - Revolution Analytics (Microsoft)

“Everything that exists [in R] is an object. Everything that happens [in R] is a function call.” - John Chambers

RStudio

Most popular Environment to run R

http://www.rstudio.com/products/rstudio/

Free & Open-Source Integrated Development Environment (IDE) for R

Features:

  1. Built-in R console
  2. R, LaTeX, HTML, C++ syntax highlighting, R code completion
  3. Easy management of multiple projects
  4. Integrated R documentation
  5. Interactive debugger
  6. Package development tools

Note: R must be installed first!

Playing with R

Type in the interactive console:

3 + 3
## [1] 6
getwd()
## [1] "C:/Users/omierzwa/Documents/GitHub/Insurance"
1:10
##  [1]  1  2  3  4  5  6  7  8  9 10

Playing with R

Type in the interactive console:

x <- 1:10 # "name <- value returns the value invisibly"
x
##  [1]  1  2  3  4  5  6  7  8  9 10
(x <- 1:10) # creates x and prints it
##  [1]  1  2  3  4  5  6  7  8  9 10

Operations in R

x + y addition

x - y substraction

x * y multiplication

x / y division

x ^ y exponention

x %% y devision remainder

x %/% y integer division

numeric vector operator numeric vector –> numeric vector

Vectors

(x <- 11:20) # exemplary vector
##  [1] 11 12 13 14 15 16 17 18 19 20
x[1] # first
## [1] 11
x[length(x)] # last element using length function
## [1] 20
x[c(1, length(x), 1)] # first, last and first again
## [1] 11 20 11

Vectors

x[1000] # no such element
## [1] NA
x * 3 # multiplication
##  [1] 33 36 39 42 45 48 51 54 57 60
y <- 1:10
x * y
##  [1]  11  24  39  56  75  96 119 144 171 200

R in Insurance

  • Main focus Non-life
    • fit loss distributions and perform credibility analysis - package actuar
    • estimate loss reserves - package ChainLadder
  • Financial analysis
    • packages YieldCurve, termstrc
  • Life insurance
    • handle demography data - package demography
    • demography projections - package LifeTables
    • actuarial and financial mathematics - package lifecontingencies
    • Life models - packages ilc, LifeMetrics, StMoMo

.

Mortality Overview

Mortality Overview

Basic quantities in the analysis of mortality

  • Survival function

\(s_{x} = Pr (X > x)\)

  • Probability that (x) will survive for another t

\(p_{xt} = s_{x+t}/s_{x}\)

  • Probability that (x) will die within t years

\(q_{xt} = [s_{x} - s_{x+t}]/s_{x}\)

  • Mortality intensity (hazard function or force of mortality)

\(\mu_{x} = lim_{h \to 0} 1/h * q_{xh}\)

Probability that (x) will die within h

Mortality Features

Mortality Features

Mortality Features

Mortality Features

.

Mortality Models

Mortality Models

Drawing

Classic Models

Drawing

Classic Models

Some special parametric laws of mortality

  • De Moivre

\(\mu_{x} = 1/ (ω – x)\) subject to \(0 \leq x < ω\)

  • Gompertz

\(\mu_{x} = Bc^{x}\) subject to \(x \geq 0, B>0, c>1\)

  • Makeham

\(\mu_{x} = A + Bc^{x}\) subject to \(x \geq 0, B>0, c>1, A>=-B\)

  • Thiele

\(\mu_{x} = B_{1}C_{1}^{-x}+B_{2}C_{2}^{[-1/2(x-k)^2]}+B_{3}C_{3}^{x}\) subject to \(x\geq 0, B_{1}, B_{2}, B_{3}>0, C_{1}, C_{2}, C_{3}>1\)

Classic Models

Advantages:

  • Compact, small numbers of parameters
  • Highly interpretable
  • Good for comparative work

Disadvantages:

  • Almost certainly “wrong”
  • Too simplistic
  • Struggle with a new source of mortality

Stochastic Models

Drawing

Stochastic Models

Drawing

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

Predictor

\(\hat{\mu}_{x}(t)\)

Predictor

\(\hat{\mu}_{x}(t) = \alpha_{x}\)

Predictor

\(\hat{\mu}_{x}(t) = \alpha_{x} + \kappa_{t}\)

Predictor

\(\hat{\mu}_{x}(t) = \alpha_{x} + \beta_{x} \kappa_{t}\)

Predictor

\(\hat{\mu}_{x}(t) = \alpha_{x} + \sum^{N}_{i=1} \beta^{i}_{x} \kappa^{i}_{t}\) \(N\) - number of age-period terms

Predictor

\(\hat{\mu}_{x}(t) = \alpha_{x} + \sum^{N}_{i=1} \beta^{i}_{x} \kappa^{i}_{t} + \gamma_{t-x}\) \(N\) - number of age-period terms

Predictor

\(\hat{\mu}_{x}(t) = \alpha_{x} + \sum^{N}_{i=1} \beta^{i}_{x} \kappa^{i}_{t} + \beta^{0}_{x} \gamma_{t-x}\) \(N\) - number of age-period terms

Cohort effect

testglsnapshot
You must enable Javascript to view this page properly.

Models Predictor

Generalised Age-Period-Cohort Stochastic Mortality Models

  • Lee-Carter (LC)
    \(\hat{\mu_{xt}} = \alpha_{x} + \beta^{(1)}_{x} \kappa^{(1)}_{t}\)
  • Age-Period-Cohort (APC)
    \(\hat{\mu_{xt}} = \alpha_{x} + \kappa^{(1)}_{t} +\gamma_{t-x}\)
  • Cairns-Blake Dowd (CBD)
    \(\hat{\mu_{xt}} = \kappa^{(1)}_{t} + (x-\bar{x})\kappa^{(2)}_{t}\)
  • Renshaw and Haberman (RH)
    \(\hat{\mu_{xt}} = \alpha_{x} + \beta^{(1)}_{x} \kappa^{(1)}_{t} + \gamma_{t-x}\)

Models Predictor

Generalised Age-Period-Cohort Stochastic Mortality Models

  • Quadratic CBD with cohort effects M6
    \(\hat{\mu_{xt}} = \kappa^{(1)}_{t} + (x-\bar{x})\kappa^{(2)}_{t} +\gamma_{t-x}\)
  • Quadratic CBD with cohort effects M7
    \(\hat{\mu_{xt}} = \kappa^{(1)}_{t} + (x-\bar{x})\kappa^{(2)}_{t} + ((x-\bar{x})^2-\hat{\sigma^{2}_{x}}) \kappa^{3}_{t}\)
  • Quadratic CBD with cohort effects M8
    \(\hat{\mu_{xt}} = \kappa^{(1)}_{t} + (x-\bar{x})\kappa^{(2)}_{t} + (x_{c}-x)\gamma_{t-x}\)
  • Plat
    \(\hat{\mu_{t}} = \alpha_{x} + \kappa^{(1)}_{t} + (x-\bar{x})\kappa^{(2)}_{t} + \gamma_{t-x}\)

Model Comparison

Drawing

Random Component

The numbers of deaths \(D_{xt}\) are independent

\(D_{xt}\) follows a Poisson or a Binomial distribution

Link Function

Parameter Constraints

  • Most stochastic mortality models not identifiable up to a transformation

  • Therefore parameter constraints required to ensure unique parameter estimates

  • Parameter constraints applied through constraint function

Stochastic Models

Models sensitive to:

  • Historical data

  • Assumptions made

Good practice

  • Understand and validate data

  • Understand models and their assumptions

  • Test several methods

  • Compare and validate results

.

R Workshop

Case Study

  • Dutch mortality data from Human Mortality Database

  • Look at mortality models: LC, APC, CBD, RH, M6-M8, PLAT
    • Fit models
    • Analyse model fit
    • Project mortalities
  • Benchmark against AG table

  • BEL and SCR Projection for a portfolio

  • Writting own packages in R

R getting started

  • Set working directory Session > Set Working Directory > Choose Directory… or press Ctrl+Shift+H and select the folder or use the console
setwd('<directory name>') # wrapped in '' 
## for Windows the path uses / instead \

Exercises

  • Shock in the portfolio: everybody 5 years younger
  • Mortality projection based on shorter historical data: 1989 instead 1950
    • Exclude RH model (problems with convergence)

References