Skip to content
Snippets Groups Projects
Commit eb84eb8a authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Split up the package into the ValuationTables and the LifeInsuranceContracts packages

parent 6044b00b
Branches
Tags
No related merge requests found
Showing
with 823 additions and 2591 deletions
Package: ValuationTables
Type: Package
Title: A framework for cohort life tables and general life insurance contracts
Version: 1.0
Date: 2016-04-01
Author: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: 2016-05-01
Title: A framework for cohort life tables and general life insurance contracts
Authors@R: c(person("Reinhold", "Kainhofer", role=c("aut", "cre"), email="reinhold@kainhofer.com"))
Author: Reinhold Kainhofer [aut, cre]
Maintainer: Reinhold Kainhofer <reinhold@kainhofer.com>
Description: Yet to be written
License: Not yet finally decided, probably GPL v3+ or LGPL or something similar
Depends:
ggplot2,
methods,
openxlsx,
scales,
utils
Suggests:
lifecontingencies
Description: This package provides classes to implement cohort life tables
for actuarial calculations. In particular, birthyear-dependent mortality
tables using a yearly trend to extrapolate from a base year are implemented,
as well as period life table, cohort life tables using an age shift, and
merged life tables.
License: GPL (>= 2)
RoxygenNote: 5.0.1
*.aux
*.dvi
*.log
*.synctex.gz
*.backup
*.kilepr
Bernkopf Max
Formelsammlung_Beispielrechnung.toc
Formelsammlung_Beispielrechnung.out
.gitignore
File deleted
This diff is collapsed.
exportPattern("^[[:alpha:]]+")
# Generated by roxygen2: do not edit by hand
export(getCohortTable)
export(plotValuationTables)
export(undampenTrend)
export(valuationTable)
export(valuationTable_ageShift)
export(valuationTable_improvementFactors)
export(valuationTable_joined)
export(valuationTable_mixed)
export(valuationTable_observed)
export(valuationTable_period)
exportClasses(valuationTable)
exportClasses(valuationTable_ageShift)
exportClasses(valuationTable_improvementFactors)
exportClasses(valuationTable_joined)
exportClasses(valuationTable_mixed)
exportClasses(valuationTable_observed)
exportClasses(valuationTable_period)
exportMethods(ageShift)
exportMethods(ages)
exportMethods(baseTable)
exportMethods(baseYear)
exportMethods(deathProbabilities)
exportMethods(getCohortTable)
exportMethods(getOmega)
exportMethods(getPeriodTable)
exportMethods(lifeTable)
exportMethods(periodDeathProbabilities)
exportMethods(undampenTrend)
import(ggplot2)
import(methods)
import(openxlsx)
library(abind);
mergeValues = function(starting, ending, t) {
rbind(starting[1:t,], ending[-1:-t,])
}
mergeValues3D = function(starting, ending, t) {
abind(starting[1:t,,], ending[-1:-t,,], along=1)
}
# Caution: px is not neccessarily 1-qx, because we might also have dread diseases so that px=1-qx-ix! However, the ix is not used for the survival present value
calculatePVSurvival = function(px=1-qx, qx=1-px, advance, arrears=c(0), ..., m=1, mCorrection = list(alpha=1, beta=0), v=1) {
# assuming advance and arrears have the same dimensions...
init = advance[1]*0;
l = max(length(qx), length(advance), length(arrears));
q = pad0(qx, l, value=1);
p = pad0(px, l, value=0);
advance = pad0(advance, l, value=init);
arrears = pad0(arrears, l, value=init);
# TODO: Make this work for matrices (i.e. currently advance and arrears are assumed to be one-dimensional vectors)
# TODO: Replace loop by better way (using Reduce?)
res = rep(0, l+1);
for (i in l:1) {
# coefficients for the payments (including corrections for payments during the year (using the alpha(m) and beta(m)):
advcoeff = mCorrection$alpha - mCorrection$beta*(1-p[i]*v);
arrcoeff = mCorrection$alpha - (mCorrection$beta + 1/m)*(1-p[i]*v);
# The actual recursion:
res[i] = advance[i]*advcoeff + arrears[i]*arrcoeff + v*p[i]*res[i+1];
}
res[1:l]
}
calculatePVGuaranteed = function(advance, arrears=c(0), ..., m=1, mCorrection = list(alpha=1, beta=0), v=1) {
# assuming advance and arrears have the same dimensions...
init = advance[1]*0;
l = max(length(advance), length(arrears));
advance = pad0(advance, l, value=init);
arrears = pad0(arrears, l, value=init);
# TODO: Make this work for matrices (i.e. currently advance and arrears are assumed to be one-dimensional vectors)
# TODO: Replace loop by better way (using Reduce?)
res = rep(0, l+1);
for (i in l:1) {
# coefficients for the payments (including corrections for payments during the year (using the alpha(m) and beta(m)):
advcoeff = mCorrection$alpha - mCorrection$beta*(1-v);
arrcoeff = mCorrection$alpha - (mCorrection$beta + 1/m)*(1-v);
# The actual recursion:
res[i] = advance[i]*advcoeff + arrears[i]*arrcoeff + v*res[i+1];
}
res[1:l]
}
# TODO: So far, we are assuming, the costs array has sufficient time steps and does not need to be padded!
calculatePVCosts = function(px=1-qx, qx=1-px, costs, ..., v=1) {
l = max(length(qx), dim(costs)[1]);
p = pad0(px, l, value=0);
costs = costs[1:l,,];
# Take the array structure from the cash flow array and initialize it with 0
res = costs*0;
prev = res[1,,]*0;
# Backward recursion starting from the last time:
for (i in l:1) {
# cat("values at iteration ", i, ": ", v, q[i], costs[i,,], prev);
res[i,,] = costs[i,,] + v*p[i]*prev;
prev=res[i,,];
}
res
}
calculatePVDeath = function(px, qx, benefits, ..., v=1) {
init = benefits[1]*0; # Preserve the possible array structure of the benefits -> vectorized calculations possible!
l = max(length(qx), length(benefits));
q = pad0(qx, l, value=1);
p = pad0(px, l, value=0);
benefits = pad0(benefits, l, value=init);
# TODO: Make this work for matrices (i.e. currently benefits are assumed to be one-dimensional vectors)
# TODO: Replace loop by better way (using Reduce?)
res = rep(init, l+1);
for (i in l:1) {
# Caution: p_x is not neccessarily 1-q_x, because we might also have dread diseases, so that px=1-qx-ix!
res[i] = v*q[i]*benefits[i] + v*p[i]*res[i+1];
}
res[1:l]
}
calculatePVDisease = function(px=1-qx-ix, qx=1-ix-px, ix=1-px-qx, benefits, ..., v=1) {
init = benefits[1]*0;
l = min(length(ix), length(qx), length(benefits));
qx = pad0(qx, l, value=1);
ix = pad0(ix, l, value=0);
px = pad0(px, l, value=0);
benefits = pad0(benefits, l, value=init);
# TODO: Make this work for matrices (i.e. currently benefits are assumed to be one-dimensional vectors)
# TODO: Replace loop by better way (using Reduce?)
res = rep(init, l+1);
for (i in l:1) {
res[i] = v*ix[i]*benefits[i] + v*px[i]*res[i+1];
}
res[1:l]
}
getSavingsPremium = function(reserves, v=1) {
pad0(reserves[-1], length(reserves))*v - reserves
}
correctionPaymentFrequency = function(m = 1, i = self$i, order = 0) {
# 0th-order approximation
alpha=1;
beta=0;
# negative orders mean that NO correction is done, e.g. because other means of
# correction are used like an explicit premium frequency loading on the premium.
if (order >=0 ) beta = beta + (m-1)/(2*m);
# For higher orders, simply add one term after the other!
if (order >= 1) beta = beta + (m^2-1)/(6*m^2)*i; # S-Versicherung: *(1-i/2)
# order 1.5 has a special term that should NOT be used for higher-order approximations!
if (order == 1.5) beta = beta + (1-m^2)/(12*m^2)*i^2;
if (order >= 2) {
beta = beta + (1-m^2)/(24*m^2)*i^2;
alpha = alpha + (m^2-1)/(12*m^2)*i^2;
}
# Exact value
if (order == Inf) {
d = i/(1+i);
im = m * ((1+i)^(1/m) - 1);
dm = im / (1+im/m);
alpha = d*i / (dm*im);
beta = (i-im) / (dm*im);
}
list(alpha=alpha, beta=beta);
}
pad0 = function(v, l, value=0) {
if (l>=length(v)) {
c(v, rep(value, l-length(v)))
} else {
v[0:l]
}
}
valueOrFunction = function(val, ...) {
if (is.function(val)) {
val(...)
} else {
val
}
}
library(R6)
library(openxlsx);
InsuranceContract = R6Class("InsuranceContract",
public = list(
tarif = NA,
#### Contract settings
params = list(
sumInsured = 1,
premiumWaiver = 0,
YOB = NA,
age = NA,
policyPeriod = Inf,
premiumPeriod = 1,
deferral = 0,
guaranteed = 0,
premiumPayments = PaymentTimeEnum("in advance"),
benefitPayments = PaymentTimeEnum("in advance"),
premiumFrequency = 1,
benefitFrequency = 1, # Only for annuities!
loadings = list(), # Allow overriding the tariff-defined loadings (see the InsuranceTariff class for all possible names)
surrenderPenalty = TRUE, # Set to FALSE after the surrender penalty has been applied once, e.g. on a premium waiver
alphaRefunded = FALSE # Alpha costs not yet refunded (in case of contract changes)
),
#### Caching values for this contract, initialized/calculated when the object is created
values = list(
basicData = NA,
transitionProbabilities = NA,
cashFlowsBasic = NA,
cashFlows = NA,
cashFlowsCosts = NA,
premiumSum = 0,
presentValues = NA,
presentValuesCosts = NA,
premiumCoefficients = NA,
premiums = NA,
absCashFlows = NA,
absPresentValues = NA,
reserves = NA,
premiumComposition = NA
),
#### Keeping the history of all contract changes during its lifetime
history = list(),
#### The code:
initialize = function(tarif, age, sumInsured = 1,
policyPeriod, premiumPeriod = policyPeriod, guaranteed = 0,
...,
loadings = list(),
premiumPayments = "in advance", benefitPayments = "in advance",
premiumFrequency = 1, benefitFrequency = 1,
deferral = 0, YOB = 1975) {
self$tarif = tarif;
self$params$age = age;
self$params$policyPeriod = policyPeriod;
if (missing(premiumPeriod) && !is.null(self$tarif$defaultPremiumPeriod)) {
self$params$premiumPeriod = self$tarif$defaultPremiumPeriod;
} else {
self$params$premiumPeriod = premiumPeriod;
}
self$params$sumInsured = sumInsured;
if (!missing(deferral)) self$params$deferral = deferral;
if (!missing(YOB)) self$params$YOB = YOB;
if (!missing(premiumPayments)) self$params$premiumPayments = premiumPayments;
if (!missing(benefitPayments)) self$params$benefitPayments = benefitPayments;
if (!missing(premiumFrequency)) self$params$premiumFrequency = premiumFrequency;
if (!missing(benefitFrequency)) self$params$benefitFrequency = benefitFrequency;
if (!missing(guaranteed)) self$params$guaranteed = guaranteed;
if (!missing(loadings)) self$params$loadings = loadings;
self$calculateContract();
},
addHistorySnapshot = function(time=0, comment="Initial contract values", type="Contract", params=self$params, values = self$values) {
self$history = rbind(self$history,
list(time=list("time"=time, "comment"=comment, "type"=type, "params"=params, "values"=values)));
},
calculateContract = function() {
self$values$transitionProbabilities = self$determineTransitionProbabilities();
self$values$cashFlowsBasic = self$determineCashFlowsBasic();
self$values$cashFlows = self$determineCashFlows();
self$values$premiumSum = self$determinePremiumSum();
self$values$cashFlowsCosts = self$determineCashFlowsCosts();
self$values$presentValues = self$calculatePresentValues();
self$values$presentValuesCosts = self$calculatePresentValuesCosts();
# the premiumCalculation function returns the premiums AND the cofficients,
# so we have to extract the coefficients and store them in a separate variable
res = self$calculatePremiums();
self$values$premiumCoefficients = res[["coefficients"]];
self$values$premiums = res[["premiums"]]
# Update the cash flows and present values with the values of the premium
pvAllBenefits = self$calculatePresentValuesBenefits()
self$values$presentValues = cbind(self$values$presentValues, pvAllBenefits)
self$values$absCashFlows = self$calculateAbsCashFlows();
self$values$absPresentValues = self$calculateAbsPresentValues();
self$values$reserves = self$calculateReserves();
self$values$basicData = self$getBasicDataTimeseries()
self$values$premiumComposition = self$premiumAnalysis();
self$addHistorySnapshot(0, "Initial contract values", type="Contract", params=self$params, values = self$values);
},
determineTransitionProbabilities = function(contractModification=NULL) {
do.call(self$tarif$getTransitionProbabilities, c(self$params, self$values, list(contractModification=contractModification)));
},
determineCashFlowsBasic = function(contractModification=NULL) {
do.call(self$tarif$getBasicCashFlows, self$params);
},
determineCashFlows = function(contractModification=NULL) {
do.call(self$tarif$getCashFlows, c(self$params, self$values, list(contractModification=contractModification)));
},
determinePremiumSum = function(contractModification=NULL) {
sum(self$values$cashFlows$premiums_advance + self$values$cashFlows$premiums_arrears);
},
determineCashFlowsCosts = function(contractModification=NULL) {
do.call(self$tarif$getCashFlowsCosts, c(self$params, self$values, list(contractModification=contractModification)));
},
calculatePresentValues = function(contractModification=NULL) {
do.call(self$tarif$presentValueCashFlows, c(self$params, self$values, list(contractModification=contractModification)));
},
calculatePresentValuesCosts = function(contractModification=NULL) {
do.call(self$tarif$presentValueCashFlowsCosts, c(self$params, self$values, list(contractModification=contractModification)));
},
calculatePremiums = function(contractModification=NULL) {
do.call(self$tarif$premiumCalculation, c(self$params, self$values, list(contractModification=contractModification)));
},
calculatePresentValuesBenefits = function(contractModification=NULL) {
do.call(self$tarif$presentValueBenefits, c(self$params, self$values, list(contractModification=contractModification)));
},
calculateAbsCashFlows = function(contractModification=NULL) {
do.call(self$tarif$getAbsCashFlows, c(self$params, self$values, list(contractModification=contractModification)));
},
calculateAbsPresentValues = function(contractModification=NULL) {
do.call(self$tarif$getAbsPresentValues, c(self$params, self$values, list(contractModification=contractModification)));
},
calculateReserves = function(contractModification=NULL) {
do.call(self$tarif$reserveCalculation, c(self$params, self$values, list(contractModification=contractModification)));
},
premiumAnalysis = function(contractModification=NULL) {
do.call(self$tarif$premiumDecomposition, c(self$params, self$values, list(contractModification=contractModification)));
},
getBasicDataTimeseries = function(contractModification=NULL) {
do.call(self$tarif$getBasicDataTimeseries, c(self$params, self$values, list(contractModification=contractModification)));
},
# Premium Waiver: Stop all premium payments at time t
# the SumInsured is determined from the available
premiumWaiver = function (t) {
newSumInsured = self$values$reserves[[toString(t), "PremiumFreeSumInsured"]];
self$params$premiumWaiver = TRUE;
self$params$surrenderPenalty = FALSE; # Surrencer penalty has already been applied, don't apply a second time
self$params$alphaRefunded = TRUE; # Alpha cost (if applicable) have already been refunded partially, don't refund again
self$params$sumInsured = newSumInsured;
self$values$cashFlowsBasic = mergeValues(starting=self$values$cashFlowsBasic, ending=self$determineCashFlowsBasic(t), t=t);
self$values$cashFlows = mergeValues(starting=self$values$cashFlows, ending=self$determineCashFlows(t), t=t);
# Premium sum is not affected by premium waivers, i.e. everything depending on the premium sum uses the original premium sum!
# self$values$premiumSum = self$determinePremiumSum();
self$values$cashFlowsCosts = mergeValues3D(starting=self$values$cashFlowsCosts, ending=self$determineCashFlowsCosts(t), t=t);
pv = self$calculatePresentValues(t);
pvc = self$calculatePresentValuesCosts(t);
self$values$presentValuesCosts = mergeValues3D(starting=self$values$presentValuesCosts, ending=pvc, t=t);
# TODO:
# the premiumCalculation function returns the premiums AND the cofficients,
# so we have to extract the coefficients and store them in a separate variable
# res = self$calculatePremiums(t);
# self$values$premiumCoefficients = mergeValues(starting=self$values$premiumCoefficients, ending=res[["coefficients"]], t=t);
# self$values$premiums = mergeValues(starting= = res[["premiums"]]
# Update the cash flows and present values with the values of the premium
pvAllBenefits = self$calculatePresentValuesBenefits()
self$values$presentValues = mergeValues(starting=self$values$presentValues, ending=cbind(pv, pvAllBenefits), t=t);
self$values$absCashFlows = mergeValues(starting=self$values$absCashFlows, ending=self$calculateAbsCashFlows(t), t=t);
self$values$absPresentValues = mergeValues(starting=self$values$absPresentValues, ending=self$calculateAbsPresentValues(t), t=t);
self$values$reserves = mergeValues(starting=self$values$reserves, ending=self$calculateReserves(t), t=t);
self$values$basicData = mergeValues(starting=self$values$basicData, ending=self$getBasicDataTimeseries(t), t=t);
self$values$premiumComposition = mergeValues(starting=self$values$premiumComposition, ending=self$premiumAnalysis(t), t=t);
self$addHistorySnapshot(time=t, comment=sprintf("Premium waiver at time %d", t), type="PremiumWaiver", params=self$params, values=self$values);
},
dummy=NULL
)
);
# InsuranceContract$debug("premiumWaiver")
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
makeQxDataFrame = function(..., YOB=1972, Period=NA) {
data=list(...);
names(data) = lapply(data, function(t) t@name);
if (missing(Period)) {
cat("Year of birth: ", YOB, "\n");
data = lapply(data, function(t) cbind(x=ages(t), y=deathProbabilities(t, YOB=YOB)))
} else {
cat("Period: ", Period,"\n");
data = lapply(data, function(t) cbind(x=ages(t), y=periodDeathProbabilities(t, Period=Period)))
}
list.names = names(data)
lns <- sapply(data, nrow)
data <- as.data.frame(do.call("rbind", data))
data$group <- rep(list.names, lns)
data
}
#' Plot multiple valuation tables (life tables) in one plot
#'
#' \code{plotValuationTables} prints multiple life tables (objects of child classes of \code{valuationTable}) in one log-linear plot, with a legend showing the names of the tables.
#'
#' @param data First life table to be plotted. Either a \code{data.frame} generated by \code{makeQxDataFrame} or a \code{valuationTable} object
#' @param ... Additional life tables to be plotted (if \code{data} is a \code{valuationTable} object)
#' @param title The plot title
#' @param legend.position The position of the legend (default is \code{c(0.9,0.1)})
#' @param legend.key.width The keywith of the lines in the legend (default is \code{unit(25,"mm")})
#'
#' @export
plotValuationTables = function(data, ..., title = "", legend.position=c(0.9,0.1), legend.key.width = unit(25, "mm")) {
if (!is.data.frame(data)) {
data = makeQxDataFrame(data, ...);
}
pl = ggplot(data, aes(x = x, y = y, colour = data$group)) +
theme_bw() +
theme(
plot.title = element_text(size=18, face="bold"),
legend.title = element_text(size=14, face="bold.italic"),
# legend in bottom right corner of the plot
legend.justification=c(1,0), legend.position=legend.position,
# No box around legend entries
legend.key = element_blank(),
legend.key.width = legend.key.width,
legend.background = element_rect(colour="gray50", linetype="solid")
) +
geom_line() +
scale_y_log10(
name=expression(paste("Sterbewahrscheinlichkeit ", q[x])),
breaks = scales::trans_breaks('log10', function(x) 10^x),
labels = scales::trans_format('log10', scales::math_format(10^.x))
#minor_breaks = log(c(sapply(x, function(x) seq(0, x, x/10))), 10)
) +
scale_x_continuous(
name="Alter",
#breaks = function (limits) scales::trans_breaks('', function(x) 10^x),
breaks = function (limits) seq(max(min(limits),0),max(limits),5),
minor_breaks = function (limits) seq(max(round(min(limits)),0),round(max(limits)),1),
#labels = scales::trans_format('log10', scales::math_format(10^.x))
) +
annotation_logticks(sides="lr") +
xlab("Alter") + labs(colour="Sterbetafel");
if (title != "") {
pl = pl + ggtitle(title);
}
pl
}
#
# plotValuationTables(mort.AT.census.1869.male, mort.AT.census.1869.female, mort.AT.census.2011.male, mort.AT.census.2011.female, AVOe2005R.male, AVOe2005R.female, YOB=1972,title="Vergleich österreichische Sterbetafeln, YOB=1972 (bei Generationentafeln)")
#
# plotValuationTables(mort.AT.census.2001.male, AVOe2005R.male, YOB=1972, title="Vergleich österreichische Sterbetafeln")
# plotValuationTables(getCohortTable(AVOe2005R.male, YOB=1972), getCohortTable(AVOe2005R.male, YOB=2016), title="Vergleich österreichische Sterbetafeln")
......@@ -16,4 +16,6 @@ AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch
PackageRoxygenize: rd,collate,namespace
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ValuationTables.R
\docType{package}
\name{ValuationTables-package}
\alias{ValuationTables-package}
\alias{ValuationTables}
\docType{package}
\title{
What the package does (short line)
~~ package title ~~
}
\alias{ValuationTables-package}
\title{Provide life table classes for life insurance purposes}
\description{
More about what it does (maybe more than one line)
~~ A concise (1-5 lines) description of the package ~~
}
\details{
\tabular{ll}{
Package: \tab ValuationTables\cr
Type: \tab Package\cr
Version: \tab 1.0\cr
Date: \tab 2013-05-03\cr
License: \tab What license is it under?\cr
Provide life table classes for life insurance purposes
}
~~ An overview of how to use the package, including the most important functions ~~
}
\author{
Who wrote it
Maintainer: Who to complain to <yourfault@somewhere.net>
~~ The author and/or maintainer of the package ~~
}
\references{
~~ Literature or other references for background information ~~
}
~~ Optionally other standard keywords, one per line, from file KEYWORDS in the R documentation directory ~~
\keyword{ package }
\seealso{
~~ Optional links to other man pages, e.g. ~~
~~ \code{\link[<pkg>:<pkg>-package]{<pkg>}} ~~
}
\examples{
~~ simple examples of the most important functions ~~
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plotValuationTables.R
\name{plotValuationTables}
\alias{plotValuationTables}
\title{Plot multiple valuation tables (life tables) in one plot}
\usage{
plotValuationTables(data, ..., title = "", legend.position = c(0.9, 0.1),
legend.key.width = unit(25, "mm"))
}
\arguments{
\item{data}{First life table to be plotted. Either a \code{data.frame} generated by \code{makeQxDataFrame} or a \code{valuationTable} object}
\item{...}{Additional life tables to be plotted (if \code{data} is a \code{valuationTable} object)}
\item{title}{The plot title}
\item{legend.position}{The position of the legend (default is \code{c(0.9,0.1)})}
\item{legend.key.width}{The keywith of the lines in the legend (default is \code{unit(25,"mm")})}
}
\description{
\code{plotValuationTables} prints multiple life tables (objects of child classes of \code{valuationTable}) in one log-linear plot, with a legend showing the names of the tables.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ValuationTables.R
\docType{class}
\name{valuationTable-class}
\alias{baseTable,valuationTable-method}
\alias{baseYear,valuationTable-method}
\alias{getCohortTable,valuationTable-method}
\alias{getPeriodTable,valuationTable-method}
\alias{lifeTable,valuationTable-method}
\alias{valuationTable}
\alias{valuationTable-class}
\title{Class valuationTable}
\usage{
getOmega(object)
ages(object, ...)
deathProbabilities(object, ..., YOB = 1975)
periodDeathProbabilities(object, ...)
lifeTable(object, ...)
\S4method{lifeTable}{valuationTable}(object, ...)
baseYear(object, ...)
\S4method{baseYear}{valuationTable}(object, ...)
baseTable(object, ...)
\S4method{baseTable}{valuationTable}(object, ...)
getPeriodTable(object, Period, ...)
\S4method{getPeriodTable}{valuationTable}(object, Period, ...)
getCohortTable(object, YOB, ...)
\S4method{getCohortTable}{valuationTable}(object, YOB, ...)
}
\arguments{
\item{...}{Parameters to be handed to the \code{deathProbabilities} method of the life table}
\item{YOB}{The birth year for which the death probabilities should be calculated}
\item{Period}{The observation year for which the period death probabilities should be determined}
\item{...}{Parameters to be handed to the \code{deathProbabilities} method of the life table}
\item{Period}{The observation year, for which the death probabilities should be determined}
\item{Period}{The observation year, for which the death probabilities should be determined}
\item{YOB}{The birth year for which the life table should be calculated}
\item{YOB}{The birth year for which the life table should be calculated}
}
\description{
Class \code{valuationTable} is the (virtual) base class for all valuation
tables. It contains the name and some general values applying to all
types of tables, but does not contain any data itself. Use a child class
to create actual valuation tables.
Return the maximum age of the life table
Return the defined ages of the life table
Return the (cohort) death probabilities of the life table given the birth year (if needed)
Return the (period) death probabilities of the life table for a given observation year
Return the lifetable object (package lifecontingencies) for the cohort life table
Return the lifetable object (package lifecontingencies) for the cohort life table
Return the base year of the life table
Return the base year of the life table
Return the base table of the life table
Return the base table of the life table
Return the period life table as a \code{valuationTable_period} object
Return the period life table as a \code{valuationTable_period} object
Return the cohort life table as a \code{valuationTable_period} object
Return the cohort life table as a \code{valuationTable_period} object
}
\section{Slots}{
\describe{
\item{\code{name}}{The human-readable name of the valuation table}
\item{\code{baseYear}}{The base year of the valuation table (e.g. for tables with trend projection)}
\item{\code{modification}}{A function that will be called with the final death probabilities
to give the user a way to modify the final probabilities}
\item{\code{loading}}{Additional security loading on the resulting table (single numeric
value, e.g. 0.05 adds 5% security margin to the probabilities)}
}}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ValuationTables.R
\docType{class}
\name{valuationTable_ageShift-class}
\alias{ageShift,valuationTable_ageShift-method}
\alias{deathProbabilities,valuationTable_ageShift-method}
\alias{periodDeathProbabilities,valuationTable_ageShift-method}
\alias{valuationTable_ageShift}
\alias{valuationTable_ageShift-class}
\title{A cohort life table, obtained by age-shifting from a given base table (death probabilities}
\usage{
ageShift(object, YOB = 1975, ...)
\S4method{ageShift}{valuationTable_ageShift}(object, YOB = 1975, ...)
\S4method{deathProbabilities}{valuationTable_ageShift}(object, ...,
YOB = 1975)
\S4method{periodDeathProbabilities}{valuationTable_ageShift}(object, ...,
Period = 1975)
}
\arguments{
\item{YOB}{The birth year for which the age shift should be determined.}
\item{Period}{The observation year for which the period death probabilities should be determined}
\item{YOB}{The birth year for which the age shift should be determined.}
\item{YOB}{The birth year for which the death probabilities should be calculated}
}
\description{
A cohort life table, obtained by age-shifting from a given base table (death probabilities
Return the age shift of the age-shifted life table given the birth year
Return the age shift of the age-shifted life table given the birth year
Return the (cohort) death probabilities of the life table given the birth year (if needed)
Return the (period) death probabilities of the life table for a given observation year
}
\section{Slots}{
\describe{
\item{\code{ageShifts}}{A \code{data.frame} with columns \code{YOB} and \code{shifts} giving the age shifts for each birth year}
}}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ValuationTables.R
\docType{class}
\name{valuationTable_improvementFactors-class}
\alias{deathProbabilities,valuationTable_improvementFactors-method}
\alias{periodDeathProbabilities,valuationTable_improvementFactors-method}
\alias{valuationTable_improvementFactors}
\alias{valuationTable_improvementFactors-class}
\title{A cohort life table, obtained by an improvment factor projection
from a given base table (PODs for a given observation year).}
\usage{
\S4method{deathProbabilities}{valuationTable_improvementFactors}(object, ...,
YOB = 1975)
\S4method{periodDeathProbabilities}{valuationTable_improvementFactors}(object,
..., Period = 1975)
}
\arguments{
\item{YOB}{The birth year for which the death probabilities should be calculated}
\item{Period}{The observation year for which the period death probabilities should be determined}
}
\description{
A cohort life table, obtained by an improvment factor projection
from a given base table (PODs for a given observation year).
Return the (cohort) death probabilities of the life table given the birth year (if needed)
Return the (period) death probabilities of the life table for a given observation year
}
\section{Slots}{
\describe{
\item{\code{baseYear}}{The base year for the improvements (\code{baseTable} describes the death probabilities in this year)}
\item{\code{improvement}}{Yearly improvement factors per age}
}}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ValuationTables.R
\docType{class}
\name{valuationTable_joined-class}
\alias{ages,valuationTable_joined-method}
\alias{getOmega,valuationTable_joined-method}
\alias{valuationTable_joined}
\alias{valuationTable_joined-class}
\title{A cohort life table obtained by joining two cohort life tables, each of which
applies only to certain observation years (e.g. for the past use the observed
PODs, and project them to the future with the trend projection)}
\usage{
\S4method{getOmega}{valuationTable_joined}(object)
\S4method{ages}{valuationTable_joined}(object, ...)
}
\description{
A cohort life table obtained by joining two cohort life tables, each of which
applies only to certain observation years (e.g. for the past use the observed
PODs, and project them to the future with the trend projection)
Return the maximum age of the joined life table
Return the defined ages of the life table
}
\section{Slots}{
\describe{
\item{\code{table1}}{The first \code{valuationTable}, valid for years given in \code{yearRange1}}
\item{\code{yearRange1}}{The years, for which \code{table1} describes the death probabilities}
\item{\code{table2}}{The second \code{valuationTable}, valid for years given in \code{yearRange2}}
\item{\code{yearRange2}}{The years, for which \code{table2} describes the death probabilities}
}}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ValuationTables.R
\docType{class}
\name{valuationTable_mixed-class}
\alias{ages,valuationTable_mixed-method}
\alias{baseYear,valuationTable_mixed-method}
\alias{deathProbabilities,valuationTable_mixed-method}
\alias{getOmega,valuationTable_mixed-method}
\alias{periodDeathProbabilities,valuationTable_mixed-method}
\alias{valuationTable_mixed}
\alias{valuationTable_mixed-class}
\title{A cohort life table obtained by mixing two life tables with the given weights}
\usage{
\S4method{getOmega}{valuationTable_mixed}(object)
\S4method{ages}{valuationTable_mixed}(object, ...)
\S4method{deathProbabilities}{valuationTable_mixed}(object, ..., YOB = 1975)
\S4method{periodDeathProbabilities}{valuationTable_mixed}(object, ...,
Period = 1975)
\S4method{baseYear}{valuationTable_mixed}(object, ...)
}
\arguments{
\item{YOB}{The birth year for which the death probabilities should be calculated}
\item{Period}{The observation year for which the period death probabilities should be determined}
}
\description{
A cohort life table obtained by mixing two life tables with the given weights
Return the maximum age of the mixed life table
Return the defined ages of the life table
Return the (cohort) death probabilities of the life table given the birth year (if needed)
Return the (period) death probabilities of the life table for a given observation year
Return the base year of the life table
}
\section{Slots}{
\describe{
\item{\code{table1}}{The first \code{valuationTable}}
\item{\code{table2}}{The second \code{valuationTable}}
\item{\code{weight1}}{The weight of the first valuation table}
\item{\code{weight2}}{The weight of the second valuation table}
\item{\code{loading}}{Additional security loading}
}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment