SlideShare a Scribd company logo
1 of 41
Download to read offline
Intro to the lifecontingencies R package
Giorgio Alfredo Spedicato, Ph.D C.Stat ACAS
19th April 2015
Intro
The lifecontingencies package (Spedicato 2013) will be
introduced.
Intro
The lifecontingencies package (Spedicato 2013) will be
introduced.
As first half 2015 it is the first R (Team 2012) package
merging demographic and financial mathematics function in
order to perform actuarial evaluation of life contingent
insurances (annuities, life insurances, endowments, etc).
Intro
The lifecontingencies package (Spedicato 2013) will be
introduced.
As first half 2015 it is the first R (Team 2012) package
merging demographic and financial mathematics function in
order to perform actuarial evaluation of life contingent
insurances (annuities, life insurances, endowments, etc).
The applied examples will shown: how to load the R package,
how to perform basic financial mathematics and demographic
calculations, how to price and reserve financial products.
The final example will show how to mix lifecontingencies and
demography (Rob J Hyndman et al. 2011) function to assess
the mortality development impact on annuities.
The final example will show how to mix lifecontingencies and
demography (Rob J Hyndman et al. 2011) function to assess
the mortality development impact on annuities.
The interested readers are suggested to look to the package’s
vignettes (also appeared in the Journal of Statistical Sofware)
for a broader overview. (Dickson, Hardy, and Waters 2009; and
Mazzoleni 2000) provide and introduction of Actuarial
Mathematics theory.
The final example will show how to mix lifecontingencies and
demography (Rob J Hyndman et al. 2011) function to assess
the mortality development impact on annuities.
The interested readers are suggested to look to the package’s
vignettes (also appeared in the Journal of Statistical Sofware)
for a broader overview. (Dickson, Hardy, and Waters 2009; and
Mazzoleni 2000) provide and introduction of Actuarial
Mathematics theory.
Also (Charpentier 2012) and (Charpentier 2014) discuss the
software.
First moves into the lifecontingecies package
Loading the package
The package is loaded using
library(lifecontingencies) #load the package
First moves into the lifecontingecies package
Loading the package
The package is loaded using
library(lifecontingencies) #load the package
It requires a recent version of R (>=3.0) and the markovchain
package (Spedicato 2015). The development version of the
package requires also Rcpp package (Eddelbuettel 2013).
Financial mathematics
Actuarial mathematics calculation applies probability to
quantify uncertainty on present values calculation.
capitals <- c(-1000,200,500,700)
times <- c(0,1,2,5)
#calculate a present value
presentValue(cashFlows=capitals, timeIds=times,
interestRates=0.03)
## [1] 269.2989
Financial mathematics
Actuarial mathematics calculation applies probability to
quantify uncertainty on present values calculation.
Certain present value calculations can be directly evaluated by
the package
capitals <- c(-1000,200,500,700)
times <- c(0,1,2,5)
#calculate a present value
presentValue(cashFlows=capitals, timeIds=times,
interestRates=0.03)
## [1] 269.2989
The presentValue function is the kernel of functions that are
used to calculate annuities and accumulated values, also paid
in fractional k payments.
ann1 <- annuity(i=0.03, n=5, k=1, type="immediate")
ann2 <- annuity(i=0.03, n=5, k=12, type="due")
c(ann1,ann2)
## [1] 4.579707 4.653791
Such functions can be combined to price bonds and other
classical financial products.
bondPrice<-5*annuity(i=0.03,n=10)+100*1.03^-10
bondPrice
## [1] 117.0604
Such functions can be combined to price bonds and other
classical financial products.
The following code exemplifies the calculation of a 5% coupon
bond at 3% yield rate when the term is ten year.
bondPrice<-5*annuity(i=0.03,n=10)+100*1.03^-10
bondPrice
## [1] 117.0604
Managing lifetables and actuarial tables
A lifetable object is an S4 class comprised by three slots: the
age (from 0 to ω), the people at risk at beginning of age x and
the table name.
#create an demo lifetable
xDemo<-seq(from=0,to=5,by=1)
lxDemo<-c(100,95,90,60,30,5)
lifetableDemo<-new("lifetable",x=xDemo,
lx=lxDemo,name="Demo")
In practice, it is often more convenient to load an existing table
from a CSV or XLS source. Some common tables have been
bundled as data.frames within the package.
data(demoIta) #using the internal Italian LT data set
lxIPS55M <- with(demoIta, IPS55M)
#performing some fixings
pos2Remove <- which(lxIPS55M %in% c(0,NA))
lxIPS55M <-lxIPS55M[-pos2Remove]
xIPS55M <-seq(0,length(lxIPS55M)-1,1)
#creating the table
ips55M <- new("lifetable",x=xIPS55M,
lx=lxIPS55M,name="IPS 55 Males")
In practice, it is often more convenient to load an existing table
from a CSV or XLS source. Some common tables have been
bundled as data.frames within the package.
The example that follows creates the Italian IPS55 life table.
data(demoIta) #using the internal Italian LT data set
lxIPS55M <- with(demoIta, IPS55M)
#performing some fixings
pos2Remove <- which(lxIPS55M %in% c(0,NA))
lxIPS55M <-lxIPS55M[-pos2Remove]
xIPS55M <-seq(0,length(lxIPS55M)-1,1)
#creating the table
ips55M <- new("lifetable",x=xIPS55M,
lx=lxIPS55M,name="IPS 55 Males")
It is therefore easy to perform standard demographic
calculations with the aid of package functions.
# decrements between age 65 and 70
dxt(ips55M, x = 65, t = 5)
## [1] 3659.74
# probabilities of death between age 80 and 85
qxt(ips55M, x = 80, t = 2)
## [1] 0.07264833
# expected curtate lifetime
exn(ips55M, x = 65)
## [1] 21.96873
Pricing and reserving Life Contingent insurances
The pricing and reserving of pure endowments A 1
x:n , term
insurances, A1
x:n , annuities ¨a
{m}
x , endowments A 1
x:n can be
easily handled within the package.
#creates a new actuarial table
ips55Act<-new("actuarialtable",
x=ips55M@x,lx=ips55M@lx,
interest=0.02,name="IPS55M")
Pricing and reserving Life Contingent insurances
The pricing and reserving of pure endowments A 1
x:n , term
insurances, A1
x:n , annuities ¨a
{m}
x , endowments A 1
x:n can be
easily handled within the package.
Performing such actuarial calculations requires to create an
actuarial table (similar to a lifetable but with one more slot for
the interest rate) that can be create as it is shown below.
#creates a new actuarial table
ips55Act<-new("actuarialtable",
x=ips55M@x,lx=ips55M@lx,
interest=0.02,name="IPS55M")
The example that follows computes the yearly premium
P = 50000 ∗ 35E30
¨a
30:35
for a pure endowment on 50K capital.
#compute APV
APV=50e3*Exn(actuarialtable =
ips55Act,x=30,n=35)
#compute Premium
P=APV/axn(actuarialtable =
ips55Act,x=30,n=35)
c(APV,P)
## [1] 23584.7564 938.1422
The package allows to easily perform sensitivities on the
financials changing key parameters like term, interest, etc as we
can see on a endowment purchased by a 30 years old
policyholder for 30 years.
#defining the ranges
interest.range<-seq(from=0.015, to=0.035,by=0.001)
term.range<-seq(from=20, to=40,by=1)
#computing APV sensitivities
apv.interest.sensitivity<-sapply(interest.range,
FUN = "AExn",actuarialtable=ips55Act,x=30,n=30)
apv.term.sensitivity<-sapply(term.range,FUN = "AExn",
actuarialtable=ips55Act,x=30)
The graph below displays sensitivities on APV varying interest
rate and insurance term.
0.015 0.025 0.035
0.400.450.500.550.600.65
APV by Interest Rate
interest rate
APV
20 30 40
0.500.550.600.65
APV by term
term
APV
Also, calculation of outstanding reserves is made easy as the
following example, applied on a 100K face value 40 year term
term life insurance with payments made yearly on a
policyholder aged 25, shows.
#compute the APV and premium
APV=100e3*Axn(actuarialtable = ips55Act,x=25,n=40)
P=APV/axn(actuarialtable = ips55Act,x=25,n=40)
#define a reserve function
reserveFunction<-function(t)
100e3*Axn(actuarialtable = ips55Act,x=25+t,n=40-t) -
P *axn(actuarialtable = ips55Act,x=25+t,n=40-t)
reserve<-sapply(0:40,reserveFunction)
0 10 20 30 40
050010001500 Reserve
Policy Age
Reserveoutstanding
Stochastic evalutation
The APV of a life contingent insurance is the expected value of
a function of a random variable (the residual life time).
Knowing the interest rate and the underlying life table it is
possible both to compute the APV and to assess the
distribution of the underlying life insurance.
#analyzing and Endowment of 100K on x=40, n=25
#compute APV
APV=AExn(actuarialtable = ips55Act,x=40,n=25)
#sampling
AEXnDistr<-rLifeContingencies(n=10e3,
lifecontingency = "AExn",x = 40,
t=25,object = ips55Act)
In order to assess if the distribution is unbiased we use a
classical one sample t - test.
#assess if the expected value match the theoretical one
t.test(x=AEXnDistr,mu = APV)
##
## One Sample t-test
##
## data: AEXnDistr
## t = 1.3102, df = 9999, p-value = 0.1902
## alternative hypothesis: true mean is not equal to 0.6148
## 95 percent confidence interval:
## 0.6146427 0.6159746
## sample estimates:
## mean of x
## 0.6153086
Endowment Actuarial Value Distribution
AEXnDistr
Density
0.6 0.7 0.8 0.9 1.0
010203040
Assessing longevity impact on annuities using
lifecontingencies and demography
This part of the presentation will make use of the demography
package to calibrate Lee Carter (Lee and Carter 1992) model,
log (µx,t) = ax + bx ∗ kt → px,t = exp−µx,t ,projecting
mortality and implicit life tables.
#load the package and the italian tables
library(demography)
#italy.demo<-hmd.mx("ITA", username="yourUN",
#password="yourPW")
load(file="mortalityDatasets.RData") #load the dataset
Lee Carter model is calibrated using lca function.
#calibrate lee carter
italy.leecarter<-lca(data=italyDemo,series="total",
max.age=103,adjust = "none")
#perform modeling of kt series
kt.model<-auto.arima(italy.leecarter$kt)
#projecting the kt
kt.forecast<-forecast(kt.model,h=100)
Lee Carter model is calibrated using lca function.
Then an arima model is used to project (extrapolate) the
underlying kt over the historical period.
#calibrate lee carter
italy.leecarter<-lca(data=italyDemo,series="total",
max.age=103,adjust = "none")
#perform modeling of kt series
kt.model<-auto.arima(italy.leecarter$kt)
#projecting the kt
kt.forecast<-forecast(kt.model,h=100)
-The code below generates the matrix of prospective life tables
#indexing the kt
kt.full<-ts(union(italy.leecarter$kt, kt.forecast$mean),
start=1872)
#getting and defining the life tables matrix
mortalityTable<-exp(italy.leecarter$ax
+italy.leecarter$bx%*%t(kt.full))
rownames(mortalityTable)<-seq(from=0, to=103)
colnames(mortalityTable)<-seq(from=1872,
to=1872+dim(mortalityTable)[2]-1)
historical and projected KT
year
kt
1900 1950 2000 2050 2100
−300−200−1000100
now we need a function that returns the one-year death
probabilities given a year of birth (cohort.
getCohortQx<-function(yearOfBirth)
{
colIndex<-which(colnames(mortalityTable)
==yearOfBirth) #identify
#the column corresponding to the cohort
#definex the probabilities from which
#the projection is to be taken
maxLength<-min(nrow(mortalityTable)-1,
ncol(mortalityTable)-colIndex)
qxOut<-numeric(maxLength+1)
for(i in 0:maxLength)
qxOut[i+1]<-mortalityTable[i+1,colIndex+i]
#fix: we add a fictional omega age where
#death probability = 1
qxOut<-c(qxOut,1)
return(qxOut)
}
Now we use such function to obtain prospective life tables and
to perform actuarial calculations. For example, we can
compute the APV of an annuity on a workers’ retiring at 65
assuming he were born in 1920, in 1950 and in 1980. We will
use the interest rate of 1.5% (the one used to compute Italian
Social Security annuity factors).
#generate the life tables
qx1920<-getCohortQx(yearOfBirth = 1920)
lt1920<-probs2lifetable(probs=qx1920,type="qx",
name="Table 1920")
at1920<-new("actuarialtable",x=lt1920@x,
lx=lt1920@lx,interest=0.015)
qx1950<-getCohortQx(yearOfBirth = 1950)
lt1950<-probs2lifetable(probs=qx1950,
type="qx",name="Table 1950")
at1950<-new("actuarialtable",x=lt1950@x,
lx=lt1950@lx,interest=0.015)
qx1980<-getCohortQx(yearOfBirth = 1980)
Now we use such function to obtain prospective life tables and
to perform actuarial calculations. For example, we can
compute the APV of an annuity on a workers’ retiring at 65
assuming he were born in 1920, in 1950 and in 1980. We will
use the interest rate of 1.5% (the one used to compute Italian
Social Security annuity factors).
The first step is to generate the life and actuarial tables
#generate the life tables
qx1920<-getCohortQx(yearOfBirth = 1920)
lt1920<-probs2lifetable(probs=qx1920,type="qx",
name="Table 1920")
at1920<-new("actuarialtable",x=lt1920@x,
lx=lt1920@lx,interest=0.015)
qx1950<-getCohortQx(yearOfBirth = 1950)
lt1950<-probs2lifetable(probs=qx1950,
type="qx",name="Table 1950")
at1950<-new("actuarialtable",x=lt1950@x,
lx=lt1950@lx,interest=0.015)
qx1980<-getCohortQx(yearOfBirth = 1980)
Now we can evaluate ¨a65 and ˚e65 for workers born in 1920,
1950 and 1980 respectively.
cat("Results for 1920 cohort","n")
## Results for 1920 cohort
c(exn(at1920,x=65),axn(at1920,x=65))
## [1] 16.51391 15.14127
cat("Results for 1950 cohort","n")
## Results for 1950 cohort
c(exn(at1950,x=65),axn(at1950,x=65))
## [1] 18.72669 16.83391
cat("Results for 1980 cohort","n")
Bibliography I
Charpentier, Arthur. 2012. “Actuarial Science with R 2: Life
Insurance and Mortality Tables.”
http://freakonometrics.blog.free.fr/index.php?post/
2012/04/04/Life-insurance,-with-R,-Meielisalp.
———. 2014. Computational Actuarial Science. The R Series.
Cambridge University Press.
Dickson, D.C.M., M.R. Hardy, and H.R. Waters. 2009. Actuarial
Mathematics for Life Contingent Risks. International Series on
Actuarial Science. Cambridge University Press.
Eddelbuettel, Dirk. 2013. Seamless R and C++ Integration with
Rcpp. New York: Springer.
Lee, R.D., and L.R. Carter. 1992. “Modeling and Forecasting U.S.
Mortality.” Journal of the American Statistical Association 87 (419):
659–75. doi:10.2307/2290201.
Bibliography II
Mazzoleni, P. 2000. Appunti Di Matematica Attuariale. EDUCatt
Università Cattolica.
Rob J Hyndman, Heather Booth, Leonie Tickle, and John
Maindonald. 2011. demography: Forecasting Mortality, Fertility,
Migration and Population Data.
http://CRAN.R-project.org/package=demography.
Spedicato, Giorgio Alfredo. 2013. “The lifecontingencies Package:
Performing Financial and Actuarial Mathematics Calculations in R.”
Journal of Statistical Software 55 (10): 1–36.
http://www.jstatsoft.org/v55/i10/.
———. 2015. markovchain: discrete Time Markov Chains Made
Easy.
Team, R Development Core. 2012. R: A Language and Environment
for Statistical Computing. Vienna, Austria: R Foundation for
Statistical Computing. http://www.R-project.org/.

More Related Content

What's hot

Risk and Risk Aversion FM
Risk and Risk Aversion FMRisk and Risk Aversion FM
Risk and Risk Aversion FMFellowBuddy.com
 
Pricing interest rate derivatives (ext)
Pricing interest rate derivatives (ext)Pricing interest rate derivatives (ext)
Pricing interest rate derivatives (ext)Swati Mital
 
Decision Tree for Predictive Modeling
Decision Tree for Predictive ModelingDecision Tree for Predictive Modeling
Decision Tree for Predictive ModelingEdureka!
 
Local and Stochastic volatility
Local and Stochastic volatilityLocal and Stochastic volatility
Local and Stochastic volatilitySwati Mital
 
Stochastic Vol Forecasting
Stochastic Vol ForecastingStochastic Vol Forecasting
Stochastic Vol ForecastingSwati Mital
 
1st Québec-Ontario Workshop on Insurance Mathematics
1st Québec-Ontario Workshop on Insurance Mathematics1st Québec-Ontario Workshop on Insurance Mathematics
1st Québec-Ontario Workshop on Insurance MathematicsArthur Charpentier
 

What's hot (8)

Exam binder 1
Exam binder 1Exam binder 1
Exam binder 1
 
Risk and Risk Aversion FM
Risk and Risk Aversion FMRisk and Risk Aversion FM
Risk and Risk Aversion FM
 
Pricing interest rate derivatives (ext)
Pricing interest rate derivatives (ext)Pricing interest rate derivatives (ext)
Pricing interest rate derivatives (ext)
 
Decision Tree for Predictive Modeling
Decision Tree for Predictive ModelingDecision Tree for Predictive Modeling
Decision Tree for Predictive Modeling
 
Local and Stochastic volatility
Local and Stochastic volatilityLocal and Stochastic volatility
Local and Stochastic volatility
 
Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
 
Stochastic Vol Forecasting
Stochastic Vol ForecastingStochastic Vol Forecasting
Stochastic Vol Forecasting
 
1st Québec-Ontario Workshop on Insurance Mathematics
1st Québec-Ontario Workshop on Insurance Mathematics1st Québec-Ontario Workshop on Insurance Mathematics
1st Québec-Ontario Workshop on Insurance Mathematics
 

Similar to Introduction to lifecontingencies R package

PATTEM JAGADESH_21mt0269_research proposal presentation.pptx
PATTEM JAGADESH_21mt0269_research proposal presentation.pptxPATTEM JAGADESH_21mt0269_research proposal presentation.pptx
PATTEM JAGADESH_21mt0269_research proposal presentation.pptxPATTEMJAGADESH
 
Insurance Optimization
Insurance OptimizationInsurance Optimization
Insurance OptimizationAlbert Chu
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning VMax Kleiner
 
An Interactive Introduction To R (Programming Language For Statistics)
An Interactive Introduction To R (Programming Language For Statistics)An Interactive Introduction To R (Programming Language For Statistics)
An Interactive Introduction To R (Programming Language For Statistics)Dataspora
 
SAMPLING MEAN DEFINITION The term sampling mean .docx
SAMPLING MEAN DEFINITION The term sampling mean .docxSAMPLING MEAN DEFINITION The term sampling mean .docx
SAMPLING MEAN DEFINITION The term sampling mean .docxanhlodge
 
Csci101 lect08b matlab_programs
Csci101 lect08b matlab_programsCsci101 lect08b matlab_programs
Csci101 lect08b matlab_programsElsayed Hemayed
 
Predictive Modeling in Insurance in the context of (possibly) big data
Predictive Modeling in Insurance in the context of (possibly) big dataPredictive Modeling in Insurance in the context of (possibly) big data
Predictive Modeling in Insurance in the context of (possibly) big dataArthur Charpentier
 
Kinetic bands versus Bollinger Bands
Kinetic bands versus Bollinger  BandsKinetic bands versus Bollinger  Bands
Kinetic bands versus Bollinger BandsAlexandru Daia
 
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...cscpconf
 
Statistics in real life engineering
Statistics in real life engineeringStatistics in real life engineering
Statistics in real life engineeringMD TOUFIQ HASAN ANIK
 
Logistic Regression in Case-Control Study
Logistic Regression in Case-Control StudyLogistic Regression in Case-Control Study
Logistic Regression in Case-Control StudySatish Gupta
 
[M3A3] Data Analysis and Interpretation Specialization
[M3A3] Data Analysis and Interpretation Specialization [M3A3] Data Analysis and Interpretation Specialization
[M3A3] Data Analysis and Interpretation Specialization Andrea Rubio
 
A few solvers for portfolio selection
A few solvers for portfolio selectionA few solvers for portfolio selection
A few solvers for portfolio selectionBogusz Jelinski
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIIMax Kleiner
 

Similar to Introduction to lifecontingencies R package (20)

PATTEM JAGADESH_21mt0269_research proposal presentation.pptx
PATTEM JAGADESH_21mt0269_research proposal presentation.pptxPATTEM JAGADESH_21mt0269_research proposal presentation.pptx
PATTEM JAGADESH_21mt0269_research proposal presentation.pptx
 
Insurance Optimization
Insurance OptimizationInsurance Optimization
Insurance Optimization
 
maXbox starter67 machine learning V
maXbox starter67 machine learning VmaXbox starter67 machine learning V
maXbox starter67 machine learning V
 
An Interactive Introduction To R (Programming Language For Statistics)
An Interactive Introduction To R (Programming Language For Statistics)An Interactive Introduction To R (Programming Language For Statistics)
An Interactive Introduction To R (Programming Language For Statistics)
 
Unit 8
Unit 8Unit 8
Unit 8
 
SAMPLING MEAN DEFINITION The term sampling mean .docx
SAMPLING MEAN DEFINITION The term sampling mean .docxSAMPLING MEAN DEFINITION The term sampling mean .docx
SAMPLING MEAN DEFINITION The term sampling mean .docx
 
Csci101 lect08b matlab_programs
Csci101 lect08b matlab_programsCsci101 lect08b matlab_programs
Csci101 lect08b matlab_programs
 
Predictive Modeling in Insurance in the context of (possibly) big data
Predictive Modeling in Insurance in the context of (possibly) big dataPredictive Modeling in Insurance in the context of (possibly) big data
Predictive Modeling in Insurance in the context of (possibly) big data
 
Kinetic bands versus Bollinger Bands
Kinetic bands versus Bollinger  BandsKinetic bands versus Bollinger  Bands
Kinetic bands versus Bollinger Bands
 
Slides ensae-2016-9
Slides ensae-2016-9Slides ensae-2016-9
Slides ensae-2016-9
 
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...
 
Statistics in real life engineering
Statistics in real life engineeringStatistics in real life engineering
Statistics in real life engineering
 
Logistic Regression in Case-Control Study
Logistic Regression in Case-Control StudyLogistic Regression in Case-Control Study
Logistic Regression in Case-Control Study
 
working with python
working with pythonworking with python
working with python
 
[M3A3] Data Analysis and Interpretation Specialization
[M3A3] Data Analysis and Interpretation Specialization [M3A3] Data Analysis and Interpretation Specialization
[M3A3] Data Analysis and Interpretation Specialization
 
A few solvers for portfolio selection
A few solvers for portfolio selectionA few solvers for portfolio selection
A few solvers for portfolio selection
 
Slides ensae 9
Slides ensae 9Slides ensae 9
Slides ensae 9
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
 
wzhu_paper
wzhu_paperwzhu_paper
wzhu_paper
 
Robust Optimal Reinsurance and Investment Problem with p-Thinning Dependent a...
Robust Optimal Reinsurance and Investment Problem with p-Thinning Dependent a...Robust Optimal Reinsurance and Investment Problem with p-Thinning Dependent a...
Robust Optimal Reinsurance and Investment Problem with p-Thinning Dependent a...
 

More from Giorgio Alfredo Spedicato (15)

Machine Learning - Supervised Learning
Machine Learning - Supervised LearningMachine Learning - Supervised Learning
Machine Learning - Supervised Learning
 
Machine Learning - Unsupervised Learning
Machine Learning - Unsupervised LearningMachine Learning - Unsupervised Learning
Machine Learning - Unsupervised Learning
 
Machine Learning - Principles
Machine Learning - PrinciplesMachine Learning - Principles
Machine Learning - Principles
 
Machine Learning - Intro
Machine Learning - IntroMachine Learning - Intro
Machine Learning - Intro
 
Meta analysis essentials
Meta analysis essentialsMeta analysis essentials
Meta analysis essentials
 
The markovchain package use r2016
The markovchain package use r2016The markovchain package use r2016
The markovchain package use r2016
 
Cat Bond and Traditional Insurance
Cat Bond and Traditional InsuranceCat Bond and Traditional Insurance
Cat Bond and Traditional Insurance
 
It skills for actuaries
It skills for actuariesIt skills for actuaries
It skills for actuaries
 
Statistics in insurance business
Statistics in insurance businessStatistics in insurance business
Statistics in insurance business
 
R in Insurance 2014
R in Insurance 2014R in Insurance 2014
R in Insurance 2014
 
L'assicurazione rca gs
L'assicurazione rca   gsL'assicurazione rca   gs
L'assicurazione rca gs
 
P & C Reserving Using GAMLSS
P & C Reserving Using GAMLSSP & C Reserving Using GAMLSS
P & C Reserving Using GAMLSS
 
Princing insurance contracts with R
Princing insurance contracts with RPrincing insurance contracts with R
Princing insurance contracts with R
 
Pricing and modelling under the Italian Direct Compensation Card Scheme
Pricing and modelling under the Italian Direct Compensation Card SchemePricing and modelling under the Italian Direct Compensation Card Scheme
Pricing and modelling under the Italian Direct Compensation Card Scheme
 
Actuarial modeling of general practictioners' drug prescriptions costs
Actuarial modeling of general practictioners' drug prescriptions costsActuarial modeling of general practictioners' drug prescriptions costs
Actuarial modeling of general practictioners' drug prescriptions costs
 

Recently uploaded

Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024Bladex
 
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance CompanyInterimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance CompanyTyöeläkeyhtiö Elo
 
How Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of ReportingHow Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of ReportingAggregage
 
Stock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdfStock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdfMichael Silva
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办fqiuho152
 
The Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarThe Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarHarsh Kumar
 
House of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHouse of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHenry Tapper
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...Henry Tapper
 
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfBPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfHenry Tapper
 
Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111Sapana Sha
 
Andheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot ModelsAndheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot Modelshematsharma006
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfAdnet Communications
 
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdfmagnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdfHenry Tapper
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130Suhani Kapoor
 
Bladex 1Q24 Earning Results Presentation
Bladex 1Q24 Earning Results PresentationBladex 1Q24 Earning Results Presentation
Bladex 1Q24 Earning Results PresentationBladex
 
Quantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector CompaniesQuantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector Companiesprashantbhati354
 
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证rjrjkk
 
Financial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and DisadvantagesFinancial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and Disadvantagesjayjaymabutot13
 

Recently uploaded (20)

Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024
 
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance CompanyInterimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
Interimreport1 January–31 March2024 Elo Mutual Pension Insurance Company
 
How Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of ReportingHow Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of Reporting
 
Stock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdfStock Market Brief Deck for "this does not happen often".pdf
Stock Market Brief Deck for "this does not happen often".pdf
 
🔝+919953056974 🔝young Delhi Escort service Pusa Road
🔝+919953056974 🔝young Delhi Escort service Pusa Road🔝+919953056974 🔝young Delhi Escort service Pusa Road
🔝+919953056974 🔝young Delhi Escort service Pusa Road
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
 
The Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh KumarThe Triple Threat | Article on Global Resession | Harsh Kumar
The Triple Threat | Article on Global Resession | Harsh Kumar
 
House of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHouse of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview document
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
 
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
letter-from-the-chair-to-the-fca-relating-to-british-steel-pensions-scheme-15...
 
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdfBPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
BPPG response - Options for Defined Benefit schemes - 19Apr24.pdf
 
Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111
 
Andheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot ModelsAndheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot Models
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdf
 
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdfmagnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
magnetic-pensions-a-new-blueprint-for-the-dc-landscape.pdf
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
 
Bladex 1Q24 Earning Results Presentation
Bladex 1Q24 Earning Results PresentationBladex 1Q24 Earning Results Presentation
Bladex 1Q24 Earning Results Presentation
 
Quantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector CompaniesQuantitative Analysis of Retail Sector Companies
Quantitative Analysis of Retail Sector Companies
 
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
原版1:1复刻温哥华岛大学毕业证Vancouver毕业证留信学历认证
 
Financial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and DisadvantagesFinancial Leverage Definition, Advantages, and Disadvantages
Financial Leverage Definition, Advantages, and Disadvantages
 

Introduction to lifecontingencies R package

  • 1. Intro to the lifecontingencies R package Giorgio Alfredo Spedicato, Ph.D C.Stat ACAS 19th April 2015
  • 2.
  • 3.
  • 4. Intro The lifecontingencies package (Spedicato 2013) will be introduced.
  • 5. Intro The lifecontingencies package (Spedicato 2013) will be introduced. As first half 2015 it is the first R (Team 2012) package merging demographic and financial mathematics function in order to perform actuarial evaluation of life contingent insurances (annuities, life insurances, endowments, etc).
  • 6. Intro The lifecontingencies package (Spedicato 2013) will be introduced. As first half 2015 it is the first R (Team 2012) package merging demographic and financial mathematics function in order to perform actuarial evaluation of life contingent insurances (annuities, life insurances, endowments, etc). The applied examples will shown: how to load the R package, how to perform basic financial mathematics and demographic calculations, how to price and reserve financial products.
  • 7. The final example will show how to mix lifecontingencies and demography (Rob J Hyndman et al. 2011) function to assess the mortality development impact on annuities.
  • 8. The final example will show how to mix lifecontingencies and demography (Rob J Hyndman et al. 2011) function to assess the mortality development impact on annuities. The interested readers are suggested to look to the package’s vignettes (also appeared in the Journal of Statistical Sofware) for a broader overview. (Dickson, Hardy, and Waters 2009; and Mazzoleni 2000) provide and introduction of Actuarial Mathematics theory.
  • 9. The final example will show how to mix lifecontingencies and demography (Rob J Hyndman et al. 2011) function to assess the mortality development impact on annuities. The interested readers are suggested to look to the package’s vignettes (also appeared in the Journal of Statistical Sofware) for a broader overview. (Dickson, Hardy, and Waters 2009; and Mazzoleni 2000) provide and introduction of Actuarial Mathematics theory. Also (Charpentier 2012) and (Charpentier 2014) discuss the software.
  • 10. First moves into the lifecontingecies package Loading the package The package is loaded using library(lifecontingencies) #load the package
  • 11. First moves into the lifecontingecies package Loading the package The package is loaded using library(lifecontingencies) #load the package It requires a recent version of R (>=3.0) and the markovchain package (Spedicato 2015). The development version of the package requires also Rcpp package (Eddelbuettel 2013).
  • 12. Financial mathematics Actuarial mathematics calculation applies probability to quantify uncertainty on present values calculation. capitals <- c(-1000,200,500,700) times <- c(0,1,2,5) #calculate a present value presentValue(cashFlows=capitals, timeIds=times, interestRates=0.03) ## [1] 269.2989
  • 13. Financial mathematics Actuarial mathematics calculation applies probability to quantify uncertainty on present values calculation. Certain present value calculations can be directly evaluated by the package capitals <- c(-1000,200,500,700) times <- c(0,1,2,5) #calculate a present value presentValue(cashFlows=capitals, timeIds=times, interestRates=0.03) ## [1] 269.2989
  • 14. The presentValue function is the kernel of functions that are used to calculate annuities and accumulated values, also paid in fractional k payments. ann1 <- annuity(i=0.03, n=5, k=1, type="immediate") ann2 <- annuity(i=0.03, n=5, k=12, type="due") c(ann1,ann2) ## [1] 4.579707 4.653791
  • 15. Such functions can be combined to price bonds and other classical financial products. bondPrice<-5*annuity(i=0.03,n=10)+100*1.03^-10 bondPrice ## [1] 117.0604
  • 16. Such functions can be combined to price bonds and other classical financial products. The following code exemplifies the calculation of a 5% coupon bond at 3% yield rate when the term is ten year. bondPrice<-5*annuity(i=0.03,n=10)+100*1.03^-10 bondPrice ## [1] 117.0604
  • 17. Managing lifetables and actuarial tables A lifetable object is an S4 class comprised by three slots: the age (from 0 to ω), the people at risk at beginning of age x and the table name. #create an demo lifetable xDemo<-seq(from=0,to=5,by=1) lxDemo<-c(100,95,90,60,30,5) lifetableDemo<-new("lifetable",x=xDemo, lx=lxDemo,name="Demo")
  • 18. In practice, it is often more convenient to load an existing table from a CSV or XLS source. Some common tables have been bundled as data.frames within the package. data(demoIta) #using the internal Italian LT data set lxIPS55M <- with(demoIta, IPS55M) #performing some fixings pos2Remove <- which(lxIPS55M %in% c(0,NA)) lxIPS55M <-lxIPS55M[-pos2Remove] xIPS55M <-seq(0,length(lxIPS55M)-1,1) #creating the table ips55M <- new("lifetable",x=xIPS55M, lx=lxIPS55M,name="IPS 55 Males")
  • 19. In practice, it is often more convenient to load an existing table from a CSV or XLS source. Some common tables have been bundled as data.frames within the package. The example that follows creates the Italian IPS55 life table. data(demoIta) #using the internal Italian LT data set lxIPS55M <- with(demoIta, IPS55M) #performing some fixings pos2Remove <- which(lxIPS55M %in% c(0,NA)) lxIPS55M <-lxIPS55M[-pos2Remove] xIPS55M <-seq(0,length(lxIPS55M)-1,1) #creating the table ips55M <- new("lifetable",x=xIPS55M, lx=lxIPS55M,name="IPS 55 Males")
  • 20. It is therefore easy to perform standard demographic calculations with the aid of package functions. # decrements between age 65 and 70 dxt(ips55M, x = 65, t = 5) ## [1] 3659.74 # probabilities of death between age 80 and 85 qxt(ips55M, x = 80, t = 2) ## [1] 0.07264833 # expected curtate lifetime exn(ips55M, x = 65) ## [1] 21.96873
  • 21. Pricing and reserving Life Contingent insurances The pricing and reserving of pure endowments A 1 x:n , term insurances, A1 x:n , annuities ¨a {m} x , endowments A 1 x:n can be easily handled within the package. #creates a new actuarial table ips55Act<-new("actuarialtable", x=ips55M@x,lx=ips55M@lx, interest=0.02,name="IPS55M")
  • 22. Pricing and reserving Life Contingent insurances The pricing and reserving of pure endowments A 1 x:n , term insurances, A1 x:n , annuities ¨a {m} x , endowments A 1 x:n can be easily handled within the package. Performing such actuarial calculations requires to create an actuarial table (similar to a lifetable but with one more slot for the interest rate) that can be create as it is shown below. #creates a new actuarial table ips55Act<-new("actuarialtable", x=ips55M@x,lx=ips55M@lx, interest=0.02,name="IPS55M")
  • 23. The example that follows computes the yearly premium P = 50000 ∗ 35E30 ¨a 30:35 for a pure endowment on 50K capital. #compute APV APV=50e3*Exn(actuarialtable = ips55Act,x=30,n=35) #compute Premium P=APV/axn(actuarialtable = ips55Act,x=30,n=35) c(APV,P) ## [1] 23584.7564 938.1422
  • 24. The package allows to easily perform sensitivities on the financials changing key parameters like term, interest, etc as we can see on a endowment purchased by a 30 years old policyholder for 30 years. #defining the ranges interest.range<-seq(from=0.015, to=0.035,by=0.001) term.range<-seq(from=20, to=40,by=1) #computing APV sensitivities apv.interest.sensitivity<-sapply(interest.range, FUN = "AExn",actuarialtable=ips55Act,x=30,n=30) apv.term.sensitivity<-sapply(term.range,FUN = "AExn", actuarialtable=ips55Act,x=30)
  • 25. The graph below displays sensitivities on APV varying interest rate and insurance term. 0.015 0.025 0.035 0.400.450.500.550.600.65 APV by Interest Rate interest rate APV 20 30 40 0.500.550.600.65 APV by term term APV
  • 26. Also, calculation of outstanding reserves is made easy as the following example, applied on a 100K face value 40 year term term life insurance with payments made yearly on a policyholder aged 25, shows. #compute the APV and premium APV=100e3*Axn(actuarialtable = ips55Act,x=25,n=40) P=APV/axn(actuarialtable = ips55Act,x=25,n=40) #define a reserve function reserveFunction<-function(t) 100e3*Axn(actuarialtable = ips55Act,x=25+t,n=40-t) - P *axn(actuarialtable = ips55Act,x=25+t,n=40-t) reserve<-sapply(0:40,reserveFunction)
  • 27. 0 10 20 30 40 050010001500 Reserve Policy Age Reserveoutstanding
  • 28. Stochastic evalutation The APV of a life contingent insurance is the expected value of a function of a random variable (the residual life time). Knowing the interest rate and the underlying life table it is possible both to compute the APV and to assess the distribution of the underlying life insurance. #analyzing and Endowment of 100K on x=40, n=25 #compute APV APV=AExn(actuarialtable = ips55Act,x=40,n=25) #sampling AEXnDistr<-rLifeContingencies(n=10e3, lifecontingency = "AExn",x = 40, t=25,object = ips55Act)
  • 29. In order to assess if the distribution is unbiased we use a classical one sample t - test. #assess if the expected value match the theoretical one t.test(x=AEXnDistr,mu = APV) ## ## One Sample t-test ## ## data: AEXnDistr ## t = 1.3102, df = 9999, p-value = 0.1902 ## alternative hypothesis: true mean is not equal to 0.6148 ## 95 percent confidence interval: ## 0.6146427 0.6159746 ## sample estimates: ## mean of x ## 0.6153086
  • 30. Endowment Actuarial Value Distribution AEXnDistr Density 0.6 0.7 0.8 0.9 1.0 010203040
  • 31. Assessing longevity impact on annuities using lifecontingencies and demography This part of the presentation will make use of the demography package to calibrate Lee Carter (Lee and Carter 1992) model, log (µx,t) = ax + bx ∗ kt → px,t = exp−µx,t ,projecting mortality and implicit life tables. #load the package and the italian tables library(demography) #italy.demo<-hmd.mx("ITA", username="yourUN", #password="yourPW") load(file="mortalityDatasets.RData") #load the dataset
  • 32. Lee Carter model is calibrated using lca function. #calibrate lee carter italy.leecarter<-lca(data=italyDemo,series="total", max.age=103,adjust = "none") #perform modeling of kt series kt.model<-auto.arima(italy.leecarter$kt) #projecting the kt kt.forecast<-forecast(kt.model,h=100)
  • 33. Lee Carter model is calibrated using lca function. Then an arima model is used to project (extrapolate) the underlying kt over the historical period. #calibrate lee carter italy.leecarter<-lca(data=italyDemo,series="total", max.age=103,adjust = "none") #perform modeling of kt series kt.model<-auto.arima(italy.leecarter$kt) #projecting the kt kt.forecast<-forecast(kt.model,h=100)
  • 34. -The code below generates the matrix of prospective life tables #indexing the kt kt.full<-ts(union(italy.leecarter$kt, kt.forecast$mean), start=1872) #getting and defining the life tables matrix mortalityTable<-exp(italy.leecarter$ax +italy.leecarter$bx%*%t(kt.full)) rownames(mortalityTable)<-seq(from=0, to=103) colnames(mortalityTable)<-seq(from=1872, to=1872+dim(mortalityTable)[2]-1)
  • 35. historical and projected KT year kt 1900 1950 2000 2050 2100 −300−200−1000100
  • 36. now we need a function that returns the one-year death probabilities given a year of birth (cohort. getCohortQx<-function(yearOfBirth) { colIndex<-which(colnames(mortalityTable) ==yearOfBirth) #identify #the column corresponding to the cohort #definex the probabilities from which #the projection is to be taken maxLength<-min(nrow(mortalityTable)-1, ncol(mortalityTable)-colIndex) qxOut<-numeric(maxLength+1) for(i in 0:maxLength) qxOut[i+1]<-mortalityTable[i+1,colIndex+i] #fix: we add a fictional omega age where #death probability = 1 qxOut<-c(qxOut,1) return(qxOut) }
  • 37. Now we use such function to obtain prospective life tables and to perform actuarial calculations. For example, we can compute the APV of an annuity on a workers’ retiring at 65 assuming he were born in 1920, in 1950 and in 1980. We will use the interest rate of 1.5% (the one used to compute Italian Social Security annuity factors). #generate the life tables qx1920<-getCohortQx(yearOfBirth = 1920) lt1920<-probs2lifetable(probs=qx1920,type="qx", name="Table 1920") at1920<-new("actuarialtable",x=lt1920@x, lx=lt1920@lx,interest=0.015) qx1950<-getCohortQx(yearOfBirth = 1950) lt1950<-probs2lifetable(probs=qx1950, type="qx",name="Table 1950") at1950<-new("actuarialtable",x=lt1950@x, lx=lt1950@lx,interest=0.015) qx1980<-getCohortQx(yearOfBirth = 1980)
  • 38. Now we use such function to obtain prospective life tables and to perform actuarial calculations. For example, we can compute the APV of an annuity on a workers’ retiring at 65 assuming he were born in 1920, in 1950 and in 1980. We will use the interest rate of 1.5% (the one used to compute Italian Social Security annuity factors). The first step is to generate the life and actuarial tables #generate the life tables qx1920<-getCohortQx(yearOfBirth = 1920) lt1920<-probs2lifetable(probs=qx1920,type="qx", name="Table 1920") at1920<-new("actuarialtable",x=lt1920@x, lx=lt1920@lx,interest=0.015) qx1950<-getCohortQx(yearOfBirth = 1950) lt1950<-probs2lifetable(probs=qx1950, type="qx",name="Table 1950") at1950<-new("actuarialtable",x=lt1950@x, lx=lt1950@lx,interest=0.015) qx1980<-getCohortQx(yearOfBirth = 1980)
  • 39. Now we can evaluate ¨a65 and ˚e65 for workers born in 1920, 1950 and 1980 respectively. cat("Results for 1920 cohort","n") ## Results for 1920 cohort c(exn(at1920,x=65),axn(at1920,x=65)) ## [1] 16.51391 15.14127 cat("Results for 1950 cohort","n") ## Results for 1950 cohort c(exn(at1950,x=65),axn(at1950,x=65)) ## [1] 18.72669 16.83391 cat("Results for 1980 cohort","n")
  • 40. Bibliography I Charpentier, Arthur. 2012. “Actuarial Science with R 2: Life Insurance and Mortality Tables.” http://freakonometrics.blog.free.fr/index.php?post/ 2012/04/04/Life-insurance,-with-R,-Meielisalp. ———. 2014. Computational Actuarial Science. The R Series. Cambridge University Press. Dickson, D.C.M., M.R. Hardy, and H.R. Waters. 2009. Actuarial Mathematics for Life Contingent Risks. International Series on Actuarial Science. Cambridge University Press. Eddelbuettel, Dirk. 2013. Seamless R and C++ Integration with Rcpp. New York: Springer. Lee, R.D., and L.R. Carter. 1992. “Modeling and Forecasting U.S. Mortality.” Journal of the American Statistical Association 87 (419): 659–75. doi:10.2307/2290201.
  • 41. Bibliography II Mazzoleni, P. 2000. Appunti Di Matematica Attuariale. EDUCatt Università Cattolica. Rob J Hyndman, Heather Booth, Leonie Tickle, and John Maindonald. 2011. demography: Forecasting Mortality, Fertility, Migration and Population Data. http://CRAN.R-project.org/package=demography. Spedicato, Giorgio Alfredo. 2013. “The lifecontingencies Package: Performing Financial and Actuarial Mathematics Calculations in R.” Journal of Statistical Software 55 (10): 1–36. http://www.jstatsoft.org/v55/i10/. ———. 2015. markovchain: discrete Time Markov Chains Made Easy. Team, R Development Core. 2012. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. http://www.R-project.org/.