Title: | Financial and Actuarial Mathematics for Life Contingencies |
---|---|
Description: | Classes and methods that allow the user to manage life table, actuarial tables (also multiple decrements tables). Moreover, functions to easily perform demographic, financial and actuarial mathematics on life contingencies insurances calculations are contained therein. See Spedicato (2013) <doi:10.18637/jss.v055.i10>. |
Authors: | Giorgio Alfredo Spedicato [aut, cre]
|
Maintainer: | Giorgio Alfredo Spedicato <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.3.12 |
Built: | 2025-02-26 05:33:21 UTC |
Source: | https://github.com/spedygiorgio/lifecontingencies |
The lifecontingencies package performs standard financial, demographic and actuarial mathematics calculation. The main purpose of the package is to provide a comprehensive set of tools to perform risk assessment of life contingent insurances.
Some functions have been powered by Rcpp code.
This package and functions herein are provided as is, without any guarantee regarding the accuracy of calculations. The author disclaims any liability arising by any losses due to direct or indirect use of this package.
Work in progress.
Giorgio Alfredo Spedicato with contributions from Reinhold Kainhofer and Kevin J. Owens Maintainer: <[email protected]>
The lifecontingencies Package: Performing Financial and Actuarial Mathematics Calculations in R, Giorgio Alfredo Spedicato, Journal of Statistical Software, 2013,55 , 10, 1-36
##financial mathematics example #calculates monthly installment of a loan of 100,000, #interest rate 0.05 i=0.05 monthlyInt=(1+i)^(1/12)-1 Capital=100000 #Montly installment R=1/12*Capital/annuity(i=i, n=10,k=12, type = "immediate") R balance=numeric(10*12+1) capitals=numeric(10*12+1) interests=numeric(10*12+1) balance[1]=Capital interests[1]=0 capitals[1]=0 for(i in (2:121)) { balance[i]=balance[i-1]*(1+monthlyInt)-R interests[i]=balance[i-1]*monthlyInt capitals[i]=R-interests[i] } loanSummary=data.frame(rate=c(0, rep(R,10*12)), balance, interests, capitals) head(loanSummary) tail(loanSummary) ##actuarial mathematics example #APV of an annuity data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate and life-long annuity for an aged 65 axn(soa08Act, x=65)
##financial mathematics example #calculates monthly installment of a loan of 100,000, #interest rate 0.05 i=0.05 monthlyInt=(1+i)^(1/12)-1 Capital=100000 #Montly installment R=1/12*Capital/annuity(i=i, n=10,k=12, type = "immediate") R balance=numeric(10*12+1) capitals=numeric(10*12+1) interests=numeric(10*12+1) balance[1]=Capital interests[1]=0 capitals[1]=0 for(i in (2:121)) { balance[i]=balance[i-1]*(1+monthlyInt)-R interests[i]=balance[i-1]*monthlyInt capitals[i]=R-interests[i] } loanSummary=data.frame(rate=c(0, rep(R,10*12)), balance, interests, capitals) head(loanSummary) tail(loanSummary) ##actuarial mathematics example #APV of an annuity data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate and life-long annuity for an aged 65 axn(soa08Act, x=65)
This functions returns the value at time n of a series of equally spaced payments of 1.
accumulatedValue(i, n,m=0, k,type = "immediate")
accumulatedValue(i, n,m=0, k,type = "immediate")
i |
Effective interest rate expressed in decimal form. E.g. 0.03 means 3%. |
n |
Number of terms of payment. |
m |
Deferring period, whose default value is zero. |
k |
Frequency of payment. |
type |
The Payment type, either |
The accumulated value is the future value of the terms of an annuity. Its mathematical expression is
A numeric value representing the calculated accumulated value.
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
Accumulated value are derived from annuities by the following basic
equation .
Giorgio A. Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
#A man wants to save 100,000 to pay for his sons #education in 10 years time. An education fund requires the investors to #deposit equal installments annually at the end of each year. If interest of #0.075 is paid, how much does the man need to save each year in order to #meet his target? R=100000/accumulatedValue(i=0.075,n=10)
#A man wants to save 100,000 to pay for his sons #education in 10 years time. An education fund requires the investors to #deposit equal installments annually at the end of each year. If interest of #0.075 is paid, how much does the man need to save each year in order to #meet his target? R=100000/accumulatedValue(i=0.075,n=10)
"actuarialtable"
Objects of class "actuarialtable"
inherit the structure of class "lifetable"
adding just the slot for interest rate, interest
.
Objects can be created by calls of the form new("actuarialtable", ...)
.
Creation is the same as lifetable objects creation, the slot for interest must be added too.
interest
:Object of class "numeric"
slot for interest rate, e.g. 0.03
x
:Object of class "numeric"
age slot
lx
:Object of class "numeric"
subjects at risk at age x
name
:Object of class "character"
name of the actuarial table
Class "lifetable"
, directly.
signature(from = "actuarialtable", to = "data.frame")
: moves from actuarialtable
to data.frame
signature(from = "actuarialtable", to = "numeric")
: coerce from actuarialtable
to a numeric
signature(object = "actuarialtable")
: as for lifetable
signature(x = "actuarialtable")
: tabulates the actuarial commutation functions
signature(object = "actuarialtable")
: show method
signature(object = "actuarialtable")
: prints brief summary
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
The interest slot will handle time-varying interest rates in the future.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
showClass("actuarialtable")
showClass("actuarialtable")
This function evaluates the n-year endowment insurance.
AExn(actuarialtable, x, n, i=actuarialtable@interest, k = 1, type = "EV", power=1)
AExn(actuarialtable, x, n, i=actuarialtable@interest, k = 1, type = "EV", power=1)
actuarialtable |
An actuarial table object. |
x |
Insured age. |
n |
Length of the insurance. |
i |
Rate of interest. When missing the one included in the actuarialtable object is used. |
k |
Frequency of benefit payment. |
type |
A string, either |
power |
The power of the APV. Default is 1 (mean) |
The n-year endowment insurance provides a payment either in the year of death or at the end of the insured period.
A numeric value.
When type="EV" the function calls both Axn
and Exn
.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#Actuarial Mathematics book example #check the actuarial equality on the expected values Exn+Axn=AExn data(soa08Act) AExn(soa08Act, x=35,n=30,i=0.06) Exn(soa08Act, x=35,n=30,i=0.06)+Axn(soa08Act, x=35,n=30,i=0.06)
#Actuarial Mathematics book example #check the actuarial equality on the expected values Exn+Axn=AExn data(soa08Act) AExn(soa08Act, x=35,n=30,i=0.06) Exn(soa08Act, x=35,n=30,i=0.06)+Axn(soa08Act, x=35,n=30,i=0.06)
Function to calculate present value of annuities-certain.
annuity(i, n, m = 0, k = 1, type = "immediate")
annuity(i, n, m = 0, k = 1, type = "immediate")
i |
Effective interest rate expressed in decimal form. E.g. 0.03 means 3%. It can be a vector of interest rates of the same length of periods. |
n |
Periods for payments. If n = |
m |
Deferring period, whose default value is zero. |
k |
Yearly payments frequency. A payment of |
type |
The Payment type, either |
This function calculates the present value of a stream of fixed payments separated by equal interval of time. Annuity immediate has the fist payment at time t = 0, while an annuity due has the first payment at time t = 1.
A string, either "immediate" or "due".
The value returned by annuity function derives from direct calculation of the discounted cash flow and
not from formulas, like . When m is greater than
1, the payment per period is assumed to be
.
Giorgio A. Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
# The present value of 5 payments of 1000 at one year interval that begins # now when the interest rate is 2.5% is 1000 * annuity(i = 0.025, n = 5, type = "due") # A man borrows a loan of 20,000 to purchase a car at # a nominal annual rate of interest of 0.06. He will pay back the loan through monthly # installments over 5 years, with the first installment to be made one month # after the release of the loan. What is the monthly installment he needs to pay? 20000 / annuity(i = 0.06 / 12, n = 5 * 12)
# The present value of 5 payments of 1000 at one year interval that begins # now when the interest rate is 2.5% is 1000 * annuity(i = 0.025, n = 5, type = "due") # A man borrows a loan of 20,000 to purchase a car at # a nominal annual rate of interest of 0.06. He will pay back the loan through monthly # installments over 5 years, with the first installment to be made one month # after the release of the loan. What is the monthly installment he needs to pay? 20000 / annuity(i = 0.06 / 12, n = 5 * 12)
This function calculates actuarial value of annuities, given an actuarial table. Fractional and deferred annuities can be evaluated. Moreover it can be used to simulate the stochastic distribution of the annuity value.
axn(actuarialtable, x, n, i = actuarialtable@interest, m, k = 1, type = "EV", power=1,payment = "advance", ...)
axn(actuarialtable, x, n, i = actuarialtable@interest, m, k = 1, type = "EV", power=1,payment = "advance", ...)
actuarialtable |
An actuarial table object. |
x |
Age of the annuitant. (can be a vector). |
n |
Number of terms of the annuity, if missing annuity is intended to be paid until death. (can be a vector). |
i |
Interest rate (default value the interest of the life table). (should be a scalar). |
m |
Deferring period. Assumed to be 1 whether missing. (can be a vector). |
k |
Number of fractional payments per period. Assumed to be 1 whether missing. (should be a scalar). |
type |
A string, either |
power |
The power of the APV. Default is 1 (mean) |
payment |
The Payment type, either |
... |
Arguments to be passed to |
When "ST" has been selected a stochastic value representing a number drawn from the domain of
is drawn. "EV" calculates the classical APV.
A numeric value.
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
When either or
zero is returned.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#assume SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate and life-long annuity for an aged 65 axn(soa08Act, x=65)
#assume SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate and life-long annuity for an aged 65 axn(soa08Act, x=65)
This function evaluates n - years term and whole life insurance.
Axn(actuarialtable, x, n, i=actuarialtable@interest, m, k=1, type = "EV", power=1, ...)
Axn(actuarialtable, x, n, i=actuarialtable@interest, m, k=1, type = "EV", power=1, ...)
actuarialtable |
An actuarial table object. |
x |
Age of the insured. (can be a vector). |
n |
Coverage period, if missing the insurance is considered whole life |
i |
Interest rate (overrides the interest rate slot in |
m |
Deferring period, even fractional, if missing assumed to be 0. (can be a vector). |
k |
Number of periods per year at the end of which the capital is payable in case of insured event, default=1 (capital payable at the end of death year). (should be a scalar). |
type |
A string, either |
power |
The power of the APV. Default is 1 (mean) |
... |
Arguments to be passed to |
The variance calculation has not been implemented yet.
A numeric value representing either the actuarial value of the coverage (when type="EV") or a number drawn from the underlying distribution of Axn.
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
It is possible that value returned by stochastic simulation are biased. Successive releases of this software will analyze the issue with detail.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#assume SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a 40 years term life insurance for an aged 25 Axn(actuarialtable=soa08Act, x=25, n=40) #check an relevant life contingencies relationship k=12 i=0.06 j=real2Nominal(i,k) Axn(soa08Act, 30,k=12) i/j*Axn(soa08Act, 30,k=1)
#assume SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a 40 years term life insurance for an aged 25 Axn(actuarialtable=soa08Act, x=25, n=40) #check an relevant life contingencies relationship k=12 i=0.06 j=real2Nominal(i,k) Axn(soa08Act, 30,k=12) i/j*Axn(soa08Act, 30,k=1)
Function to evaluate multiple decrement insurances
Axn.mdt(object, x, n, i, decrement)
Axn.mdt(object, x, n, i, decrement)
object |
an |
x |
policyholder's age |
n |
contract duration |
i |
interest rate |
decrement |
decrement category |
The scalar representing APV of the insurance
The function is experimental and very basic. Testing is still needed. Use at own risk!
#creates a temporary mdt myTable<-data.frame(x=41:43,lx=c(800,776,752),d1=rep(8,3),d2=rep(16,3)) myMdt<-new("mdt",table=myTable,name="ciao") Axn.mdt(myMdt, x=41,n=2,i=.05,decrement="d2")
#creates a temporary mdt myTable<-data.frame(x=41:43,lx=c(800,776,752),d1=rep(8,3),d2=rep(16,3)) myMdt<-new("mdt",table=myTable,name="ciao") Axn.mdt(myMdt, x=41,n=2,i=.05,decrement="d2")
These functions evaluates life insurances and annuities on two heads.
axyn(tablex, tabley, x, y, n, i, m, k = 1, status = "joint", type = "EV", payment="advance") Axyn(tablex, x, tabley, y, n, i, m, k = 1, status = "joint", type = "EV")
axyn(tablex, tabley, x, y, n, i, m, k = 1, status = "joint", type = "EV", payment="advance") Axyn(tablex, x, tabley, y, n, i, m, k = 1, status = "joint", type = "EV")
tablex |
Life X |
tabley |
Life Y |
x |
Age of life X. |
y |
Age of life Y. |
n |
Insured duration. Infinity if missing. |
i |
Interest rate. Default value is those implied in |
m |
Deferring period. Default value is zero. |
k |
Fractional payments or periods where insurance is payable. |
status |
Either |
type |
A string, either |
payment |
The Payment type, either |
Actuarial mathematics book formulas has been implemented.
A numeric value returning APV of chosen insurance form.
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
Deprecated functions. Use Axyzn
and axyzn
instead.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
## Not run: data(soa08Act) #last survival status annuity axyn(tablex=soa08Act, tabley=soa08Act, x=65, y=70, n=5, status = "last",type = "EV") #first survival status annuity Axyn(tablex=soa08Act, tabley=soa08Act, x=65, y=70, status = "last",type = "EV") ## End(Not run)
## Not run: data(soa08Act) #last survival status annuity axyn(tablex=soa08Act, tabley=soa08Act, x=65, y=70, n=5, status = "last",type = "EV") #first survival status annuity Axyn(tablex=soa08Act, tabley=soa08Act, x=65, y=70, status = "last",type = "EV") ## End(Not run)
Function to evalate the multiple lives insurances and annuities
Axyzn(tablesList, x, n, i, m, k = 1, status = "joint", type = "EV", power=1) axyzn(tablesList, x, n, i, m, k = 1, status = "joint", type = "EV", power=1, payment="advance")
Axyzn(tablesList, x, n, i, m, k = 1, status = "joint", type = "EV", power=1) axyzn(tablesList, x, n, i, m, k = 1, status = "joint", type = "EV", power=1, payment="advance")
tablesList |
A list whose elements are either lifetable or actuarialtable class objects. |
x |
A vector of the same size of tableList that contains the initial ages. |
n |
Lenght of the insurance. |
i |
Interest rate |
m |
Deferring period. |
k |
Fractional payment frequency. |
status |
Either |
type |
A string, either |
power |
The power of the APV. Default is 1 (mean). |
payment |
The Payment type, either |
In theory, these functions apply the same concept of life insurances on one head on multiple heads.
The insurance value is returned.
These functions are the more general version of axyn
and
Axyn
.
Giorgio Alfredo Spedicato, Kevin J. Owens.
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate and life-long annuity for an aged 65 listOfTables=list(soa08Act, soa08Act) #Check actuarial equality axyzn(listOfTables,x=c(60,70),status="last") axn(listOfTables[[1]],60)+axn(listOfTables[[2]],70)- axyzn(listOfTables,x=c(60,70),status="joint")
data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate and life-long annuity for an aged 65 listOfTables=list(soa08Act, soa08Act) #Check actuarial equality axyzn(listOfTables,x=c(60,70),status="last") axn(listOfTables[[1]],60)+axn(listOfTables[[2]],70)- axyzn(listOfTables,x=c(60,70),status="joint")
This function evaluates the n-year term decreasing life insurance. Both actuarial value and stochastic random sample can be returned.
DAxn(actuarialtable, x, n, i=actuarialtable@interest,m = 0,k=1, type = "EV", power=1)
DAxn(actuarialtable, x, n, i=actuarialtable@interest,m = 0,k=1, type = "EV", power=1)
actuarialtable |
An actuarial table object. |
x |
Age of the insured. |
n |
Length of the insurance period. |
i |
Interest rate, when present it overrides the interest rate of the actuarial table object. |
m |
Deferring period, even fractional, assumed 1 whether missing. |
k |
Number of fractional payments per period. Assumed to be 1 whether missing. |
type |
A string, either |
power |
The power of the APV. Default is 1 (mean) |
Formulas of Bowes book have been implemented.
A numeric value representing the expected value or the simulated value.
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
Neither fractional payments nor stochastic calculations have been implemented yet.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#using SOA illustrative life tables data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a 10 years decreasing term life insurance for an aged 25 DAxn(actuarialtable=soa08Act, x=25, n=10)
#using SOA illustrative life tables data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a 10 years decreasing term life insurance for an aged 25 DAxn(actuarialtable=soa08Act, x=25, n=10)
A list of data.frames containing transition probabilities by age (row) and year of projections Transitions are split by males and females, and show probabilities of survival, death and transitions from Healty to Disabled
de_angelis_di_falco
de_angelis_di_falco
a list containing elevent items (data.frames), and an mdt data object (HealthyMaleTable2013)
Paolo De Angelis, Luigi di Falco (a cura di). Assicurazioni sulla salute: caratteristiche, modelli attuariali e basi tecniche
This function return present values for decreasing annuities - certain.
decreasingAnnuity(i, n,type="immediate")
decreasingAnnuity(i, n,type="immediate")
i |
A numeric value representing the interest rate. |
n |
The number of periods. |
type |
The Payment type, either |
A decreasing annuity has the following flows of payments: n, n-1, n-2, ..., 1, 0.
A numeric value reporting the present value of the decreasing cash flows.
The function is provided as is, without any guarantee regarding the accuracy of calculation. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
This function calls presentValue
function internally.
Giorgio A. Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
annuity
,increasingAnnuity
,DAxn
#the present value of 10, 9, 8,....,0 payable at the end of the period #for 10 years is decreasingAnnuity(i=0.03, n=10) #assuming a 3% interest rate #should be sum((10:1)/(1+.03)^(1:10))
#the present value of 10, 9, 8,....,0 payable at the end of the period #for 10 years is decreasingAnnuity(i=0.03, n=10) #assuming a 3% interest rate #should be sum((10:1)/(1+.03)^(1:10))
UP94 life tables underlying mortality rates
data(demoCanada)
data(demoCanada)
A data frame with 120 observations on the following 7 variables.
x
age
up94M
UP 94, males
up94F
UP 94, females
up942015M
UP 94 projected to 2015, males
up942015f
UP 94 projected to 2015, females
up942020M
UP 94 projected to 2020, males
up942020F
UP 94 projected to 2020, females
Mortality rates are provided.
Courtesy of Andrew Botros
Courtesy of Andrew Botros
data(demoCanada) head(demoCanada) #create the up94M life table up94MLt<-probs2lifetable(probs=demoCanada$up94M,radix=100000,"qx",name="UP94") #create the up94M actuarial table table up94MAct<-new("actuarialtable", lx=up94MLt@lx, x=up94MLt@x,interest=0.02)
data(demoCanada) head(demoCanada) #create the up94M life table up94MLt<-probs2lifetable(probs=demoCanada$up94M,radix=100000,"qx",name="UP94") #create the up94M actuarial table table up94MAct<-new("actuarialtable", lx=up94MLt@lx, x=up94MLt@x,interest=0.02)
Seven yearly mortality rates for each age
data(demoChina)
data(demoChina)
A data frame with 106 observations on the following 8 variables.
age
Attained age
CL1
CL1 rates
CL2
CL2 rates
CL3
CL3 rates
CL4
CL4 rates
CL5
CL5 rates
CL6
CL6 rates
CL90-93
CL 90-93 rates
See the source link for details.
Society of Actuaries
data(demoChina) tableChinaCL1<-probs2lifetable(probs=demoChina$CL1,radix=1000,type="qx",name="CHINA CL1")
data(demoChina) tableChinaCL1<-probs2lifetable(probs=demoChina$CL1,radix=1000,type="qx",name="CHINA CL1")
Illustrative life tables from French population.
data(demoFrance)
data(demoFrance)
A data frame with 113 observations on the following 5 variables.
age
Attained age
TH00_02
Male 2000 life table
TF00_02
Female 2000 life table
TD88_90
1988 1990 life table
TV88_90
1988 1990 life table
These tables are real French population life tables. They regard 88 - 90 and 00 - 02 experience.
Actuaris - Winter Associes
data(demoFrance) head(demoFrance)
data(demoFrance) head(demoFrance)
Dataset containing mortality rates for German population, male and females.
data(demoGermany)
data(demoGermany)
A data frame with 113 observations on the following 5 variables.
x
Attained age
qxMale
Male mortality rate
qxFemale
Female mortality rate
Sterbetafel DAV 1994
Private communicatiom
data(demoGermany) head(demoGermany)
data(demoGermany) head(demoGermany)
This dataset reports five pairs of Italian population life tables. These table can be used to create life table objects and actuarial tables object.
data(demoIta)
data(demoIta)
A data frame with 121 observations on the following 9 variables.
X
a numeric vector, representing ages from 0 to .
SIM02
a numeric vector, 2002 cross section general population males life table
SIF02
a numeric vector, 2002 cross section general population females life table
SIM00
a numeric vector, 2000 cross section general population males life table
SIF00
a numeric vector, 2000 cross section general population females life table
SIM92
a numeric vector, 1992 cross section general population males life table
SIF92
a numeric vector, 1992 cross section general population females life table
SIM81
a numeric vector, 1981 cross sectional general population males life table
SIF81
a numeric vector, 1981 cross sectional general population females life table
SIM61
a numeric vector, 1961 cross sectional general population males life table
SIF61
a numeric vector, 1961 cross sectional general population females life table
RG48M
a numeric vector, RG48 projected males life table
RG48F
a numeric vector, RG48 projected females life table
IPS55M
a numeric vector, IPS55 projected males life table
IPS55F
a numeric vector, IPS55 projected females life table
SIM71
a numeric vector, 1971 cross sectional general population males life table
SIM51
a numeric vector, 1951 cross sectional general population males life table
SIM31
a numeric vector, 1931 cross sectional general population males life table
These table contains the vectors of survival at the beginning of life years and are the building block of both
lifetable
and actuarialtable
classes.
These tables comes from Italian national statistical bureau (ISTAT) for SI series, government Ministry of Economics (Ragioneria Generale dello Stato) for RG48 or from Insurers' industrial association IPS55. RG48 represents the projected survival table for the 1948 born cohort, while IPS55 represents the projected survival table for the 1955 born cohort.
ISTAT, IVASS, Ordine Nazionale Attuari
#load and show data(demoIta) head(demoIta) #create sim92 life and actuarial table lxsim92<-demoIta$SIM92 lxsim92<-lxsim92[!is.na(lxsim92) & lxsim92!=0] xsim92<-seq(0,length(lxsim92)-1,1) #create the table sim92lt=new("lifetable",x=xsim92,lx=lxsim92,name="SIM92") plot(sim92lt)
#load and show data(demoIta) head(demoIta) #create sim92 life and actuarial table lxsim92<-demoIta$SIM92 lxsim92<-lxsim92[!is.na(lxsim92) & lxsim92!=0] xsim92<-seq(0,length(lxsim92)-1,1) #create the table sim92lt=new("lifetable",x=xsim92,lx=lxsim92,name="SIM92") plot(sim92lt)
Two yearly mortality rates for each age
data(demoJapan)
data(demoJapan)
A data frame with 110 observations on the following 3 variables.
JP8587M
Male life table
JP8587F
Female life table
age
Attained age
Dowloaded in 2012 from Society of Actuaries (SOA) mortality table web site
SOA mortality web site
data(demoJapan) head(demoJapan)
data(demoJapan) head(demoJapan)
AM and AF one year mortality rate. Series of 1992
data(demoUk)
data(demoUk)
A data frame with 74 observations on the following 3 variables:
Age
Annuitant age
AM92
One year mortality rate (males)
AF92
One year mortality rate (males)
This data set shows the one year survival rates for males and females of the 1992 series. It has been taken from the Institute of Actuaries. The series cannot be directly used to create a life table since neither rates are not provided for ages below 16 nor for ages over 90. Various approach can be used to complete the series.
Institute of Actuaries
data(demoUk) head(demoUk)
data(demoUk) head(demoUk)
This data set contains period life tables for years 1990, 2000 and 2007. Both males and females life tables are reported.
demoUsa
demoUsa
A data.frame
containing people surviving at the beginning of "age" at 2007, 2000, and 1990
split by gender
Reported age is truncated at the last age with lx>0.
See https://www.ssa.gov/oact/NOTES/as120/LifeTables_Body.html
data(demoUsa) head(demoUsa)
data(demoUsa) head(demoUsa)
Compute the duration or the convexity of a series of CF
duration(cashFlows, timeIds, i, k = 1, macaulay = TRUE) convexity(cashFlows, timeIds, i, k = 1)
duration(cashFlows, timeIds, i, k = 1, macaulay = TRUE) convexity(cashFlows, timeIds, i, k = 1)
cashFlows |
A vector representing the cash flows amounts. |
timeIds |
Cash flows times |
i |
APR interest, i.e. nominal interest rate compounded m-thly. |
k |
Compounding frequency for the nominal interest rate. |
macaulay |
Use the Macaulay formula |
The Macaulay duration is defined as
,
while
A numeric value representing either the duration or the convexity of the cash flow series
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
#evaluate the duration/convexity of a coupon payment cf=c(10,10,10,10,10,110) t=c(1,2,3,4,5,6) duration(cf, t, i=0.03) convexity(cf, t, i=0.03)
#evaluate the duration/convexity of a coupon payment cf=c(10,10,10,10,10,110) t=c(1,2,3,4,5,6) duration(cf, t, i=0.03) convexity(cf, t, i=0.03)
Expected residual life.
exn(object, x, n, type = "curtate")
exn(object, x, n, type = "curtate")
object |
A lifetable/actuarialtable object. |
x |
Attained age |
n |
Time until which the expected life should be calculated. Assumed omega - x whether missing. |
type |
Either |
A numeric value representing the expected life span.
Giorgio Alfredo Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#loads and show data(soa08Act) exn(object=soa08Act, x=0) exn(object=soa08Act, x=0,type="complete")
#loads and show data(soa08Act) exn(object=soa08Act, x=0) exn(object=soa08Act, x=0,type="complete")
Function to evaluate the pure endowment
Exn(actuarialtable, x, n, i = actuarialtable@interest, type = "EV", power = 1)
Exn(actuarialtable, x, n, i = actuarialtable@interest, type = "EV", power = 1)
actuarialtable |
An actuarial table object. |
x |
Age of the insured. |
n |
Length of the contract. |
i |
Interest rate (it overwrites the |
type |
A string, eithed "EV" (default value), "ST" (stocastic realization) or "VR" if the value of the variance is needed. |
power |
The power of the APV. Default is 1 (mean) |
The APV of the contract
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the pure endowment for a man aged 30 for a time span of 35 Exn(soa08Act, x=30, n=35)
#assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the pure endowment for a man aged 30 for a time span of 35 Exn(soa08Act, x=30, n=35)
This function list the character decrements of the mdf class
getDecrements(object)
getDecrements(object)
object |
A |
A character vector is returned
A character vector listing the decrements defined in the class
To be updated
Giorgio Spedicato
Marcel Finan A Reading of the Theory of Life Contingency Models: A Preparation for Exam MLC/3L
#create a new table tableDecr=data.frame(d1=c(150,160,160),d2=c(50,75,85)) newMdt<-new("mdt",name="testMDT",table=tableDecr) getDecrements(newMdt)
#create a new table tableDecr=data.frame(d1=c(150,160,160),d2=c(50,75,85)) newMdt<-new("mdt",name="testMDT",table=tableDecr) getDecrements(newMdt)
It returns the present value of a life contingency, specified by its APV symbol, known the time to death ob the sibjects
getLifecontingencyPv(deathsTimeX, lifecontingency, object, x, t, i = object@interest, m = 0, k = 1, payment = "advance") getLifecontingencyPvXyz(deathsTimeXyz, lifecontingency, tablesList, x, t, i, m = 0, k = 1, status = "joint", payment = "advance")
getLifecontingencyPv(deathsTimeX, lifecontingency, object, x, t, i = object@interest, m = 0, k = 1, payment = "advance") getLifecontingencyPvXyz(deathsTimeXyz, lifecontingency, tablesList, x, t, i, m = 0, k = 1, status = "joint", payment = "advance")
deathsTimeX |
Time to death |
lifecontingency |
lifecontingency symbol |
object |
life table(s) |
x |
age(s) of the policyholder(s) |
t |
term of the contract |
i |
interest rate |
m |
deferrement |
k |
fractional payments |
payment |
The Payment type, either |
deathsTimeXyz |
matrix of death times from birth |
tablesList |
list of table of the same size of num column of deathTimeXyz. |
status |
Either |
This function is a wrapper to the many internal functions that give the PV known the age of death.
A vector or matrix of size number of rows of deathTimeXyz / deathTimeXy
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
Multiple life function needs to be tested
Spedicato Giorgio
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
rLifeContingenciesXyz
, rLifeContingencies
#simulate the PV values for some life contingencies given some death times data(soa08Act) testgetLifecontingencyPvXyzAxyz<-getLifecontingencyPvXyz(deathsTimeXyz= matrix(c(50,50,51,43,44,22,12,56,20,24,53,12), ncol=2), lifecontingency = "Axyz",tablesList = list(soa08Act, soa08Act), i = 0.03, t=30,x=c(40,50), m=0, k=1,status="last") testgetLifecontingencyPvAxn<-getLifecontingencyPv(deathsTimeX = seq(0, 110, by=1), lifecontingency = "Axn", object=soa08Act, x=40,t=20, m=0, k=1)
#simulate the PV values for some life contingencies given some death times data(soa08Act) testgetLifecontingencyPvXyzAxyz<-getLifecontingencyPvXyz(deathsTimeXyz= matrix(c(50,50,51,43,44,22,12,56,20,24,53,12), ncol=2), lifecontingency = "Axyz",tablesList = list(soa08Act, soa08Act), i = 0.03, t=30,x=c(40,50), m=0, k=1,status="last") testgetLifecontingencyPvAxn<-getLifecontingencyPv(deathsTimeX = seq(0, 110, by=1), lifecontingency = "Axn", object=soa08Act, x=40,t=20, m=0, k=1)
This function returns the value of a life table object, that is,
the last attainable age within a life table.
getOmega(object)
getOmega(object)
object |
A life table object. |
A numeric value representing the value of a life table object
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#assumes SOA example life table to be load data(soaLt) soa08=with(soaLt, new("lifetable", x=x,lx=Ix,name="SOA2008")) #the last attainable age under SOA life table is getOmega(soa08)
#assumes SOA example life table to be load data(soaLt) soa08=with(soaLt, new("lifetable", x=x,lx=Ix,name="SOA2008")) #the last attainable age under SOA life table is getOmega(soa08)
This function evaluates increasing annuities
Iaxn(actuarialtable, x, n, i, m = 0, type = "EV", power=1)
Iaxn(actuarialtable, x, n, i, m = 0, type = "EV", power=1)
actuarialtable |
An |
x |
The age of the insured head. |
n |
The duration of the insurance |
i |
The interest rate that overrides the one in the |
m |
The deferring period. |
type |
Yet only "EV" is implemented. |
power |
The power of the APV. Default is 1 (mean) |
This actuarial mathematics is generally exoteric. I have seen no valid example of it.
The APV of the insurance
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#using SOA illustrative life tables data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a lifetime increasing annuity for a subject aged 80 Iaxn(actuarialtable=soa08Act, x=80, n=10)
#using SOA illustrative life tables data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a lifetime increasing annuity for a subject aged 80 Iaxn(actuarialtable=soa08Act, x=80, n=10)
This function evaluates the APV of an increasing life insurance.
The amount payable at the end of year of death are: .
N can be set as
.
IAxn(actuarialtable, x, n,i=actuarialtable@interest, m = 0, k=1, type = "EV", power=1)
IAxn(actuarialtable, x, n,i=actuarialtable@interest, m = 0, k=1, type = "EV", power=1)
actuarialtable |
The actuarial table used to perform life - contingencies calculations. |
x |
The age of the insured. |
n |
The term of life insurance. If missing n is set as |
i |
Interest rate (overrides the interest rate of the actuarialtable object). |
m |
The deferring period. If missing, m is set as 0. |
k |
Number of fractional payments per period. Assumed to be 1 whether missing. |
type |
A string, either |
power |
The power of the APV. Default is 1 (mean). |
The stochastic value feature has not been implemented yet.
A numeric value.
The function is provided as is, without any guarantee regarding the accuracy of calculation. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a 10 years increasing term life insurance for an aged 25 IAxn(actuarialtable=soa08Act, x=25, n=10)
#assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) #evaluate the value of a 10 years increasing term life insurance for an aged 25 IAxn(actuarialtable=soa08Act, x=25, n=10)
This function evaluates non - stochastic increasing annuities.
increasingAnnuity(i, n, type = "immediate")
increasingAnnuity(i, n, type = "immediate")
i |
A numeric value representing the interest rate. |
n |
The number of periods. |
type |
The Payment type, either |
An increasing annuity shows the following flow of payments:
The value of the annuity.
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
This function calls internally presentValue
function.
Giorgio A. Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
#the present value of 1,2,...,n-1, n sequence of payments, #payable at the end of the period #for 10 periods is increasingAnnuity(i=0.03, n=10) #assuming a 3% interest rate
#the present value of 1,2,...,n-1, n sequence of payments, #payable at the end of the period #for 10 periods is increasingAnnuity(i=0.03, n=10) #assuming a 3% interest rate
There functions switch from interest to intensity and vice - versa.
intensity2Interest(intensity) interest2Intensity(i)
intensity2Interest(intensity) interest2Intensity(i)
intensity |
Intensity rate |
i |
interest rate |
Simple financial mathematics formulas are applied.
A numeric value.
Giorgio A. Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
# a force of interest of 0.02 corresponds to an APR of intensity2Interest(intensity=0.02) #an interest rate equal to 0.02 corresponds to a force of interest of of interest2Intensity(i=0.02)
# a force of interest of 0.02 corresponds to an APR of intensity2Interest(intensity=0.02) #an interest rate equal to 0.02 corresponds to a force of interest of of interest2Intensity(i=0.02)
These functions switch from interest to discount rates and vice - versa
interest2Discount(i) discount2Interest(d)
interest2Discount(i) discount2Interest(d)
i |
Interest rate |
d |
Discount rate |
The following formula (and its inverse) rules the relationships:
A numeric value
Giorgio Alfredo Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
intensity2Interest
,nominal2Real
discount2Interest(d=0.04)
discount2Interest(d=0.04)
This function evaluates non - stochastic increasing annuities future values.
Isn(i, n, type = "immediate")
Isn(i, n, type = "immediate")
i |
Interest rate. |
n |
Terms. |
type |
Either "due" for annuity due or "immediate" for annuity immediate. |
It calls increasingAnnuity
after having capitalized by
A numeric value
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
This function calls internally increasingAnnuity
function.
Giorgio A. Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
Isn(n=10,i=0.03)
Isn(n=10,i=0.03)
"lifetable"
lifetable
objects allow to define and use life tables with the aim to evaluate
survival probabilities and mortality rates easily.
Such values represent the building blocks used to estimate life insurances actuarial mathematics.
Objects can be created by calls of the form new("lifetable", ...)
.
Two vectors are needed. The age vector and the population at risk vector.
x
:Object of class "numeric"
, representing the sequence 0,1,
lx
:Object of class "numeric"
, representing the number of lives at the beginning of age . It is a non
increasing sequence. The last element of vector x is supposed to be > 0.
name
:Object of class "character"
, reporting the name of the table
signature(from = "lifetable", to = "data.frame")
: method to create a data - frame from a lifetable object
signature(from = "lifetable", to = "markovchainList")
: coerce method from lifetable
to markovchainList
signature(from = "lifetable", to = "numeric")
: brings to numeric
signature(from = "data.frame", to = "lifetable")
: brings to life table
signature(object = "lifetable")
: returns the maximum attainable life age
signature(x = "lifetable", y = "ANY")
: plot method
signature(x = "lifetable")
: head method
signature(x = "lifetable")
: method to print the survival probability implied in the table
signature(object = "lifetable")
: identical to plot
method
signature(object = "lifetable")
: it returns summary information about the object
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
t
may be missing in pxt
, qxt
, ext
. It assumes value equal to 1 in such case.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
showClass("lifetable") data(soa08) summary(soa08) #the last attainable age under SOA life table is getOmega(soa08) #head and tail data(soaLt) tail(soaLt) head(soaLt)
showClass("lifetable") data(soa08) summary(soa08) #the last attainable age under SOA life table is getOmega(soa08) #head and tail data(soaLt) tail(soaLt) head(soaLt)
Various demographic functions
Lxt(object, x, t = 1, fxt = 0.5) Tx(object, x)
Lxt(object, x, t = 1, fxt = 0.5) Tx(object, x)
object |
a |
x |
age of the subject |
t |
duration of the calculation |
fxt |
correction constant, default 0.5 |
Tx
il the sum of years lived since age x
by the population of the life table, it is the sum of Lx
. The function is provided as is,
without any warranty regarding the accuracy of calculations. Use at own risk.
A numeric value
Giorgio Alfredo Spedicato.
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) Lxt(soa08Act, 67,10) #assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) Tx(soa08Act, 67)
data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) Lxt(soa08Act, 67,10) #assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) Tx(soa08Act, 67)
"mdt"
A class to store multiple decrement tables
Objects can be created by calls of the form new("mdt", name, table, ...)
.
They store absolute decrements
name
:The name of the table
table
:A data frame containing at least the number of decrements
signature(object = "mdt")
: return the name of decrements
signature(object = "mdt")
: maximum attainable age
signature(.Object = "mdt")
: method to initialize the class
signature(x = "mdt")
: tabulate absolute decrement rates
signature(object = "mdt")
: show rates of decrement
signature(from = "mdt", to = "markovchainList")
: coercing to markovchainList
objects
signature(from = "mdt", to = "data.frame")
: coercing to markovchainList
objects
signature(object = "mdt")
: it returns summary information about the object
Currently only decrements storage of the class is defined.
Giorgio Spedicato
Marcel Finan A Reading of the Theory of Life Contingency Models: A Preparation for Exam MLC/3L
#shows the class definition showClass("mdt") #create a new table tableDecr=data.frame(d1=c(150,160,160),d2=c(50,75,85)) newMdt<-new("mdt",name="testMDT",table=tableDecr)
#shows the class definition showClass("mdt") #create a new table tableDecr=data.frame(d1=c(150,160,160),d2=c(50,75,85)) newMdt<-new("mdt",name="testMDT",table=tableDecr)
These functions evaluate multiple life survival probabilities, either for joint or last life status. Arbitrary life probabilities can be generated as well as random samples of lifes.
exyzt(tablesList, x, t = Inf, status = "joint", type = "Kx", ...) pxyzt(tablesList, x, t, status = "joint", fractional=rep("linear", length(tablesList)), ...) qxyzt(tablesList, x, t, status = "joint", fractional=rep("linear",length(tablesList)), ...)
exyzt(tablesList, x, t = Inf, status = "joint", type = "Kx", ...) pxyzt(tablesList, x, t, status = "joint", fractional=rep("linear", length(tablesList)), ...) qxyzt(tablesList, x, t, status = "joint", fractional=rep("linear",length(tablesList)), ...)
tablesList |
A list whose elements are either |
x |
A vector of the same size of tableList that contains the initial ages. |
t |
The duration. |
status |
Either |
type |
Either |
fractional |
Assumptions for fractional age. One of |
... |
Options to be passed to |
These functions extends pxyt
family to an arbitrary number of life contingencies.
An estimate of survival / death probability or expected lifetime, or a matrix of ages.
The procedure is experimental.
Giorgio Alfredo, Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
#assessment of curtate expectation of future lifetime of the joint-life status #generate a sample of lifes data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) tables=list(males=soa08Act, females=soa08Act) xVec=c(60,65) test=rLifexyz(n=50000, tablesList = tables,x=xVec,type="Kx") #check first survival status t.test(x=apply(test,1,"min"),mu=exyzt(tablesList=tables, x=xVec,status="joint")) #check last survival status t.test(x=apply(test,1,"max"),mu=exyzt(tablesList=tables, x=xVec,status="last"))
#assessment of curtate expectation of future lifetime of the joint-life status #generate a sample of lifes data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) tables=list(males=soa08Act, females=soa08Act) xVec=c(60,65) test=rLifexyz(n=50000, tablesList = tables,x=xVec,type="Kx") #check first survival status t.test(x=apply(test,1,"min"),mu=exyzt(tablesList=tables, x=xVec,status="joint")) #check last survival status t.test(x=apply(test,1,"max"),mu=exyzt(tablesList=tables, x=xVec,status="last"))
Function to convert mortality rates to probabilities of death
mx2qx(mx, ax = 0.5)
mx2qx(mx, ax = 0.5)
mx |
mortality rates vector |
ax |
the average number of years lived between ages x and x +1 by individuals who die in that interval |
Function to convert mortality rates to probabilities of death
A vector of death probabilities
mxt
, qxt
, qx2mx
#using some recursion qx2mx(mx2qx(.2))
#using some recursion qx2mx(mx2qx(.2))
This function returns the central mortality rate demographic function.
mxt(object, x, t)
mxt(object, x, t)
object |
a |
x |
subject's age |
t |
period on which the rate is evaluated |
A numeric value representing the central mortality rate between age and
.
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) #compare mx and qx mxt(soa08Act, 60,10) qxt(soa08Act, 60,10)
#assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) #compare mx and qx mxt(soa08Act, 60,10) qxt(soa08Act, 60,10)
Functions to switch from nominal / effective / convertible rates
nominal2Real(i, k = 1, type = "interest") convertible2Effective(i, k = 1, type = "interest") real2Nominal(i, k = 1, type = "interest") effective2Convertible(i, k = 1, type = "interest")
nominal2Real(i, k = 1, type = "interest") convertible2Effective(i, k = 1, type = "interest") real2Nominal(i, k = 1, type = "interest") effective2Convertible(i, k = 1, type = "interest")
i |
The rate to be converted. |
k |
The original / target compounting frequency. |
type |
Either "interest" (default) or "nominal". |
effective2Convertible
and convertible2Effective
wrap the other two functions.
A numeric value.
Convertible rates are synonims of nominal rates
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
#a nominal rate of 0.12 equates an APR of nominal2Real(i=0.12, k = 12, "interest")
#a nominal rate of 0.12 equates an APR of nominal2Real(i=0.12, k = 12, "interest")
This function evaluates the present values of a series of cash flows, given occurrence time. Probabilities of occurrence can also be taken into account.
presentValue(cashFlows, timeIds, interestRates, probabilities,power=1)
presentValue(cashFlows, timeIds, interestRates, probabilities,power=1)
cashFlows |
Vector of cashFlow, must be coherent with |
timeIds |
Vector of points of time where |
interestRates |
A numeric value or a time-size vector of interest rate used to discount cahs flow. |
probabilities |
Optional vector of probabilities. |
power |
Power to square discount and cash flows. Default is set to 1 |
probabilities
is optional, a sequence of 1 length of timeIds is assumed.
Interest rate shall be a fixed number or a vector of the same size of timeIds
. power
parameters is generally useless
beside life contingencies insurances evaluations.
A numeric value representing the present value of cashFlows vector, or the actuarial present value if probabilities are provided.
The function is provided as is, without any guarantee regarding the accuracy of calculation. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
This simple function is the kernel working core of the package. Actuarial and financial mathematics ground on it.
Giorgio A. Spedicato
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
#simple example cf=c(10,10,10) #$10 of payments one per year for three years t=c(1,2,3) #years p=c(1,1,1) #assume payments certainty #assume 3% of interest rate presentValue(cashFlows=cf, timeIds=t, interestRates=0.03, probabilities=p)
#simple example cf=c(10,10,10) #$10 of payments one per year for three years t=c(1,2,3) #years p=c(1,1,1) #assume payments certainty #assume 3% of interest rate presentValue(cashFlows=cf, timeIds=t, interestRates=0.03, probabilities=p)
This function returns a newly created lifetable object given either survival or death (one year) probabilities)
probs2lifetable(probs, radix = 10000, type = "px", name = "ungiven")
probs2lifetable(probs, radix = 10000, type = "px", name = "ungiven")
probs |
A real valued vector representing either one year survival or death probabilities. The last value in the vector must be either 1 or 0, depending if it represents death or survival probabilities respectively. |
radix |
The radix of the life table. |
type |
Character value either "px" or "qx" indicating how probabilities must be interpreted. |
name |
The character value to be put in the corresponding slot of returned object. |
The value is the length of the probs vector.
A lifetable
object.
The function is provided as is, without any guarantee regarding the accuracy of calculation. We disclaim any liability for eventual losses arising from direct or indirect use of this software.
This function allows to use mortality projection given by other softwares with the lifecontingencies package.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
fakeSurvivalProbs=seq(0.9,0,by=-0.1) newTable=probs2lifetable(fakeSurvivalProbs,type="px",name="fake") head(newTable) tail(newTable)
fakeSurvivalProbs=seq(0.9,0,by=-0.1) newTable=probs2lifetable(fakeSurvivalProbs,type="px",name="fake") head(newTable) tail(newTable)
These functions evaluate raw survival and death probabilities between age x and x+t
dxt(object, x, t, decrement) pxt(object, x, t, fractional = "linear", decrement) qxt(object, x, t, fractional = "linear", decrement)
dxt(object, x, t, decrement) pxt(object, x, t, fractional = "linear", decrement) qxt(object, x, t, fractional = "linear", decrement)
object |
A |
x |
Age of life |
t |
Period until which the age shall be evaluated. Default value is 1.
(can be a vector for |
fractional |
Assumptions for fractional age. One of |
decrement |
The reason of decrement (only for |
Fractional assumptions are:
linear: linear interpolation between consecutive ages, i.e. assume uniform distribution.
constant force of mortality : constant force of mortality, also known as exponential interpolation.
hyperbolic: Balducci assumption, also known as harmonic interpolation.
Note that fractional="uniform"
, "exponential"
, "harmonic"
or "Balducci"
is also authorized.
See references for details.
A numeric value representing requested probability.
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
Function dxt
accepts also fractional value of t. Linear interpolation is used in such case. These functions are called by many other functions.
Giorgio A. Spedicato
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
#dxt example data(soa08Act) dxt(object=soa08Act, x=90, t=2) #qxt example qxt(object=soa08Act, x=90, t=2) #pxt example pxt(object=soa08Act, x=90, t=2, "constant force" ) #add another example for MDT
#dxt example data(soa08Act) dxt(object=soa08Act, x=90, t=2) #qxt example qxt(object=soa08Act, x=90, t=2) #pxt example pxt(object=soa08Act, x=90, t=2, "constant force" ) #add another example for MDT
These functions evaluate survival and death probabilities for two heads.
exyt(objectx, objecty, x, y, t, status = "joint") pxyt(objectx, objecty, x, y, t, status = "joint") qxyt(objectx, objecty, x, y, t, status = "joint")
exyt(objectx, objecty, x, y, t, status = "joint") pxyt(objectx, objecty, x, y, t, status = "joint") qxyt(objectx, objecty, x, y, t, status = "joint")
objectx |
|
objecty |
|
x |
Age of life X. |
y |
Age of life Y. |
t |
Time until survival has to be evaluated. |
status |
Either |
A numeric value representing joint survival probability.
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software. Also it is being Deprecated and asap removed from the package.
These functions are used to evaluate two or more life contingencies.
Giorgio A. Spedicato, Kevin J. Owens.
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
## Not run: data(soa08Act) pxyt(soa08Act, soa08Act, 65, 70,10) pxyt(soa08Act, soa08Act, 65, 70,10, "last") ## End(Not run)
## Not run: data(soa08Act) pxyt(soa08Act, soa08Act, 65, 70,10) pxyt(soa08Act, soa08Act, 65, 70,10, "last") ## End(Not run)
Function to convert death probabilities to mortality rates
qx2mx(qx, ax = 0.5)
qx2mx(qx, ax = 0.5)
qx |
death probabilities |
ax |
the average number of years lived between ages x and x +1 by individuals who die in that interval |
Function to convert death probabilities to mortality rates
A vector of mortality rates
mxt
, qxt
, mx2qx
data(soa08Act) soa08qx<-as(soa08Act,"numeric") soa08mx<-qx2mx(qx=soa08qx) soa08qx2<-mx2qx(soa08mx)
data(soa08Act) soa08qx<-as(soa08Act,"numeric") soa08mx<-qx2mx(qx=soa08qx) soa08qx2<-mx2qx(soa08mx)
Return Associated single decrement from absolute rate of decrement
qxt.prime.fromMdt(object, x, t = 1, decrement) qxt.fromQxprime(qx.prime, other.qx.prime, t = 1)
qxt.prime.fromMdt(object, x, t = 1, decrement) qxt.fromQxprime(qx.prime, other.qx.prime, t = 1)
object |
a mdj object |
x |
age |
t |
period (default 1) |
decrement |
type (necessary) |
qx.prime |
single ASDT decrement of which corresponding decrement is desired |
other.qx.prime |
ASDT decrements other than |
a single value (AST)
qxt.fromQxprime()
: Obtain decrement from single decrements
#Creating the valdez mdf valdezDf<-data.frame( x=c(50:54), lx=c(4832555,4821937,4810206,4797185,4782737), hearth=c(5168, 5363, 5618, 5929, 6277), accidents=c(1157, 1206, 1443, 1679,2152), other=c(4293,5162,5960,6840,7631)) valdezMdt<-new("mdt",name="ValdezExample",table=valdezDf) qxt.prime.fromMdt(object=valdezMdt,x=53,decrement="other") #Finan example 67.2 qxt.fromQxprime(qx.prime = 0.01,other.qx.prime = c(0.03,0.06))
#Creating the valdez mdf valdezDf<-data.frame( x=c(50:54), lx=c(4832555,4821937,4810206,4797185,4782737), hearth=c(5168, 5363, 5618, 5929, 6277), accidents=c(1157, 1206, 1443, 1679,2152), other=c(4293,5162,5960,6840,7631)) valdezMdt<-new("mdt",name="ValdezExample",table=valdezDf) qxt.prime.fromMdt(object=valdezMdt,x=53,decrement="other") #Finan example 67.2 qxt.fromQxprime(qx.prime = 0.01,other.qx.prime = c(0.03,0.06))
Function to generate samples from the life contingencies stochastic variables
rLifeContingencies( n, lifecontingency, object, x, t, i = object@interest, m = 0, k = 1, parallel = FALSE, payment = "advance" ) rLifeContingenciesXyz( n, lifecontingency, tablesList, x, t, i, m = 0, k = 1, status = "joint", parallel = FALSE, payment = "advance" )
rLifeContingencies( n, lifecontingency, object, x, t, i = object@interest, m = 0, k = 1, parallel = FALSE, payment = "advance" ) rLifeContingenciesXyz( n, lifecontingency, tablesList, x, t, i, m = 0, k = 1, status = "joint", parallel = FALSE, payment = "advance" )
n |
Size of sample |
lifecontingency |
A character string, either |
object |
An |
x |
Policyholder's age at issue time; for |
t |
The lenght of the insurance. Must be specified according to the present value of benefits definition. |
i |
The interest rate, whose default value is the |
m |
Deferring period, default value is zero. |
k |
Fractional payment, default value is 1. |
parallel |
Uses the parallel computation facility. |
payment |
The Payment type, either |
tablesList |
A list of |
status |
Either |
A numeric vector
## Not run: #assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) out<-rLifeContingencies(n=1000, lifecontingency="Axn",object=soa08Act, x=40, t=getOmega(soa08Act)-40, m=0) APV=Axn(soa08Act,x=40) #check if out distribution is unbiased t.test(x=out, mu=APV)$p.value>0.05 ## End(Not run) ## Not run: data(soa08Act) n=10000 lifecontingency="Axyz" tablesList=list(soa08Act,soa08Act) x=c(60,60); i=0.06; m=0; status="joint"; t=30; k=1 APV=Axyzn(tablesList=tablesList,x=x,n=t,m=m,k=k,status=status,type="EV") samples<-rLifeContingenciesXyz(n=n,lifecontingency = lifecontingency,tablesList = tablesList, x=x,t=t,m=m,k=k,status=status, parallel=FALSE) APV mean(samples) ## End(Not run)
## Not run: #assumes SOA example life table to be load data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06, x=x,lx=Ix,name="SOA2008")) out<-rLifeContingencies(n=1000, lifecontingency="Axn",object=soa08Act, x=40, t=getOmega(soa08Act)-40, m=0) APV=Axn(soa08Act,x=40) #check if out distribution is unbiased t.test(x=out, mu=APV)$p.value>0.05 ## End(Not run) ## Not run: data(soa08Act) n=10000 lifecontingency="Axyz" tablesList=list(soa08Act,soa08Act) x=c(60,60); i=0.06; m=0; status="joint"; t=30; k=1 APV=Axyzn(tablesList=tablesList,x=x,n=t,m=m,k=k,status=status,type="EV") samples<-rLifeContingenciesXyz(n=n,lifecontingency = lifecontingency,tablesList = tablesList, x=x,t=t,m=m,k=k,status=status, parallel=FALSE) APV mean(samples) ## End(Not run)
Function to generate random future lifetimes
rLife(n, object, x = 0, k = 1, type = "Tx") rLifexyz(n, tablesList, x, k = 1, type = "Tx")
rLife(n, object, x = 0, k = 1, type = "Tx") rLifexyz(n, tablesList, x, k = 1, type = "Tx")
n |
Number of variates to generate |
object |
An object of class lifetable |
x |
The attained age of subject x, default value is 0 |
k |
Number of periods within the year when it is possible death to happen, default value is 1 |
type |
Either |
tablesList |
An list of lifetables |
Following relation holds for the future life time:
A numeric vector of n elements.
The function is provided as is, without any warranty regarding the accuracy of calculations. The author disclaims any liability for eventual losses arising from direct or indirect use of this software.
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
## Not run: ##get 20000 random future lifetimes for the Soa life table at birth data(soa08Act) lifes=rLife(n=20000,object=soa08Act, x=0, type="Tx") check if the expected life at birth derived from the life table is statistically equal to the expected value of the sample t.test(x=lifes, mu=exn(soa08Act, x=0, type="continuous")) ## End(Not run) ## Not run: #assessment of curtate expectation of future lifetime of the joint-life status #generate a sample of lifes data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) tables=list(males=soa08Act, females=soa08Act) xVec=c(60,65) test=rLifexyz(n=50000, tablesList = tables,x=xVec,type="Kx") #check first survival status t.test(x=apply(test,1,"min"),mu=exyzt(tablesList=tables, x=xVec,status="joint")) #check last survival status t.test(x=apply(test,1,"max"),mu=exyzt(tablesList=tables, x=xVec,status="last")) ## End(Not run)
## Not run: ##get 20000 random future lifetimes for the Soa life table at birth data(soa08Act) lifes=rLife(n=20000,object=soa08Act, x=0, type="Tx") check if the expected life at birth derived from the life table is statistically equal to the expected value of the sample t.test(x=lifes, mu=exn(soa08Act, x=0, type="continuous")) ## End(Not run) ## Not run: #assessment of curtate expectation of future lifetime of the joint-life status #generate a sample of lifes data(soaLt) soa08Act=with(soaLt, new("actuarialtable",interest=0.06,x=x,lx=Ix,name="SOA2008")) tables=list(males=soa08Act, females=soa08Act) xVec=c(60,65) test=rLifexyz(n=50000, tablesList = tables,x=xVec,type="Kx") #check first survival status t.test(x=apply(test,1,"min"),mu=exyzt(tablesList=tables, x=xVec,status="joint")) #check last survival status t.test(x=apply(test,1,"max"),mu=exyzt(tablesList=tables, x=xVec,status="last")) ## End(Not run)
Simulate from a multiple decrement table
rmdt(n = 1, object, x = 0, t = 1, t0 = "alive", include.t0 = TRUE)
rmdt(n = 1, object, x = 0, t = 1, t0 = "alive", include.t0 = TRUE)
n |
Number of simulations. |
object |
The |
x |
the period to simulate from. |
t |
the period until to simulate. |
t0 |
initial status (default is "alive"). |
include.t0 |
should initial status to be included (default is TRUE)? |
A matrix with n columns (the length of simulation) and either t (if initial status is not included) or t+1 rows.
The functin uses rmarkovchain
function from markovchain package to simulate the chain
Giorgio Spedicato
rLifeContingenciesXyz
,rLifeContingencies
mdtDf<-data.frame(x=c(0,1,2,3),death=c(100,50,30,10),lapse=c(150,20,2,0)) myMdt<-new("mdt",name="example Mdt",table=mdtDf) ciao<-rmdt(n=5,object = myMdt,x = 0,t = 4,include.t0=FALSE,t0="alive")
mdtDf<-data.frame(x=c(0,1,2,3),death=c(100,50,30,10),lapse=c(150,20,2,0)) myMdt<-new("mdt",name="example Mdt",table=mdtDf) ciao<-rmdt(n=5,object = myMdt,x = 0,t = 4,include.t0=FALSE,t0="alive")
This is the table that appears in the classical book Actuarial Mathematics in Appendix 2A and used throughout the book to illustrate life contingent calculations. The Society of Actuaries has been using this table when administering US actuarial professional MLC preliminary examinations.
data(soa08)
data(soa08)
Formal class 'lifetable' [package "lifecontingencies"] with 3 slots ..@ x : int [1:141] 0 1 2 3 4 5 6 7 8 9 ... ..@ lx : num [1:141] 100000 97958 97826 97707 97597 ... ..@ name: chr "SOA Illustrative Life Table"
This table is a blend of Makeham's mortality law for ages 13 and above and some ad hoc values for ages 0 to 12.
The parameters for Makeham's mortality law are
1000 * mu(x) = 0.7 + 0.05 * 10^(0.04 * x)
where mu(x) is the force of mortality.
The published Illustrative Life Table just shows ages 0 to 110 but in the computing exercises of chapter 3 the authors explain that the table's age range is from 0 to 140.
This table is based on US 1990 general population mortality.
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
data(soa08) ## maybe str(soa08) ; plot(soa08) ...
data(soa08) ## maybe str(soa08) ; plot(soa08) ...
An object of class actuarialtable built from the SOA illustrative life table. Interest rate is 6
data(soa08Act)
data(soa08Act)
Formal class 'actuarialtable' [package "lifecontingencies"] with 4 slots ..@ interest: num 0.06 ..@ x : int [1:141] 0 1 2 3 4 5 6 7 8 9 ... ..@ lx : num [1:141] 100000 97958 97826 97707 97597 ... ..@ name : chr "SOA Illustrative Life Table"
This table is a blend of Makeham's mortality law for ages 13 and above and some ad hoc values for ages 0 to 12.
The parameters for Makeham's mortality law are
1000 * mu(x) = 0.7 + 0.05 * 10^(0.04 * x)
where mu(x) is the force of mortality.
The published Illustrative Life Table just shows ages 0 to 110 but in the computing exercises of chapter 3 the authors explain that the table's age range is from 0 to 140.
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
## Not run: data(soa08Act) ## End(Not run)
## Not run: data(soa08Act) ## End(Not run)
Bowers' book Illustrative Service Table
data(SoAISTdata)
data(SoAISTdata)
A data frame with 41 observations on the following 6 variables.
x
Attained age
lx
Surviving subjects ate the beginning of each age
death
Drop outs for death cause
withdrawal
Drop outs for withdrawal cause
inability
Drop outs for inability cause
retirement
Drop outs for retirement cause
It is a data frame that can be used to create a multiple decrement table
Optical recognized characters from below source with some few adjustments
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
data(SoAISTdata) head(SoAISTdata)
data(SoAISTdata) head(SoAISTdata)
This table has been used by the classical book Actuarial Mathematics and by the Society of Actuaries for US professional examinations.
data(soaLt)
data(soaLt)
A data.frame
with 111 obs on the following 2 variables:
x
a numeric vector
Ix
a numeric vector
Early ages have been found elsewere since miss in the original data sources; SOA did not provide population at risk data for certain spans of age (e.g. 1-5, 6-9, 11-14 and 16-19)
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
data(soaLt) head(soaLt)
data(soaLt) head(soaLt)
Uk AM AF life tables
data(AF92Lt)
data(AF92Lt)
The format is: Formal class 'lifetable' [package ".GlobalEnv"] with 3 slots ..@ x : int [1:111] 0 1 2 3 4 5 6 7 8 9 ... ..@ lx : num [1:111] 100000 99924 99847 99770 99692 ... ..@ name: chr "AF92"
Probabilities for earliest (under 16) and lastest ages (over 92) have been derived using a Brass - Logit model fit on Society of Actuaries life table.
See Uk life table.
data(AF92Lt) exn(AF92Lt) data(AM92Lt) exn(AM92Lt)
data(AF92Lt) exn(AF92Lt) data(AM92Lt) exn(AM92Lt)