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

Add class to handle pension tables (first attempt, not finished yet)

parent 872a5d32
Branches
Tags
No related merge requests found
Showing
with 108 additions and 28 deletions
...@@ -22,8 +22,8 @@ Description: Classes to implement and plot cohort life tables ...@@ -22,8 +22,8 @@ Description: Classes to implement and plot cohort life tables
as well as period life table, cohort life tables using an age shift, and as well as period life table, cohort life tables using an age shift, and
merged life tables. merged life tables.
License: GPL (>= 2) License: GPL (>= 2)
RoxygenNote: 5.0.1 RoxygenNote: 6.0.1
Collate: Collate:
'mortalityTable.R' 'mortalityTable.R'
'mortalityTable.period.R' 'mortalityTable.period.R'
'mortalityTable.ageShift.R' 'mortalityTable.ageShift.R'
...@@ -47,6 +47,7 @@ Collate: ...@@ -47,6 +47,7 @@ Collate:
'mortalityTable.jointLives.R' 'mortalityTable.jointLives.R'
'mortalityTables.list.R' 'mortalityTables.list.R'
'mortalityTables.load.R' 'mortalityTables.load.R'
'pensionTable.R'
'plot.mortalityTable.R' 'plot.mortalityTable.R'
'plotMortalityTableComparisons.R' 'plotMortalityTableComparisons.R'
'plotMortalityTables.R' 'plotMortalityTables.R'
......
...@@ -16,6 +16,7 @@ export(mortalityTable.period) ...@@ -16,6 +16,7 @@ export(mortalityTable.period)
export(mortalityTable.trendProjection) export(mortalityTable.trendProjection)
export(mortalityTables.list) export(mortalityTables.list)
export(mortalityTables.load) export(mortalityTables.load)
export(pensionTable)
export(plotMortalityTableComparisons) export(plotMortalityTableComparisons)
export(plotMortalityTables) export(plotMortalityTables)
exportClasses(mortalityTable) exportClasses(mortalityTable)
...@@ -27,6 +28,7 @@ exportClasses(mortalityTable.mixed) ...@@ -27,6 +28,7 @@ exportClasses(mortalityTable.mixed)
exportClasses(mortalityTable.observed) exportClasses(mortalityTable.observed)
exportClasses(mortalityTable.period) exportClasses(mortalityTable.period)
exportClasses(mortalityTable.trendProjection) exportClasses(mortalityTable.trendProjection)
exportClasses(pensionTable)
exportMethods(ageShift) exportMethods(ageShift)
exportMethods(ages) exportMethods(ages)
exportMethods(baseTable) exportMethods(baseTable)
......
#' @include mortalityTable.R
NULL
#' Class pensionTable
#'
#' Class \code{pensionTable} is the (virtual) base class for all pensions
#' tables. It contains the name and some general values applying to all
#' types of tables. In particular, it holds individual tables for each of the
#' transition probabilities. Possible states are:
#' * active: healty, no pension, typically paying some kin of premium
#' * incapacity: disablity pension, in most cases permanent, not working, early pension
#' * retirement: old age pension, usually starting with a fixed age
#' * dead
#' * Widow/widower pension
#'
#' Correspondingly, the following transition probabilities can be given:
#' * qxaa: death probability of actives (active -> dead)
#' * ix: invalidity probability (active -> incapacity)
#' * qix: death probability of invalid (invalid -> dead)
#' * rx: reactivation probability (incapacity -> active)
#' * apx: retirement probability (active -> retirement), typically 1 for a fixed age
#' * apx: retirement probability of invalids (invalid -> retirement), typically 0 or 1 for a fixed age
#' * qpx: death probability of retired (retired -> dead)
#' * hx: probability of a widow at moment of death (dead -> widow), y(x) age differene
#' * qxw: death probability of widows/widowers
#' * qgx: death probability of total group (irrespective of state)
#'
#' @slot qx Death probability table of actives (derived from mortalityTable)
#' @slot ix Invalidity probability of actives (derived from mortalityTable)
#' @slot qxi Death probability table of invalids (derived from mortalityTable)
#' @slot rx Reactivation probability of invalids (derived from mortalityTable)
#' @slot apx Retirement probability of actives (derived from mortalityTable)
#' @slot apix Retirement probability of invalids (derived from mortalityTable)
#' @slot qpx Death probability of old age pensioners (derived from mortalityTable)
#' @slot hx Probability of a widow at the moment of death (derived from mortalityTable)
#' @slot qwy Death probability of widow(er)s (derived from mortality Table)
#' @slot yx Age difference of the widow to the deceased
#' @slot qgx Death probability of whole group (derived from mortalityTable), irrespective of state
#'
#' @export pensionTable
#' @exportClass pensionTable
pensionTable = setClass(
"pensionTable",
slots = list(
qx = "mortalityTable",
ix = "mortalityTable",
qix = "mortalityTable",
rx = "mortalityTable",
apx = "mortalityTable",
apix = "mortalityTable",
qpx = "mortalityTable",
hx = "mortalityTable",
qwy = "mortalityTable",
yx = "mortalityTable",
qgx = "mortalityTable"
),
contains = "mortalityTable"
)
#' @describeIn baseTable Return the base table of the joint lives mortality table (returns the base table of the first table used for joint lives)
setMethod("transitionProbabilities", "pensionTable",
function(object, ..., YOB = 1982) {
x = ages(object@qx);
q = deathProbabilities(object@qx, ..., YOB = YOB);
i = deathProbabilities(object@ix, ..., YOB = YOB);
data.frame(x, q, i)
})
...@@ -8,4 +8,14 @@ ...@@ -8,4 +8,14 @@
\description{ \description{
Provide life table classes for life insurance purposes Provide life table classes for life insurance purposes
} }
\seealso{
Useful links:
\itemize{
\item \url{https://gitlab.open-tools.net/R/r-mortality-tables}
}
}
\author{
\strong{Maintainer}: Reinhold Kainhofer \email{reinhold@kainhofer.com}
}
...@@ -25,6 +25,7 @@ Return the age shift of the age-shifted life table given the birth year ...@@ -25,6 +25,7 @@ Return the age shift of the age-shifted life table given the birth year
\item \code{mortalityTable.ageShift}: Return the age shift of the age-shifted life table \item \code{mortalityTable.ageShift}: Return the age shift of the age-shifted life table
given the birth year given the birth year
}} }}
\examples{ \examples{
mortalityTables.load("Austria_Annuities") mortalityTables.load("Austria_Annuities")
ageShift(AVOe2005R.male.av, YOB=1910) ageShift(AVOe2005R.male.av, YOB=1910)
...@@ -32,4 +33,3 @@ ageShift(AVOe2005R.male.av, YOB=1955) ...@@ -32,4 +33,3 @@ ageShift(AVOe2005R.male.av, YOB=1955)
ageShift(AVOe2005R.male.av, YOB=2010) ageShift(AVOe2005R.male.av, YOB=2010)
} }
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
\docType{methods} \docType{methods}
\name{ages} \name{ages}
\alias{ages} \alias{ages}
\alias{ages,mortalityTable.joined-method} \alias{ages,mortalityTable.period-method}
\alias{ages,mortalityTable.jointLives-method}
\alias{ages,mortalityTable.mixed-method} \alias{ages,mortalityTable.mixed-method}
\alias{ages,mortalityTable.joined-method}
\alias{ages,mortalityTable.observed-method} \alias{ages,mortalityTable.observed-method}
\alias{ages,mortalityTable.period-method} \alias{ages,mortalityTable.jointLives-method}
\title{Return the defined ages of the life table} \title{Return the defined ages of the life table}
\usage{ \usage{
ages(object, ...) ages(object, ...)
...@@ -42,6 +42,7 @@ Return the defined ages of the life table ...@@ -42,6 +42,7 @@ Return the defined ages of the life table
\item \code{mortalityTable.jointLives}: Return the defined ages of the joint lives mortality table (returns the ages of the first table used for joint lives) \item \code{mortalityTable.jointLives}: Return the defined ages of the joint lives mortality table (returns the ages of the first table used for joint lives)
}} }}
\examples{ \examples{
mortalityTables.load("Austria_*", wildcard=TRUE) mortalityTables.load("Austria_*", wildcard=TRUE)
ages(AVOe2005R.male) ages(AVOe2005R.male)
...@@ -49,4 +50,3 @@ ages(AVOe1996R.male) ...@@ -49,4 +50,3 @@ ages(AVOe1996R.male)
ages(mort.AT.census.2011.male) ages(mort.AT.census.2011.male)
} }
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
\name{baseTable} \name{baseTable}
\alias{baseTable} \alias{baseTable}
\alias{baseTable,mortalityTable-method} \alias{baseTable,mortalityTable-method}
\alias{baseTable,mortalityTable.jointLives-method}
\alias{baseTable,mortalityTable.period-method} \alias{baseTable,mortalityTable.period-method}
\alias{baseTable,mortalityTable.jointLives-method}
\title{Return the base table of the life table} \title{Return the base table of the life table}
\usage{ \usage{
baseTable(object, ...) baseTable(object, ...)
...@@ -32,9 +32,9 @@ Return the base table of the life table ...@@ -32,9 +32,9 @@ Return the base table of the life table
\item \code{mortalityTable.jointLives}: Return the base table of the joint lives mortality table (returns the base table of the first table used for joint lives) \item \code{mortalityTable.jointLives}: Return the base table of the joint lives mortality table (returns the base table of the first table used for joint lives)
}} }}
\examples{ \examples{
mortalityTables.load("Austria_Annuities") mortalityTables.load("Austria_Annuities")
baseTable(AVOe2005R.male) baseTable(AVOe2005R.male)
} }
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
\name{baseYear} \name{baseYear}
\alias{baseYear} \alias{baseYear}
\alias{baseYear,mortalityTable-method} \alias{baseYear,mortalityTable-method}
\alias{baseYear,mortalityTable.jointLives-method}
\alias{baseYear,mortalityTable.mixed-method} \alias{baseYear,mortalityTable.mixed-method}
\alias{baseYear,mortalityTable.jointLives-method}
\title{Return the base year of the life table} \title{Return the base year of the life table}
\usage{ \usage{
baseYear(object, ...) baseYear(object, ...)
...@@ -32,9 +32,9 @@ Return the base year of the life table ...@@ -32,9 +32,9 @@ Return the base year of the life table
\item \code{mortalityTable.jointLives}: Return the base year of the life table \item \code{mortalityTable.jointLives}: Return the base year of the life table
}} }}
\examples{ \examples{
mortalityTables.load("Austria_Annuities") mortalityTables.load("Austria_Annuities")
baseYear(AVOe2005R.male) baseYear(AVOe2005R.male)
} }
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deathProbabilities.R, R/mortalityTable.jointLives.R % Please edit documentation in R/deathProbabilities.R,
% R/mortalityTable.jointLives.R
\docType{methods} \docType{methods}
\name{deathProbabilities} \name{deathProbabilities}
\alias{deathProbabilities} \alias{deathProbabilities}
\alias{deathProbabilities,mortalityTable.period-method}
\alias{deathProbabilities,mortalityTable.ageShift-method} \alias{deathProbabilities,mortalityTable.ageShift-method}
\alias{deathProbabilities,mortalityTable.trendProjection-method}
\alias{deathProbabilities,mortalityTable.improvementFactors-method} \alias{deathProbabilities,mortalityTable.improvementFactors-method}
\alias{deathProbabilities,mortalityTable.jointLives-method}
\alias{deathProbabilities,mortalityTable.mixed-method} \alias{deathProbabilities,mortalityTable.mixed-method}
\alias{deathProbabilities,mortalityTable.period-method} \alias{deathProbabilities,mortalityTable.jointLives-method}
\alias{deathProbabilities,mortalityTable.trendProjection-method}
\title{Return the (cohort) death probabilities of the life table given the birth year (if needed)} \title{Return the (cohort) death probabilities of the life table given the birth year (if needed)}
\usage{ \usage{
deathProbabilities(object, ..., YOB = 1975) deathProbabilities(object, ..., YOB = 1975)
......
...@@ -20,4 +20,3 @@ class. ...@@ -20,4 +20,3 @@ class.
\examples{ \examples{
generateAgeShift(1, YOBs = c(1922, 1944, 1958, 1973, 1989, 2006, 2023, 2041, 2056)) generateAgeShift(1, YOBs = c(1922, 1944, 1958, 1973, 1989, 2006, 2023, 2041, 2056))
} }
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
\docType{methods} \docType{methods}
\name{getOmega} \name{getOmega}
\alias{getOmega} \alias{getOmega}
\alias{getOmega,mortalityTable.joined-method} \alias{getOmega,mortalityTable.period-method}
\alias{getOmega,mortalityTable.jointLives-method}
\alias{getOmega,mortalityTable.mixed-method} \alias{getOmega,mortalityTable.mixed-method}
\alias{getOmega,mortalityTable.joined-method}
\alias{getOmega,mortalityTable.observed-method} \alias{getOmega,mortalityTable.observed-method}
\alias{getOmega,mortalityTable.period-method} \alias{getOmega,mortalityTable.jointLives-method}
\title{Return the maximum age of the life table} \title{Return the maximum age of the life table}
\usage{ \usage{
getOmega(object) getOmega(object)
......
...@@ -24,4 +24,3 @@ It is not required to call this function manually, \code{plotMortalityTables} ...@@ -24,4 +24,3 @@ It is not required to call this function manually, \code{plotMortalityTables}
will automatically do it if object derived from class \code{mortalityTable} will automatically do it if object derived from class \code{mortalityTable}
are passed. are passed.
} }
...@@ -37,4 +37,3 @@ mortalityComparisonTable( ...@@ -37,4 +37,3 @@ mortalityComparisonTable(
} }
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
% Please edit documentation in R/mortalityTable.R % Please edit documentation in R/mortalityTable.R
\docType{class} \docType{class}
\name{mortalityTable-class} \name{mortalityTable-class}
\alias{mortalityTable}
\alias{mortalityTable-class} \alias{mortalityTable-class}
\alias{mortalityTable}
\title{Class mortalityTable} \title{Class mortalityTable}
\description{ \description{
Class \code{mortalityTable} is the (virtual) base class for all mortality Class \code{mortalityTable} is the (virtual) base class for all mortality
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
% Please edit documentation in R/mortalityTable.ageShift.R % Please edit documentation in R/mortalityTable.ageShift.R
\docType{class} \docType{class}
\name{mortalityTable.ageShift-class} \name{mortalityTable.ageShift-class}
\alias{mortalityTable.ageShift}
\alias{mortalityTable.ageShift-class} \alias{mortalityTable.ageShift-class}
\alias{mortalityTable.ageShift}
\title{Class mortalityTable.ageShift - Cohort life tables generated by age-shift} \title{Class mortalityTable.ageShift - Cohort life tables generated by age-shift}
\description{ \description{
A cohort life table, obtained by age-shifting from a given base table (death probabilities A cohort life table, obtained by age-shifting from a given base table (death probabilities
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
% Please edit documentation in R/mortalityTable.improvementFactors.R % Please edit documentation in R/mortalityTable.improvementFactors.R
\docType{class} \docType{class}
\name{mortalityTable.improvementFactors-class} \name{mortalityTable.improvementFactors-class}
\alias{mortalityTable.improvementFactors}
\alias{mortalityTable.improvementFactors-class} \alias{mortalityTable.improvementFactors-class}
\alias{mortalityTable.improvementFactors}
\title{Class mortalityTable.improvementFactors - Cohort life table with improvement \title{Class mortalityTable.improvementFactors - Cohort life table with improvement
factors} factors}
\description{ \description{
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
% Please edit documentation in R/mortalityTable.joined.R % Please edit documentation in R/mortalityTable.joined.R
\docType{class} \docType{class}
\name{mortalityTable.joined-class} \name{mortalityTable.joined-class}
\alias{mortalityTable.joined}
\alias{mortalityTable.joined-class} \alias{mortalityTable.joined-class}
\alias{mortalityTable.joined}
\title{Class mortalityTable.joined - Life table created by joining two life tables} \title{Class mortalityTable.joined - Life table created by joining two life tables}
\description{ \description{
A cohort life table obtained by joining two cohort life tables, each of which A cohort life table obtained by joining two cohort life tables, each of which
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
% Please edit documentation in R/mortalityTable.jointLives.R % Please edit documentation in R/mortalityTable.jointLives.R
\docType{class} \docType{class}
\name{mortalityTable.jointLives-class} \name{mortalityTable.jointLives-class}
\alias{mortalityTable.jointLives}
\alias{mortalityTable.jointLives-class} \alias{mortalityTable.jointLives-class}
\alias{mortalityTable.jointLives}
\title{Class mortalityTable.jointLives - Life table for multiple joint lives} \title{Class mortalityTable.jointLives - Life table for multiple joint lives}
\description{ \description{
A cohort life table obtained by calculating joint death probabilities for A cohort life table obtained by calculating joint death probabilities for
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
% Please edit documentation in R/mortalityTable.mixed.R % Please edit documentation in R/mortalityTable.mixed.R
\docType{class} \docType{class}
\name{mortalityTable.mixed-class} \name{mortalityTable.mixed-class}
\alias{mortalityTable.mixed}
\alias{mortalityTable.mixed-class} \alias{mortalityTable.mixed-class}
\alias{mortalityTable.mixed}
\title{Class mortalityTable.mixed - Life table as a mix of two life tables} \title{Class mortalityTable.mixed - Life table as a mix of two life tables}
\description{ \description{
A cohort life table obtained by mixing two life tables with the given weights A cohort life table obtained by mixing two life tables with the given weights
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
% Please edit documentation in R/mortalityTable.observed.R % Please edit documentation in R/mortalityTable.observed.R
\docType{class} \docType{class}
\name{mortalityTable.observed-class} \name{mortalityTable.observed-class}
\alias{mortalityTable.observed}
\alias{mortalityTable.observed-class} \alias{mortalityTable.observed-class}
\alias{mortalityTable.observed}
\title{Class mortalityTable.observed - Life table from actual observations} \title{Class mortalityTable.observed - Life table from actual observations}
\description{ \description{
A cohort life table described by actual observations (data frame of PODs A cohort life table described by actual observations (data frame of PODs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment