Freakonometrics

To content | To menu | To search

Tag - Rmetrics

Entries feed - Comments feed

Saturday, June 23 2012

Actuarial models with R, Meielisalp

I will be giving a short course in Switzerland next week, at the 6th R/Rmetrics Meielisalp Workshop & Summer School on Computational Finance and Financial Engineering organized by ETH Zürich, https://www.rmetrics.org/. The long version of the slides for the course on Actuarial models with R can be found online with the #Rmetrics tag, and the short version will be uploaded soon. There will be some practicals, based on Swiss mortality table for the part on demography. The datasets can be uploaded using the following code,

DEATH=read.table(
"http://freakonometrics.free.fr/DeathsSwitzerland.txt",
header=TRUE,skip=2)
EXPOSURE=read.table(
"http://freakonometrics.free.fr/ExposuresSwitzerland.txt",
header=TRUE,skip=2)
DEATH$Age=as.numeric(as.character(DEATH$Age))
DEATH=DEATH[-which(is.na(DEATH$Age)),]
EXPOSURE$Age=as.numeric(as.character(EXPOSURE$Age))
EXPOSURE=EXPOSURE[-which(is.na(EXPOSURE$Age)),]
  • based on those datasets, plot the log mortality rates for male and female,

  • for those two datasets, plot the log mortality rates in 1900 and 1950, respectively
  • for those two datasets, plot the log mortality rates for the cohort born on 1900 and 1950, respectively
  • on the total dataset (male and female), fit a Lee-Carter model. Plot the age coefficients

  • plot the time coefficients and propose a forecast for that series of estimators.

  • plot the residuals obtained from the regression

  • using those estimates, and the forecasts, project the log-mortality rates

  • extrapolate the survival function of an insured aged 40 in 2000, and compare it with the one obtained on the longitudinal dataset.

  • based on those survival functions, compute actuarial present values for several quantities, e.g. whole life annuities for some insured aged 40, and whole life insurances, and compare those values from 1900 till 2040 (on the graphs below, titles were inverted).

Then, we will briefly mention payment triangles. We will work on the triangle used on http://rworkingparty.wikidot.com/ that can be downloaded below,
OthLiabData=read.csv(
"http://www.casact.org/research/reserve_data/othliab_pos.csv",
header=TRUE, sep=",")
library(plyr)
OL=SumData=ddply(OthLiabData,.(AccidentYear,DevelopmentYear,
DevelopmentLag),summarise,IncurLoss=sum(IncurLoss_H1-BulkLoss_H1),
CumPaidLoss=sum(CumPaidLoss_H1), EarnedPremDIR=
sum(EarnedPremDIR_H1))
LossTri <- as.triangle(OL, origin="AccidentYear",
dev="DevelopmentLag", value="IncurLoss")
Year=as.triangle(OL, origin="AccidentYear",
dev="DevelopmentLag", value="DevelopmentYear")
TRIANGLE=LossTri
TRIANGLE[Year>1997]=NA
Here, the triangle looks like that
> TRIANGLE
dev
origin      1      2      3      4      5      6      7      8      9     10
1988 128747 195938 241180 283447 297402 308815 314126 317027 319135 319559
1989 135147 208767 270979 304488 330066 339871 344742 347800 353245     NA
1990 152400 238665 297495 348826 359413 364865 372436 372163     NA     NA
1991 151812 266245 357430 400405 423172 442329 460713     NA     NA     NA
1992 163737 269170 347469 381251 424810 451221     NA     NA     NA     NA
1993 187756 358573 431410 476674 504667     NA     NA     NA     NA     NA
1994 210590 351270 486947 581599     NA     NA     NA     NA     NA     NA
1995 213141 351363 444272     NA     NA     NA     NA     NA     NA     NA
1996 237162 378987     NA     NA     NA     NA     NA     NA     NA     NA
1997 220509     NA     NA     NA     NA     NA     NA     NA     NA     NA
  • suggest an estimation for the amount of reserves, all years.
  • using a Poisson regression, propose a VaR with level 99.5% for future payments, for all claims that already occurred.

Wednesday, June 6 2012

Claims reserving and IBNR with R

Following previous posts on life contingencies and longevity and mortality models, I upload additional material for the short course at the 6th R/Rmetrics Meielisalp Workshop & Summer School on Computational Finance and Financial Engineering organized by ETH Zürich, https://www.rmetrics.org/. The third part of the talk (on Actuarial models with R) will be dedicated to IBNR and claims reserving. A complete set of slides can be downloaded from the blog, but again, only some part will be presented. Note that the slides start with a parallel between mortality tables (in life insurance) and payment triangles (in non-life insurance).

Once again, the codes are from a book on actuarial science in R, written with Christophe Dutang and Vincent Goulet (so far in French) that should appear, some day... The code used in the slides above are based on the following datasets,

> source("http://perso.univ-rennes1.fr/arthur.charpentier/
+ bases.R")
We will built our own functions to derive all quantities. One function used can be found here
> source("http://perso.univ-rennes1.fr/arthur.charpentier/
+ merz-wuthrich-triangle.R")
Finally, note that most of the code can be found in the following library
> library(ChainLadder)

Monday, June 4 2012

Longevity and mortality dynamics with R

Following the previous post on life contingencies and actuarial models in life insurance, I upload additional material for the short course at the 6th R/Rmetrics Meielisalp Workshop & Summer School on Computational Finance and Financial Engineering organized by ETH Zürich, https://www.rmetrics.org/. The second part of the talk (on Actuarial models with R) will be dedicated to longevity and mortality. A complete set of slides can be downloaded from the blog, but again, only some part will be presented.

As mentioned earlier, the codes are from a book on actuarial science in R, written with Christophe Dutang and Vincent Goulet (so far in French) that should appear, some day... The code used in the slides above can be downloaded from here, and datasets are the following,

> DEATH <- read.table(
+ "http://freakonometrics.free.fr/Deces-France.txt",
+ header=TRUE)
> EXPO  <- read.table(
+ "http://freakonometrics.free.fr/Exposures-France.txt",
+ header=TRUE,skip=2)

For additional resources, I will use Rob Hyndman's package on demography, Heather Turner and David Firth's package on generalized nonlinear models (e.g. the slides of the short course Heather gave in Rennes at the UseR! conference in 2009), as well as functions developed by JPMorgan's LifeMetrics (functions are  fully documented in the LifeMetrics Technical Document). All those functions can be obtained using

> library(demography)
> library(gnm)
> source("http://freakonometrics.free.fr/fitModels.R")

Friday, June 1 2012

Life contingencies with R

I will be giving in less than four weeks a short course at the 6th R/Rmetrics Meielisalp Workshop & Summer School on Computational Finance and Financial Engineering organized by ETH Zürich, https://www.rmetrics.org/. The talk will be on Actuarial models with R, and first part will be dedicated to life insurance. A complete set of slides can be downloaded from the blog, but in the talk, only some part will be presented.

The codes are from a book on actuarial science in R, written with Christophe Dutang and Vincent Goulet (so far in French) that should appear, some day... The code used in the slides can be downloaded from here, and datasets are the following,

> TD <- read.table(
+ "http://perso.univ-rennes1.fr/arthur.charpentier/TD8890.csv",
+ sep=";",header=TRUE)
> TV <- read.table(
+ "http://perso.univ-rennes1.fr/arthur.charpentier/TV8890.csv",
+ sep=";",header=TRUE)

For additional resources, I recommend Emiliano's website, http://www.math.uconn.edu/, with great lectures on life insurance mathematics, and the (new) lifecontinfencies vignette on http://cran.r-project.org/,

> library(lifecontingencies)