| Type: | Package |
| Title: | Financial and Actuarial Mathematics for Life Contingencies |
| Version: | 1.6.4 |
| Maintainer: | Giorgio Alfredo Spedicato <spedicato_giorgio@yahoo.it> |
| 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>. |
| Depends: | R (≥ 4.4.0), methods |
| Imports: | ggplot2, parallel, utils, Rcpp (≥ 1.0.0), stats |
| Suggests: | demography, forecast, markovchain, testthat, knitr, formatR, StMoMo, survival, rmarkdown, quarto |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| LazyLoad: | yes |
| LazyData: | true |
| BugReports: | https://github.com/spedygiorgio/lifecontingencies/issues |
| BuildVignettes: | yes |
| VignetteBuilder: | utils, knitr, quarto |
| URL: | https://github.com/spedygiorgio/lifecontingencies |
| LinkingTo: | Rcpp |
| Config/roxygen2/version: | 8.1.1 |
| NeedsCompilation: | yes |
| Packaged: | 2026-11-22 22:27:44 UTC; Utente |
| Author: | Giorgio Alfredo Spedicato
|
| Repository: | CRAN |
| Date/Publication: | 2026-11-22 23:10:02 UTC |
Package to perform actuarial mathematics on life contingencies and classical financial mathematics calculations.
Description
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.
Details
Some functions have been powered by Rcpp code.
Warning
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.
Note
Work in progress.
Author(s)
Giorgio Alfredo Spedicato with contributions from Reinhold Kainhofer and Kevin J. Owens Maintainer: <spedicato_giorgio@yahoo.it>
References
The lifecontingencies Package: Performing Financial and Actuarial Mathematics Calculations in R, Giorgio Alfredo Spedicato, Journal of Statistical Software, 2013,55 , 10, 1-36
See Also
Examples
##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)
Multiple decrement insurances and annuities
Description
Axn.mdt gives the actuarial present value (APV) of a
term insurance on a multiple decrement table, paying at the end of the
year of decrement a benefit that may depend on the cause of decrement.
axn.mdt gives the APV of an annuity payable while the insured is
still in the active (no decrement yet) state.
Usage
Axn.mdt(object, x, n, i, decrement, benefits = 1, m = 0)
axn.mdt(object, x, n, i, m = 0, k = 1, payment = "advance")
Arguments
object |
an |
x |
policyholder's age (an integer age tabulated in |
n |
contract duration in years. If missing, the cover runs to the end
of the table, i.e. |
i |
interest rate |
decrement |
decrement(s) covered: one or more names (or column
indices) among |
benefits |
benefit amounts, one per element of |
m |
deferment period in years (default 0). |
k |
number of annuity payments per year (default 1). Survival
probabilities at fractional durations are interpolated linearly in
|
payment |
|
Details
With v = (1+i)^{-1} the insurance APV is
\sum_{j \in J} b_j \sum_{h=0}^{n-1} v^{m+h+1}\,{}_{m+h}p^{(\tau)}_x\, q^{(j)}_{x+m+h},
which for a single cause reduces to the historical Axn.mdt. The
annuity APV is \frac1k \sum_{h} v^{t_h}\, {}_{t_h}p^{(\tau)}_x, with
payment times t_h = m, m+1/k, \ldots, m+n-1/k (in advance) or
m+1/k, \ldots, m+n (in arrears). Benefit premiums and reserves follow
from the equivalence principle as ratios/differences of the two.
Value
A numeric vector of APVs (one per element of x).
References
Finan, M. B. (2014). A Reading of the Theory of Life Contingency Models: A Preparation for Exam MLC/3L, Sections 68-69.
Examples
# Finan (2014), Example 69.1: 3-year term on (16), i = 10%
myTable <- data.frame(x = 16:18, lx = c(20000, 17600, 14520),
da = c(1300, 1870, 2380), doc = c(1100, 1210, 1331))
myMdt <- new("mdt", table = myTable, name = "Finan 69.1")
A <- Axn.mdt(myMdt, x = 16, n = 3, i = 0.10, decrement = "doc")
a <- axn.mdt(myMdt, x = 16, n = 3, i = 0.10)
20000 * A / a # level annual premium: 1250
# Finan (2014), Example 68.1: benefit 1 for cause 1, 2 for cause 2
t681 <- data.frame(x = 50:51, lx = c(1200, 800),
d1 = c(100, 200), d2 = c(300, 300))
m681 <- new("mdt", table = t681)
Axn.mdt(m681, x = 50, n = 2, i = 0.5, decrement = c("d1", "d2"),
benefits = c(1, 2)) # 0.6852
Multiple lifes insurances and annuities
Description
Function to evalate the multiple lives insurances and annuities
Usage
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")
Arguments
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 |
Details
In theory, these functions apply the same concept of life insurances on one head on multiple heads.
Value
The insurance value is returned.
Note
These functions are the more general version of axyn and
Axyn.
Author(s)
Giorgio Alfredo Spedicato, Kevin J. Owens.
References
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
See Also
Examples
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")
Increasing annuity life contingencies
Description
This function evaluates increasing annuities
Usage
Iaxn(actuarialtable, x, n, i, m = 0, type = "EV", power=1)
Arguments
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) |
Details
This actuarial mathematics is generally exoteric. I have seen no valid example of it.
Value
The APV of the insurance
Warning
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.
Note
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.
Author(s)
Giorgio A. Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
#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)
Accumulated value of an increasing annuity
Description
Future (accumulated) value at time n of an increasing annuity with
payment stream 1, 2, \ldots, n. Equivalent to capitalising
increasingAnnuity by (1+i)^n.
Usage
Isn(i, n, type = "immediate")
Arguments
i |
Effective interest rate. |
n |
Number of periods. |
type |
|
Value
A numeric scalar.
Author(s)
Giorgio A. Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
accumulatedValue, increasingAnnuity
Examples
Isn(n = 10, i = 0.03)
SoA illustrative service table
Description
Bowers' book Illustrative Service Table
Usage
data(SoAISTdata)
Format
A data frame with 41 observations on the following 6 variables.
xAttained age
lxSurviving subjects ate the beginning of each age
deathDrop outs for death cause
withdrawalDrop outs for withdrawal cause
inabilityDrop outs for inability cause
retirementDrop outs for retirement cause
Details
It is a data frame that can be used to create a multiple decrement table
Source
Optical recognized characters from below source with some few adjustments
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
Examples
data(SoAISTdata)
head(SoAISTdata)
Uk AM AF 92 life tables
Description
Uk AM AF life tables
Usage
data(AF92Lt)
Format
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"
Details
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.
Source
See Uk life table.
References
Examples
data(AF92Lt)
exn(AF92Lt)
data(AM92Lt)
exn(AM92Lt)
Accumulated value of an annuity-certain
Description
Future value at time n of a stream of equally spaced unit payments.
With the standard identity
s_{\overline{n}|} = (1 + i)^n\, a_{\overline{n}|}, this is a thin
wrapper around annuity.
Usage
accumulatedValue(i, n, m = 0, k = 1, type = "immediate")
Arguments
i |
Effective interest rate. |
n |
Number of payment periods. |
m |
Deferment period. Default |
k |
Number of payments per year. Default |
type |
Payment timing: |
Value
A numeric scalar: the accumulated value.
Author(s)
Giorgio A. Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
Examples
# Future value of 1 per year, paid in arrears, for 10 years at 3%:
accumulatedValue(i = 0.03, n = 10)
Class "actuarialtable"
Description
Objects of class "actuarialtable" inherit the structure of class "lifetable" adding just the slot for interest rate, interest.
Objects from the Class
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.
Slots
interest:Object of class
"numeric"slot for interest rate, e.g. 0.03x:Object of class
"numeric"age slotlx:Object of class
"numeric"subjects at risk at age xname:Object of class
"character"name of the actuarial table
Extends
Class "lifetable", directly.
Methods
- coerce
signature(from = "actuarialtable", to = "data.frame"): moves fromactuarialtabletodata.frame- coerce
signature(from = "actuarialtable", to = "numeric"): coerce fromactuarialtableto a numeric- getOmega
signature(object = "actuarialtable"): as forlifetablesignature(x = "actuarialtable"): tabulates the actuarial commutation functions- show
signature(object = "actuarialtable"): show method- summary
signature(object = "actuarialtable"): prints brief summary
Warning
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.
Note
The interest slot will handle time-varying interest rates in the future.
Author(s)
Giorgio A. Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
showClass("actuarialtable")
Present value of an annuity-certain
Description
Compute the present value of a stream of fixed payments separated by equal
intervals of time. Returns the perpetuity value when n = Inf.
Usage
annuity(i, n, m = 0, k = 1, type = "immediate")
Arguments
i |
Effective interest rate expressed in decimal form (e.g. |
n |
Number of payment periods. |
m |
Deferment period. Default |
k |
Number of payments per year. A payment of |
type |
Payment timing. |
Details
For an annuity-immediate the first payment occurs at time 1/k; for an
annuity-due the first payment occurs at time 0. The present value is
obtained by delegating to presentValue with the appropriate
payment schedule rather than closed-form formulas, which keeps the output
consistent across other APV functions that reuse the same kernel.
Value
A numeric scalar: the present value of the annuity.
Note
The value returned derives from direct discounting of the cash flow
schedule, not from closed-form formulas such as
a^{(m)}_{\overline{n}|} = (1 - v^n)/i^{(m)}. When m > 1,
the per-period payment is 1/m.
Author(s)
Giorgio A. Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
accumulatedValue, increasingAnnuity,
decreasingAnnuity
Examples
# Present value of 1 per year, paid in arrears, for 10 years at 3%:
annuity(i = 0.03, n = 10)
# Same but paid monthly (1/12 at the end of each month):
annuity(i = 0.03, n = 10, k = 12)
# Perpetuity due:
annuity(i = 0.05, n = Inf, type = "due")
Life insurance with arithmetic-variation benefit
Description
Two term life insurances whose benefit varies arithmetically over the
coverage period, both with optional deferment m and k
fractional claim times (claims settled at the end of each sub-period):
-
IAxn — increasing arithmetic term insurance (benefit grows linearly with time);
-
DAxn — decreasing arithmetic term insurance (benefit declines linearly with time).
Usage
IAxn(
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
)
Arguments
actuarialtable |
A |
x |
Attained age at inception. |
n |
Coverage length in years. If missing, defaults to
|
i |
Annual effective interest rate. Defaults to
|
m |
Deferment (years). Default 0. |
k |
Fractional periods per year ( |
type |
Output type: |
power |
Power applied to the discounted payoff before expectation (default 1). Used to compute higher moments. |
Details
Let t_j = m + (j-1)/k for j=1,\dots,nk and
v = (1+i)^{-1}. With fractional claims at end-of-sub-period:
IAxn — increasing arithmetic term, benefit j/k at t_j:
\mathrm{IA}_{\overline{n}|}^{(k)} = \sum_{j=1}^{nk}
\frac{j}{k}\, v^{t_j + 1/k}\; {}_{t_j}p_x\; q_{x+t_j}^{(1/k)}.
DAxn — decreasing arithmetic term, benefit n - (j-1)/k at
t_j:
\mathrm{DA}_{\overline{n}|}^{(k)} = \sum_{j=1}^{nk}
\Big(n - \frac{j-1}{k}\Big)\, v^{t_j + 1/k}\;
{}_{t_j}p_x\; q_{x+t_j}^{(1/k)}.
Both expressions call pxt and
qxt(..., t = 1/k) just as Axn does for the
level benefit case.
Value
A numeric scalar: the APV, or one simulated realization when
type = "ST".
Fractional timing conventions
For insurance benefits in this package, fractional claims are placed at
the end of each sub-period (at t_j + 1/k). This matches the
implementation that multiplies survival to t_j by the fractional
death probability over the next sub-period:
v^{t_j + 1/k}\; {}_{t_j}p_x\; q_{x+t_j}^{(1/k)}.
Annuities, by contrast, carry a payment-timing flag ("immediate"
vs "due") that changes the evaluation times; insurance here always
uses end-of-sub-period timing.
References
Bowers, N. L., Gerber, H. U., Hickman, J. C., Jones, D. A., Nesbitt, C. J. (1997). Actuarial Mathematics, 2nd ed., SOA.
See Also
Axn (level benefit), AExn,
Exn, axn
Other life-contingency APVs:
endowment_trio
Examples
## Setup (legacy examples)
data(soaLt)
soa08Act <- with(soaLt,
new("actuarialtable", interest = 0.06, x = x, lx = Ix, name = "SOA2008"))
## IAxn: increasing arithmetic term, 10 years, age 25 (legacy)
IAxn(actuarialtable = soa08Act, x = 25, n = 10)
## More examples (k > 1 and deferment)
IAxn(actuarialtable = soa08Act, x = 40, n = 20, k = 12) # monthly
IAxn(actuarialtable = soa08Act, x = 40, n = 15, m = 5, k = 4) # deferred 5y, quarterly
## DAxn: decreasing arithmetic term, 10 years, age 25 (legacy)
DAxn(actuarialtable = soa08Act, x = 25, n = 10)
## More examples (k > 1 and deferment)
DAxn(actuarialtable = soa08Act, x = 45, n = 10, k = 2) # semiannual
DAxn(actuarialtable = soa08Act, x = 45, n = 12, m = 3, k = 12) # deferred 3y, monthly
Autoplot a life table
Description
Produces a ggplot2 representation of the number of survivors by age. The method is defined for 'lifetable'; S3 dispatch also makes it available for S4 subclasses such as 'actuarialtable'.
Usage
## S3 method for class 'lifetable'
autoplot(object, ...)
Arguments
object |
A 'lifetable' object, or an object inheriting from it. |
... |
Additional arguments passed to 'ggplot2::geom_line()'. |
Value
A 'ggplot2' plot object.
Examples
lt <- new("lifetable", x = 0:3, lx = c(100, 90, 50, 10))
ggplot2::autoplot(lt)
Functions to evaluate life insurance and annuities on two heads.
Description
These functions evaluates life insurances and annuities on two heads.
Usage
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")
Arguments
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 |
Details
Actuarial mathematics book formulas has been implemented.
Value
A numeric value returning APV of chosen insurance form.
Warning
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.
Note
Deprecated functions. Use Axyzn and axyzn instead.
Author(s)
Giorgio A. Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
## 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)
Build an mdt object from a matrix of independent (ASDT) rates
Description
buildMdtFromIndependentRates constructs a multiple-decrement table
(mdt) from a matrix of independent single-decrement rates
q'^{(j)}_x, the inverse of independentRatesFromMdt.
Usage
buildMdtFromIndependentRates(
x,
qx.primes,
radix = 1e+05,
name = "ASDT-built mdt"
)
Arguments
x |
Integer vector of ages (must be consecutive and start at 0 after
internal completion by |
qx.primes |
Numeric matrix of independent rates. Rows correspond to
ages in |
radix |
Radix (initial cohort size). Default 100 000. |
name |
Character string for the table name. Default |
Details
For each age the combined (absolute) rate of decrement j is obtained by
the UDD-based integration formula
q^{(j)}_x = q'^{(j)}_x \int_0^1 \prod_{i \ne j} \bigl(1 - s\,q'^{(i)}_x\bigr)\,ds,
which is the same formula used by qxt.fromQxprime for a single
age. The resulting absolute rates are multiplied by l^{(\tau)}_x to
obtain the decrement counts, and the survivorship column is computed
recursively from p^{(\tau)}_x = \prod_j (1 - q'^{(j)}_x).
Value
An mdt object.
See Also
independentRatesFromMdt for the reverse extraction,
qxt.fromQxprime for the single-age formula.
Examples
# Finan (2014) Example 67.4:
# Three decrements (death, disability, retirement) at ages 60-61.
qp <- matrix(c(0.010, 0.030, 0.100,
0.013, 0.050, 0.200), nrow = 2, byrow = TRUE,
dimnames = list(NULL, c("death", "disability", "retirement")))
mdt674 <- buildMdtFromIndependentRates(x = 60:61, qx.primes = qp,
radix = 1000, name = "Finan 67.4")
print(mdt674)
Italian Health Insurance Data
Description
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 Healthy to Disabled
Usage
de_angelis_di_falco
Format
a list containing eleven items (data.frames), and an mdt data object (HealthyMaleTable2013)
Source
Paolo De Angelis, Luigi di Falco (a cura di). Assicurazioni sulla salute: caratteristiche, modelli attuariali e basi tecniche
Decreasing annuity-certain
Description
Present value of a decreasing annuity with payment stream n, n-1,
\ldots, 1. Payments occur at times 1, 2, \ldots, n for an
annuity-immediate, or at 0, 1, \ldots, n-1 for an annuity-due.
Usage
decreasingAnnuity(i, n, type = "immediate")
Arguments
i |
Effective interest rate. |
n |
Number of periods. |
type |
Payment timing: |
Value
A numeric scalar: the present value of the decreasing cash flow.
Note
Internally calls presentValue.
Author(s)
Giorgio A. Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
annuity, increasingAnnuity,
DAxn
Examples
# Present value of 10, 9, 8, ..., 1 payable at the end of each year
# for 10 years at 3%:
decreasingAnnuity(i = 0.03, n = 10)
# Check against the direct sum:
sum((10:1) / (1 + 0.03)^(1:10))
Canada Mortality Rates for UP94 Series
Description
UP94 life tables underlying mortality rates
Usage
data(demoCanada)
Format
A data frame with 120 observations on the following 7 variables.
xage
up94MUP 94, males
up94FUP 94, females
up942015MUP 94 projected to 2015, males
up942015fUP 94 projected to 2015, females
up942020MUP 94 projected to 2020, males
up942020FUP 94 projected to 2020, females
Details
Mortality rates are provided.
Source
Courtesy of Andrew Botros
References
Courtesy of Andrew Botros
Examples
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)
China Mortality Rates for life table construction
Description
Seven yearly mortality rates for each age
Usage
data(demoChina)
Format
A data frame with 106 observations on the following 8 variables.
ageAttained age
CL1CL1 rates
CL2CL2 rates
CL3CL3 rates
CL4CL4 rates
CL5CL5 rates
CL6CL6 rates
CL90-93CL 90-93 rates
Details
See the source link for details.
Source
Society of Actuaries
References
Examples
data(demoChina)
tableChinaCL1<-probs2lifetable(probs=demoChina$CL1,radix=1000,type="qx",name="CHINA CL1")
French population life tables
Description
Illustrative life tables from French population.
Usage
data(demoFrance)
Format
A data frame with 113 observations on the following 5 variables.
ageAttained age
TH00_02Male 2000 life table
TF00_02Female 2000 life table
TD88_901988 1990 life table
TV88_901988 1990 life table
Details
These tables are real French population life tables. They regard 88 - 90 and 00 - 02 experience.
Source
Actuaris - Winter Associes
Examples
data(demoFrance)
head(demoFrance)
German population life tables
Description
Dataset containing mortality rates for German population, male and females.
Usage
data(demoGermany)
Format
A data frame with 113 observations on the following 5 variables.
xAttained age
qxMaleMale mortality rate
qxFemaleFemale mortality rate
Details
Sterbetafel DAV 1994
Source
Private communicatiom
Examples
data(demoGermany)
head(demoGermany)
Italian population life tables for males and females
Description
This dataset reports five pairs of Italian population life tables. These table can be used to create life table objects and actuarial tables object.
Usage
data(demoIta)
Format
A data frame with 121 observations on the following 9 variables.
Xa numeric vector, representing ages from 0 to
\omega.SIM02a numeric vector, 2002 cross section general population males life table
SIF02a numeric vector, 2002 cross section general population females life table
SIM00a numeric vector, 2000 cross section general population males life table
SIF00a numeric vector, 2000 cross section general population females life table
SIM92a numeric vector, 1992 cross section general population males life table
SIF92a numeric vector, 1992 cross section general population females life table
SIM81a numeric vector, 1981 cross sectional general population males life table
SIF81a numeric vector, 1981 cross sectional general population females life table
SIM61a numeric vector, 1961 cross sectional general population males life table
SIF61a numeric vector, 1961 cross sectional general population females life table
RG48Ma numeric vector, RG48 projected males life table
RG48Fa numeric vector, RG48 projected females life table
IPS55Ma numeric vector, IPS55 projected males life table
IPS55Fa numeric vector, IPS55 projected females life table
SIM71a numeric vector, 1971 cross sectional general population males life table
SIM51a numeric vector, 1951 cross sectional general population males life table
SIM31a numeric vector, 1931 cross sectional general population males life table
Details
These table contains the vectors of survival at the beginning of life years and are the building block of both
lifetable and actuarialtable classes.
Source
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.
References
ISTAT, IVASS, Ordine Nazionale Attuari
Examples
#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)
Japan Mortality Rates for life table construction
Description
Two yearly mortality rates for each age
Usage
data(demoJapan)
Format
A data frame with 110 observations on the following 3 variables.
JP8587MMale life table
JP8587FFemale life table
ageAttained age
Details
Downloaded in 2012 from Society of Actuaries (SOA) mortality table web site
Source
SOA mortality web site
Examples
data(demoJapan)
head(demoJapan)
UK life tables
Description
AM and AF one year mortality rate. Series of 1992
Usage
data(demoUk)
Format
A data frame with 74 observations on the following 3 variables:
AgeAnnuitant age
AM92One year mortality rate (males)
AF92One year mortality rate (females)
Details
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.
Source
Institute of Actuaries
References
Examples
data(demoUk)
head(demoUk)
United States Social Security life tables
Description
This data set contains period life tables for years 1990, 2000 and 2007. Both males and females life tables are reported.
Usage
demoUsa
Format
A data.frame containing people surviving at the beginning of "age" at 2007, 2000, and 1990
split by gender
Details
Reported age is truncated at the last age with lx>0.
Source
See https://www.ssa.gov/oact/NOTES/as120/LifeTables_Body.html
Examples
data(demoUsa)
head(demoUsa)
Duration and convexity of a series of cash flows
Description
duration returns the Macaulay (or modified) duration of a stream of
cash flows; convexity returns its convexity. Both are the classical
first- and second-order sensitivity measures of present value to a small
parallel shift of the interest rate.
Usage
duration(cashFlows, timeIds, i, k = 1, macaulay = TRUE)
convexity(cashFlows, timeIds, i, k = 1)
Arguments
cashFlows |
A numeric vector of cash-flow amounts. |
timeIds |
Numeric vector of payment times, same length as
|
i |
Nominal (APR) interest rate convertible |
k |
Compounding frequency for the nominal interest rate (periods per
year); default |
macaulay |
Logical. |
Details
With v = (1 + i/k)^{-1} and t'_j = t_j k, the Macaulay
duration is
D = \frac{\sum_j t_j\, CF_j\, v^{t'_j}}{\sum_j CF_j\, v^{t'_j}} ,
and the convexity is
C = \frac{\sum_j t_j (t_j + 1/k)\, CF_j\, v^{t'_j}}
{\sum_j CF_j\, v^{t'_j}} (1 + i/k)^{-2} .
Value
A numeric scalar: the (Macaulay or modified) duration, or the convexity, of the cash-flow series.
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
Examples
# Duration and convexity of a coupon bond (10 per year, 100 at maturity)
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)
Endowment, insurance, pure endowment and survival-annuity APVs
Description
Four classical single-life life-contingency actuarial present values, sharing a single documentation page because they take the same core arguments and are typically used together:
-
Exn — pure endowment: pays 1 at time
nif alive. -
Axn — term / whole-life insurance: pays 1 at the end of the subperiod of death within
nyears (or up to the limiting age ifnis missing), with fractional claim timing. -
AExn —
n-year endowment insurance:Axn + Exn. -
axn — survival annuity (immediate or due), deferred by
myears, withkpayments per year.
Usage
Exn(actuarialtable, x, n, i = actuarialtable@interest, type = "EV", power = 1)
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,
...
)
AExn(
actuarialtable,
x,
n,
i = actuarialtable@interest,
k = 1,
type = "EV",
power = 1
)
Arguments
actuarialtable |
A |
x |
Attained age at inception. |
n |
Contract length in years. If missing, |
i |
Annual effective interest rate. Defaults to
|
type |
Output type: |
power |
Power applied to the discounted payoff before expectation (default 1). Used to compute higher moments of the present value. |
m |
Deferment (years). Default 0. Vector accepted (for |
k |
Fractional periods per year ( |
payment |
Payment timing for annuities: |
... |
Extra arguments forwarded to |
Details
With v = (1 + i)^{-1}:
Exn: pure endowment, E_x^n = v^n \, {}_n p_x.
Axn: fractional-claim term/whole-life insurance,
A_{\overline{n}|}^{(k)} = \sum_{j=1}^{nk} v^{t_j + 1/k}\; {}_{t_j}p_x\; q_{x+t_j}^{(1/k)},
where t_j = m + (j-1)/k, computed via pxt(...) and
qxt(..., t = 1/k).
AExn: equals Axn(...) + Exn(...) with aligned arguments.
Vectorization: Exn and AExn accept vectors for
x, n and i; the arguments are recycled to a common
length and one value per element is returned.
axn — Survival annuity (immediate/due) with deferment m
and k fractional payments. For type = "EV" the annuity is
a_{\overline{n}|}^{(k)} = \sum_{j=1}^{nk} \frac{1}{k}\, v^{t_j}\, {}_{t_j}p_x,
with payment times t_j determined by payment and m.
Axn — Life insurance (term / whole life) with fractional claim
times, vectorized in x, n and m (recycled to a
common length); k must be scalar.
AExn — n-year endowment insurance, computed as
Axn(..., n, k) + Exn(..., n). Vectorised over x, n
and i; a zero-term endowment pays 1 immediately. When all
contracts share the same interest rate, Axn/Exn are
called once with the full vector of ages/terms; otherwise the loop runs
contract by contract (Axn takes a single scalar i).
Value
A numeric value for scalar inputs, or a numeric vector for
vectorized inputs: the APV when type = "EV", or one simulated
realization when type = "ST".
References
Bowers, N. L., Gerber, H. U., Hickman, J. C., Jones, D. A., Nesbitt, C. J. (1997). Actuarial Mathematics, 2nd ed., SOA.
See Also
Axn, AExn, axn,
Exn, rLifeContingencies
Other life-contingency APVs:
arithmetic_variation_insurances
Examples
## Common setup used in legacy docs
data(soaLt)
soa08Act <- with(soaLt,
new("actuarialtable", interest = 0.06, x = x, lx = Ix, name = "SOA2008"))
## Exn (pure endowment)
Exn(soa08Act, x = 30, n = 35)
## Axn (term / whole life insurance)
# 10-year term, semiannual claims:
Axn(soa08Act, x = 50, n = 10, k = 2)
# Whole life (n inferred), monthly:
Axn(soa08Act, x = 30, k = 12)
# Several ages and terms at once:
Exn(soa08Act, x = c(30, 40, 50), n = c(35, 25, 15))
## AExn = Axn + Exn (legacy book-check)
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)
AExn(soa08Act, x = c(35, 45), n = c(30, 20))
## axn (survival annuity, legacy example)
# Life-long annuity for age 65:
axn(soa08Act, x = 65)
## axn specific legacy examples
# Immediate (arrears) vs due (advance), quarterly, 15-year term deferred 5 years:
axn(soa08Act, x = 60, n = 15, m = 5, k = 4, payment = "immediate")
axn(soa08Act, x = 60, n = 15, m = 5, k = 4, payment = "due")
# Vectorization over x and n:
axn(soa08Act, x = c(60, 65), n = c(10, 20), k = 12, payment = "due")
Expected residual life.
Description
Expected future lifetime of a life aged x, either over the whole remaining
lifespan or over a temporary period of n years.
Usage
exn(object, x, n, type = "curtate", fxt = 0.5, axOmega = 1 - fxt)
Arguments
object |
A lifetable/actuarialtable object. |
x |
Attained age |
n |
Length (in years) of the period over which the expected lifetime is computed, i.e. a temporary expectation. Assumed omega - x + 1 (the whole remaining lifespan) whether missing. |
type |
Either |
fxt |
fraction of the year of age lived by those who die within the year, used by the
|
axOmega |
mean number of years lived in the last, open-ended age interval, used by the
|
Details
For type = "curtate" the function returns the (temporary) curtate expectation of life
e_{x:\overline{n}|} = \sum_{k=1}^{n} {}_k p_x ,
that is the expected number of complete future years lived by (x) within the next n years.
With n missing it is the curtate expectation of life e_x = E[K_x].
For type = "complete" the function returns the (temporary) complete expectation of life
\mathring{e}_{x:\overline{n}|} = \int_0^n {}_t p_x \, dt = \frac{{}_nL_x}{l_x} ,
evaluated under the uniform distribution of deaths (UDD) assumption within each year, i.e.
L_x = l_x - 0.5 d_x (see Lxt). With n missing it is
\mathring{e}_x = T_x / l_x = E[T_x].
Under UDD the two quantities are related by
\mathring{e}_{x:\overline{n}|} = e_{x:\overline{n}|} + 0.5\,(1 - {}_n p_x), which reduces to
\mathring{e}_x = e_x + 0.5 when n covers the whole remaining lifespan.
The last tabulated age \omega is treated as a closed interval: those alive at \omega
are assumed to die on average half a year later. Published tables that close the table with an open
interval (e.g. L_{\omega} = l_{\omega}/m_{\omega}, as in the NCHS tables) can therefore
show a slightly larger complete life expectancy.
Value
A numeric value representing the expected life span.
Author(s)
Giorgio Alfredo Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
#loads and show
data(soa08Act)
#curtate expectation of life at birth
exn(object=soa08Act, x=0)
#complete expectation of life at birth (curtate + 0.5 under UDD)
exn(object=soa08Act, x=0,type="complete")
#temporary 20-year expectations at age 50
exn(object=soa08Act, x=50, n=20)
exn(object=soa08Act, x=50, n=20, type="complete")
Decrement names of an mdt object
Description
Return the names of the decrement (cause-of-exit) columns stored in a
mdt multiple-decrement table, i.e. every column in
the underlying data frame other than the structural x (age) and
lx (survivors) columns.
Usage
getDecrements(object)
## S4 method for signature 'mdt'
getDecrements(object)
Arguments
object |
A |
Value
A character vector of decrement identifiers.
Author(s)
Giorgio Alfredo Spedicato
References
Finan, M.B. A Reading of the Theory of Life Contingency Models: A Preparation for Exam MLC/3L.
See Also
Examples
tableDecr <- data.frame(d1 = c(150, 160, 160), d2 = c(50, 75, 85))
newMdt <- new("mdt", name = "testMDT", table = tableDecr)
getDecrements(newMdt)
Functions to obtain the present value of a life contingency given the time to death
Description
It returns the present value of a life contingency, specified by its APV symbol, known the time to death ob the sibjects
Usage
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")
Arguments
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 |
Details
This function is a wrapper to the many internal functions that give the PV known the age of death.
Value
A vector or matrix of size number of rows of deathTimeXyz / deathTimeXy
Warning
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.
Note
Multiple life function needs to be tested
Author(s)
Spedicato Giorgio
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
rLifeContingenciesXyz, rLifeContingencies
Examples
#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)
Last attainable age of a life or multiple-decrement table
Description
Return the \omega value of a life table or multiple-decrement
table, i.e. the largest age tabulated in the object. Methods are
provided for lifetable (inherited by
actuarialtable) and mdt.
Usage
getOmega(object)
## S4 method for signature 'mdt'
getOmega(object)
## S4 method for signature 'lifetable'
getOmega(object)
Arguments
object |
A life-table-like object
( |
Value
A numeric scalar: the largest tabulated age.
Author(s)
Giorgio A. Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
# Assumes the SOA example life table to be loaded
data(soaLt)
soa08 <- with(soaLt, new("lifetable", x = x, lx = Ix, name = "SOA2008"))
getOmega(soa08)
Increasing annuity-certain
Description
Present value of an increasing annuity with payment stream 1, 2,
\ldots, n. Payments occur at times 1, 2, \ldots, n for an
annuity-immediate, or at 0, 1, \ldots, n-1 for an annuity-due.
Usage
increasingAnnuity(i, n, type = "immediate")
Arguments
i |
Effective interest rate. |
n |
Number of periods. |
type |
Payment timing: |
Value
A numeric scalar: the present value of the increasing cash flow.
Note
Internally calls presentValue.
Author(s)
Giorgio A. Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
annuity, decreasingAnnuity,
IAxn
Examples
# Present value of 1, 2, 3, ..., 10 payable at the end of each year
# for 10 years at 3%:
increasingAnnuity(i = 0.03, n = 10)
Extract the full Associated Single Decrement Table (ASDT) from an mdt object
Description
independentRatesFromMdt returns a matrix of ASDT independent rates
q'^{(j)}_x for every combination of age and decrement in the supplied
multiple-decrement table.
Usage
independentRatesFromMdt(object, x, t = 1)
Arguments
object |
An |
x |
Optional numeric vector of ages to include. Defaults to all ages
tabulated in |
t |
Period (default 1). |
Details
The independent rate for decrement j at age x is obtained under
the Uniform Distribution of Deaths (UDD) assumption as
q'^{(j)}_x = 1 - \bigl(1 - q^{(\tau)}_x\bigr)^{q^{(j)}_x / q^{(\tau)}_x},
which is the same formula used by qxt.prime.fromMdt for a single
age/decrement pair. independentRatesFromMdt is a convenience wrapper
that applies this extraction to all ages and all decrements at once, returning
the result as a tidy matrix.
Value
A numeric matrix with one row per age and one column per decrement. Row names are the ages, column names the decrement identifiers.
See Also
qxt.prime.fromMdt for a single age/decrement pair,
buildMdtFromIndependentRates for the inverse operation.
Examples
valdezDf <- data.frame(
x = 50:54,
lx = c(4832555, 4821937, 4810206, 4797185, 4782737),
heart = 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)
# ASDT matrix on the ages actually supplied
independentRatesFromMdt(valdezMdt, x = 50:54)
# Subset of ages
independentRatesFromMdt(valdezMdt, x = 50:52)
Convert between interest rate and force of interest
Description
These functions switch between an effective interest rate i and the
corresponding force of interest (intensity) \delta, using the
standard identities \delta = \log(1 + i) and i = e^{\delta} - 1.
Usage
intensity2Interest(intensity)
interest2Intensity(i)
Arguments
intensity |
Force of interest (continuous-time intensity). |
i |
interest rate |
Details
Simple financial-mathematics formulas:
i = e^{\delta} - 1, \qquad \delta = \log(1 + i).
Value
A numeric scalar.
Author(s)
Giorgio A. Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
Examples
# A force of interest of 0.02 corresponds to an effective rate of
intensity2Interest(intensity = 0.02)
#an interest rate equal to 0.02 corresponds to a force of interest of of
interest2Intensity(i=0.02)
Convert between interest and discount rates
Description
Switch between an effective interest rate i and the corresponding
effective discount rate d using the standard identity
d = \frac{i}{1 + i}, \qquad i = \frac{d}{1 - d}.
Usage
interest2Discount(i)
discount2Interest(d)
Arguments
i |
Effective interest rate. |
d |
Effective discount rate. |
Value
A numeric scalar.
Author(s)
Giorgio Alfredo Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
intensity2Interest, nominal2Real
Examples
# An effective interest rate of 4% corresponds to a discount rate of
interest2Discount(i = 0.04)
# The inverse direction:
discount2Interest(d = 0.04)
Class "lifetable"
Description
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 from the Class
Objects can be created by calls of the form new("lifetable", ...).
Two vectors are needed. The age vector and the population at risk vector.
Slots
x:Object of class
"numeric", representing the sequence 0,1,\ldots, \omegalx:Object of class
"numeric", representing the number of lives at the beginning of agex. 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
Methods
- coerce
signature(from = "lifetable", to = "data.frame"): method to create a data - frame from a lifetable object- coerce
signature(from = "lifetable", to = "markovchainList"): coerce method fromlifetabletomarkovchainList; available only when the optional markovchain package is installed- coerce
signature(from = "lifetable", to = "numeric"): brings to numeric- coerce
signature(from = "data.frame", to = "lifetable"): brings to life table- getOmega
signature(object = "lifetable"): returns the maximum attainable life age- plot
signature(x = "lifetable"): plot method- head
signature(x = "lifetable"): head methodsignature(x = "lifetable"): method to print the survival probability implied in the table- show
signature(object = "lifetable"): identical toplotmethod- summary
signature(object = "lifetable"): it returns summary information about the object
Warning
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.
Note
t may be missing in pxt, qxt, ext. It assumes value equal to 1 in such case.
Author(s)
Giorgio A. Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
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)
Class "mdt"
Description
A class to store multiple decrement tables
Objects from the Class
Objects can be created by calls of the form new("mdt", name, table,
bottomCompletionSurvival, ...). They store absolute decrements.
bottomCompletionSurvival (default 0.99) is the one-year
survival ratio used to synthetically back-fill ages below the lowest age
supplied in table; it does not affect rows for ages actually
supplied.
Slots
name:The name of the table
table:A data frame containing at least the number of decrements
Methods
- getDecrements
signature(object = "mdt"): return the name of decrements- getOmega
signature(object = "mdt"): maximum attainable age- initialize
signature(.Object = "mdt"): method to initialize the classsignature(x = "mdt"): tabulate absolute decrement rates- show
signature(object = "mdt"): show rates of decrement- coerce
signature(from = "mdt", to = "markovchainList"): coercing tomarkovchainListobjects; available only when the optional markovchain package is installed- coerce
signature(from = "mdt", to = "data.frame"): coercing todata.frame- summary
signature(object = "mdt"): it returns summary information about the object
Note
Currently only decrements storage of the class is defined.
Author(s)
Giorgio Alfredo Spedicato
References
Marcel Finan A Reading of the Theory of Life Contingency Models: A Preparation for Exam MLC/3L
See Also
Examples
#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)
Convert an mdt to long (time, status) format for survival analysis
Description
mdtToLong reshapes a multiple decrement table into an aggregated
long data set with one row per (exit time, cause) and a count
column, ready for competing-risks tools such as
survival::survfit(Surv(time, status) ~ 1, weights = count)
(Aalen-Johansen cumulative incidence) or for any analysis based on
survival::Surv.
Usage
mdtToLong(object, x, t, exitTime = c("end", "mid"), dropZero = TRUE)
Arguments
object |
an |
x |
entry age of the cohort (default: the lowest tabulated age, 0). |
t |
length of the follow-up in years (default: to the end of the
table). Lives still in the table at |
exitTime |
where in the year of age decrements are placed:
|
dropZero |
logical: drop rows with zero count (default |
Details
With exitTime = "end" the Aalen-Johansen estimate of the
cumulative incidence of cause j at time k computed on the
weighted long data coincides with qxt(object, x, k, decrement = j);
see the multiple decrement vignette.
Value
A data.frame with columns time (years since age
x), age (age at exit or censoring), status (a
factor whose first level, "censored", is followed by the
decrement names, as expected by survival::Surv for multi-state
data) and count (number of lives, possibly non-integer).
Examples
valdezDf <- data.frame(
x = 50:54,
lx = c(4832555, 4821937, 4810206, 4797185, 4782737),
heart = 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)
long <- mdtToLong(valdezMdt, x = 50, t = 5)
head(long)
if (requireNamespace("survival", quietly = TRUE)) {
fit <- survival::survfit(survival::Surv(time, status) ~ 1,
data = long, weights = count)
summary(fit, times = 1:5)$pstate
}
Median age at death of a life table
Description
S4 method for the median generic: the median age at
death implied by a lifetable, i.e. the age at which the survivorship
column l_x has fallen to half of its value at age (linear
interpolation on l_x).
Usage
## S4 method for signature 'lifetable'
median(x, na.rm = FALSE, ...)
Arguments
x |
A |
na.rm |
Unused, kept for compatibility with the generic. |
... |
Optional |
Value
The median age at death (a numeric value).
See Also
Examples
data(soa08Act)
median(soa08Act) # median age at death from birth
median(soa08Act, age = 65) # median age at death given survival to 65
Modal age at death of a life table
Description
Returns the age at which the number of deaths d_x is largest, i.e. the
Lexis modal age at death. (R's base mode returns the
storage type of an object and cannot be used for this, so a dedicated
function is provided.)
Usage
modalAge(object, startAge = NULL, interpolate = FALSE)
Arguments
object |
A |
startAge |
Optional lower age bound for the search. Use it (e.g.
|
interpolate |
Logical. If |
Details
The death counts are d_x = l_x - l_{x+1}; the artificial mass
at the last, open age interval (all remaining survivors) is excluded from
the search.
Value
The modal age at death (a numeric value).
See Also
Examples
data(soa08Act)
modalAge(soa08Act)
modalAge(soa08Act, startAge = 10, interpolate = TRUE)
Functions to deals with multiple life models
Description
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.
Usage
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)), ...)
Arguments
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 |
Details
These functions extends pxyt family to an arbitrary number of life contingencies.
Value
An estimate of survival / death probability or expected lifetime, or a matrix of ages.
Note
The procedure is experimental.
Author(s)
Giorgio Alfredo, Spedicato
References
Broverman, S.A., Mathematics of Investment and Credit (Fourth Edition), 2008, ACTEX Publications.
See Also
Examples
#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"))
Convert mortality rates to death probabilities
Description
Convert a vector of central mortality rates {}_1m_x into one-year
death probabilities {}_1q_x using the standard identity
{}_1q_x = \frac{{}_1m_x}{1 + (1 - a_x) {}_1m_x} ,
where a_x is the average fraction of year lived by those who die
between ages x and x+1. The default ax = 0.5
corresponds to the uniform distribution of deaths within the year.
Usage
mx2qx(mx, ax = 0.5)
Arguments
mx |
Numeric vector of central mortality rates. |
ax |
Average fraction of a year lived by those who die in it.
Default |
Value
A numeric vector of one-year death probabilities.
See Also
Examples
# Round-trip: qx2mx should invert mx2qx
qx2mx(mx2qx(0.2))
Central mortality rate
Description
Compute the central mortality rate {}_tm_x, i.e. deaths between
ages x and x+t divided by the person-years lived over that
window. It is the demographic rate counterpart of the (per-life)
probability of death qxt.
Usage
mxt(object, x, t)
Arguments
object |
A |
x |
Subject's attained age. |
t |
Length of the age interval over which the rate is evaluated (default 1). |
Details
{}_tm_x = \frac{{}_td_x}{{}_tL_x}.
Under the uniform distribution of deaths within each year of age,
{}_1m_x \approx {}_1q_x / (1 - 0.5 \cdot {}_1q_x).
Value
A numeric scalar: the central mortality rate between x
and x+t.
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
Examples
# Assumes the SOA example life table to be loaded
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)
Convert between effective, nominal, convertible and discount rates
Description
Convert between an effective annual rate (also called "real" rate here)
and the corresponding nominal rate convertible k-thly (also called
"convertible" rate), for either interest or discount. Convertible rates
are synonyms of nominal rates, so convertible2Effective and
effective2Convertible are thin wrappers of nominal2Real and
real2Nominal respectively, provided for naming consistency with
different textbook traditions.
Usage
nominal2Real(i, k = 1, type = "interest")
convertible2Effective(i, k = 1, type = "interest")
real2Nominal(i, k = 1, type = "interest")
effective2Convertible(i, k = 1, type = "interest")
Arguments
i |
The rate to be converted. |
k |
The original / target compounding frequency (periods per year). |
type |
|
Details
With type = "interest", nominal2Real(i, k) returns
(1 + i/k)^k - 1; with type = "nominal" it returns
1 - (1 - i/k)^k (the discount analogue). real2Nominal
inverts the respective expression.
Value
A numeric scalar.
Note
Convertible rates are synonyms of nominal rates.
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
Examples
# A nominal annual rate of 0.12 convertible monthly is equivalent to an
# effective annual rate of
nominal2Real(i = 0.12, k = 12, "interest")
Various demographic functions on a life table
Description
Lxt computes the person-years lived between ages x and
x + t; Tx returns the total person-years lived from age
x to the end of the table. They are the standard building blocks
of life-table analysis and feed into the complete expectation of life
(exn).
Usage
Lxt(object, x, t = 1, fxt = 0.5)
Tx(object, x, fxt = 0.5, axOmega = 1 - fxt)
Arguments
object |
a |
x |
age of the subject. |
t |
duration of the calculation (default 1). |
fxt |
fraction of the year of age lived by those who die within the
year, so that |
axOmega |
mean number of years lived in the last, open-ended age
interval by those still alive at the last tabulated age |
Details
With d_x = l_x - l_{x+1} and {}_tL_x = \sum_{k=0}^{t-1}
(l_{x+k} - fxt\, d_{x+k}), the function sums person-years over the
requested age window.
Tx is the total number of years lived from age x by the
life-table cohort, i.e. the sum of Lx from x to the last
tabulated age \omega.
Value
A numeric scalar.
Author(s)
Giorgio Alfredo Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
Examples
data(soaLt)
soa08Act <- with(soaLt, new("actuarialtable", interest = 0.06,
x = x, lx = Ix, name = "SOA2008"))
Lxt(soa08Act, 67, 10)
Tx(soa08Act, 67)
Plot a multiple decrement table
Description
S4 method for the plot generic: visualises the
decrement structure of an mdt object. Three views are available:
a stacked-area chart of death counts d^{(j)}_x (default), a stacked
bar chart, or a line chart of decrement probabilities
q^{(j)}_x = d^{(j)}_x / l^{(\tau)}_x.
Usage
## S4 method for signature 'mdt,missing'
plot(x, y, type = c("area", "bar", "probability"), ...)
Arguments
x |
An |
y |
Not used (kept for S4 generic compatibility). |
type |
Character: one of |
... |
Further arguments (currently unused). |
Value
A ggplot2 object (returned invisibly).
Examples
valdezDf <- data.frame(
x = 50:54,
lx = c(4832555, 4821937, 4810206, 4797185, 4782737),
heart = 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)
plot(valdezMdt)
plot(valdezMdt, type = "bar")
plot(valdezMdt, type = "probability")
Present value of a series of cash flows
Description
Evaluate the present value, or the actuarial present value when occurrence
probabilities are supplied, of a vector of cash flows discounted at a
given set of interest rates. This is the computational kernel on top of
which the actuarial APV machinery (Axn, axn,
Exn, IAxn, DAxn, ...) is built.
Usage
presentValue(cashFlows, timeIds, interestRates, probabilities, power = 1)
Arguments
cashFlows |
Numeric vector of cash flows, coherent in length with
|
timeIds |
Numeric vector of time points at which the |
interestRates |
Either a scalar effective interest rate or a numeric
vector of the same length as |
probabilities |
Optional numeric vector of occurrence probabilities,
one per element of |
power |
Numeric exponent applied to each discounted (and
probability-weighted) cash flow before summation. The default |
Details
With power = 1, the function implements
\mathrm{APV} = \sum_j (1 + i_j)^{-t_j}\, CF_j\, p_j,
where (t_j, CF_j, i_j, p_j) are the aligned entries of
timeIds, cashFlows, interestRates and
probabilities. A missing timeIds is interpreted as the
single time t = 1 (a warning is emitted so that silent
misalignments can be caught). The numerical work is delegated to the C++
kernel .presentValueC() for performance.
Value
A numeric scalar: the (actuarial) present value of the cash-flow series.
Note
This simple function is the kernel on which the package's actuarial and financial mathematics rest.
Author(s)
Giorgio A. Spedicato
References
Broverman, S.A. (2008). Mathematics of Investment and Credit (Fourth Edition), ACTEX Publications.
See Also
Examples
# Three $10 payments at the end of years 1-3, certainty, flat 3% rate:
cf <- c(10, 10, 10)
t <- c(1, 2, 3)
p <- c(1, 1, 1)
presentValue(cashFlows = cf, timeIds = t, interestRates = 0.03,
probabilities = p)
Life table from a vector of probabilities
Description
Create a lifetable object from a vector of one-year
survival or death probabilities, starting at age 0. Useful for feeding
mortality projections produced by other software (e.g. StMoMo)
into lifecontingencies.
Usage
probs2lifetable(probs, radix = 10000, type = "px", name = "ungiven")
Arguments
probs |
Numeric vector of one-year survival or death probabilities,
starting at age 0. Its last element must be |
radix |
Initial cohort size |
type |
Either |
name |
Character string stored in the |
Details
The limiting age \omega is the length of probs. The survival
factor at age k is probs[k] (if type = "px") or
1 - probs[k] (if type = "qx"), and l_x is built as the
cumulative product of these factors times radix.
Value
A lifetable object.
Author(s)
Giorgio A. Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
fakeSurvivalProbs <- seq(0.9, 0, by = -0.1)
newTable <- probs2lifetable(fakeSurvivalProbs, type = "px", name = "fake")
head(newTable)
tail(newTable)
Functions to evaluate survival, death probabilities and deaths.
Description
These functions evaluate raw survival and death probabilities between age x and x+t
Usage
dxt(object, x, t, decrement)
pxt(object, x, t, fractional = "linear", decrement)
qxt(object, x, t, fractional = "linear", decrement)
Arguments
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 |
Details
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.
dxt, pxt and qxt are S4 generics with methods for lifetable (and hence
actuarialtable) and mdt objects; other packages can add methods for new table classes.
For mdt objects with a decrement, {}_tq_x^{(j)} = {}_td_x^{(j)} / l_x^{(\tau)} and
pxt returns its complement 1 - {}_tq_x^{(j)}; ages must be tabulated integers and fractional
t is interpolated linearly (UDD) within the year.
Value
A numeric value representing requested probability.
Warning
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.
Note
Function dxt accepts also fractional value of t. Linear interpolation is used in such case. These functions are called by many other functions.
Author(s)
Giorgio A. Spedicato
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
#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" )
#MDT example (Valdez)
valdezMdt <- new("mdt", name = "ValdezExample", table = data.frame(
x = 50:54, lx = c(4832555, 4821937, 4810206, 4797185, 4782737),
heart = c(5168, 5363, 5618, 5929, 6277),
accidents = c(1157, 1206, 1443, 1679, 2152),
other = c(4293, 5162, 5960, 6840, 7631)))
qxt(valdezMdt, x = 50, t = 3, decrement = "heart")
qxt(valdezMdt, x = 50, t = 3, decrement = c("heart", "accidents"))
pxt(valdezMdt, x = 50, t = 3)
Functions to evaluate joint survival probabilities.
Description
These functions evaluate survival and death probabilities for two heads.
Usage
exyt(objectx, objecty, x, y, t, status = "joint")
pxyt(objectx, objecty, x, y, t, status = "joint")
qxyt(objectx, objecty, x, y, t, status = "joint")
Arguments
objectx |
|
objecty |
|
x |
Age of life X. |
y |
Age of life Y. |
t |
Time until survival has to be evaluated. |
status |
Either |
Value
A numeric value representing joint survival probability.
Warning
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.
Note
These functions are used to evaluate two or more life contingencies.
Author(s)
Giorgio A. Spedicato, Kevin J. Owens.
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
## Not run:
data(soa08Act)
pxyt(soa08Act, soa08Act, 65, 70,10)
pxyt(soa08Act, soa08Act, 65, 70,10, "last")
## End(Not run)
Quantiles of the age-at-death distribution of a life table
Description
S4 method for the quantile generic: quantiles of the
age at death implied by a lifetable, obtained by linear interpolation
on the survivorship column l_x.
Usage
## S4 method for signature 'lifetable'
quantile(x, probs = seq(0, 1, 0.25), age = min(x@x), names = TRUE, ...)
Arguments
x |
A |
... |
Further arguments (currently unused). |
probs |
Numeric vector of probabilities in |
age |
Youngest age to condition on (default: the youngest tabulated
age). Quantiles refer to the age at death given survival to |
names |
Logical: if |
Value
A numeric vector of age-at-death quantiles.
See Also
Examples
data(soa08Act)
quantile(soa08Act)
quantile(soa08Act, probs = c(0.1, 0.9), age = 65)
Convert death probabilities to mortality rates
Description
Inverse of mx2qx: convert one-year death probabilities
{}_1q_x into central mortality rates {}_1m_x,
{}_1m_x = \frac{{}_1q_x}{1 + a_x {}_1q_x - {}_1q_x} .
Usage
qx2mx(qx, ax = 0.5)
Arguments
qx |
Numeric vector of one-year death probabilities. |
ax |
Average fraction of a year lived by those who die in it.
Default |
Value
A numeric vector of central mortality rates.
See Also
Examples
data(soa08Act)
soa08qx <- as(soa08Act, "numeric")
soa08mx <- qx2mx(qx = soa08qx)
soa08qx2 <- mx2qx(soa08mx)
Return Associated single decrement from absolute rate of decrement
Description
Return Associated single decrement from absolute rate of decrement
Usage
qxt.prime.fromMdt(object, x, t = 1, decrement)
qxt.fromQxprime(qx.prime, other.qx.prime, t = 1)
Arguments
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 |
Value
a single value (AST)
Functions
-
qxt.fromQxprime(): Obtain decrement from single decrements
Examples
#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
Description
Function to generate samples from the life contingencies stochastic variables
Usage
rLifeContingencies(
n,
lifecontingency,
object,
x,
t,
i = object@interest,
m = 0,
k = 1,
parallel = FALSE,
nthreads = NULL,
payment = "advance"
)
rLifeContingenciesXyz(
n,
lifecontingency,
tablesList,
x,
t,
i,
m = 0,
k = 1,
status = "joint",
parallel = FALSE,
nthreads = NULL,
payment = "advance"
)
Arguments
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 |
Request multi-threaded (OpenMP) computation of the per-sample
payoff. This is opt-in twice: it has an effect only if
|
nthreads |
Number of OpenMP threads used when parallelisation is active.
Defaults to |
payment |
The Payment type, either |
tablesList |
A list of |
status |
Either |
Value
A numeric vector
Examples
## 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
Description
Function to generate random future lifetimes
Usage
rLife(n, object, x = 0, k = 1, type = "Tx")
rLifexyz(n, tablesList, x, k = 1, type = "Tx")
Arguments
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 |
Details
Under the uniform distribution of deaths assumption the complete future lifetime is the curtate one plus an independent uniform fraction of year, T_x=K_x+U with U\sim Unif(0,1), hence E[T_x]=E[K_x]+0.5. For type="Tx" the function returns K_x+0.5/k, i.e. a deterministic mid-period fraction, so only the expected value (not the full distribution) of T_x is reproduced.
Value
A numeric vector of n elements.
Note
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.
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
See Also
Examples
## 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
Description
Simulate from a multiple decrement table
Usage
rmdt(n = 1, object, x = 0, t = 1, t0 = "alive", include.t0 = TRUE)
Arguments
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)? |
Value
A matrix with n columns (the length of simulation) and either t (if initial status is not included) or t+1 rows.
Details
The function uses rmarkovchain from the optional markovchain package to simulate the chain: it stops with an informative error if that package is not installed.
Author(s)
Giorgio Alfredo Spedicato
See Also
rLifeContingenciesXyz,rLifeContingencies
Examples
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)
if (requireNamespace("markovchain", quietly = TRUE)) {
ciao<-rmdt(n=5,object = myMdt,x = 0,t = 4,include.t0=FALSE,t0="alive")
}
Society of Actuaries Illustrative Life Table object.
Description
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.
Usage
data(soa08)
Format
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"
Details
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.
Note
This table is based on US 1990 general population mortality.
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
Examples
data(soa08)
## maybe str(soa08) ; plot(soa08) ...
Society of Actuaries Illustrative Life Table with interest rate at 6
Description
An object of class actuarialtable built from the SOA illustrative life table. Interest rate is 6
Usage
data(soa08Act)
Format
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"
Details
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.
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
Examples
## Not run:
data(soa08Act)
## End(Not run)
Society of Actuaries life table
Description
This table has been used by the classical book Actuarial Mathematics and by the Society of Actuaries for US professional examinations.
Usage
data(soaLt)
Format
A data.frame with 111 obs on the following 2 variables:
xa numeric vector
Ixa numeric vector
Details
Early ages have been sourced elsewhere because they are missing from the original data; SOA did not provide population at risk data for certain spans of age (e.g. 1-5, 6-9, 11-14 and 16-19)
References
Actuarial Mathematics (Second Edition), 1997, by Bowers, N.L., Gerber, H.U., Hickman, J.C., Jones, D.A. and Nesbitt, C.J.
Examples
data(soaLt)
head(soaLt)
Variance and standard deviation of the future lifetime
Description
varxn and sdxn return the variance and the standard deviation
of the future lifetime of a life aged x, as the natural second-moment
companions of exn (which returns the mean).
Usage
varxn(object, x, n, type = "Kx")
sdxn(object, x, n, type = "Kx")
Arguments
object |
A |
x |
Attained age. Defaults to |
n |
Length (in years) of a temporary period. If missing, the whole remaining lifespan is used. |
type |
Either |
Details
For the curtate future lifetime the (temporary) variance is computed exactly from the life table as
\mathrm{Var}(\min(K_x, n)) = \sum_{k=1}^{n}(2k-1)\,{}_k p_x - \left(\sum_{k=1}^{n}{}_k p_x\right)^2 .
For the complete future lifetime the variance is returned only for the whole
remaining lifespan (n missing), using the uniform-distribution-of-deaths
relation \mathrm{Var}(T_x) = \mathrm{Var}(K_x) + 1/12 (because, under UDD,
T_x = K_x + U with U\sim\mathrm{Unif}(0,1) independent of K_x).
A temporary complete variance is not provided; use type = "Kx" for a
temporary period.
Value
A numeric value: the variance (varxn) or standard deviation
(sdxn) of the (temporary) future lifetime.
Author(s)
Giorgio Alfredo Spedicato
References
Dickson, D.C.M., Hardy, M.R., Waters, H.R. (2013), Actuarial Mathematics for Life Contingent Risks, 2nd ed., Cambridge University Press.
See Also
Examples
data(soa08Act)
# variance and sd of the curtate future lifetime at birth
varxn(soa08Act, x = 0)
sdxn(soa08Act, x = 0)
# complete future lifetime: Var(T) = Var(K) + 1/12
varxn(soa08Act, x = 65, type = "complete")
# temporary (20-year) curtate future lifetime at age 40
varxn(soa08Act, x = 40, n = 20)