From b54cb929a07cda5228a904c1b60f1bd27c4c1da7 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Wed, 30 Aug 2017 00:12:14 +0000 Subject: [PATCH] Add utility function mortalityTable.onceAndFuture --- NAMESPACE | 1 + R/mortalityTable.period.R | 14 ++++++++++++++ man/mortalityTable.onceAndFuture.Rd | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 man/mortalityTable.onceAndFuture.Rd diff --git a/NAMESPACE b/NAMESPACE index 8104960..0918ff0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,6 +13,7 @@ export(mortalityTable.jointLives) export(mortalityTable.mixed) export(mortalityTable.observed) export(mortalityTable.once) +export(mortalityTable.onceAndFuture) export(mortalityTable.period) export(mortalityTable.trendProjection) export(mortalityTable.zeroes) diff --git a/R/mortalityTable.period.R b/R/mortalityTable.period.R index c1bf31a..d569e51 100644 --- a/R/mortalityTable.period.R +++ b/R/mortalityTable.period.R @@ -49,3 +49,17 @@ mortalityTable.once = function(transitionAge, name = "Deterministic mortality ta ) } +#' Generate a (deterministic) mortality table with all probabilities starting at a given age set to 1 +#' +#' @param transitionAge The age where the deterministic transition occurs +#' @param name The name of the table +#' @param ages The ages of the table +#' +#' @export +mortalityTable.onceAndFuture = function(transitionAge, name = "Deterministic mortality table", ages = 0:99) { + mortalityTable.period( + name = name, + ages = ages, + deathProbs = sapply(ages, function(x) { if (x >= transitionAge) 1 else 0}) + ) +} diff --git a/man/mortalityTable.onceAndFuture.Rd b/man/mortalityTable.onceAndFuture.Rd new file mode 100644 index 0000000..33c9cd1 --- /dev/null +++ b/man/mortalityTable.onceAndFuture.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mortalityTable.period.R +\name{mortalityTable.onceAndFuture} +\alias{mortalityTable.onceAndFuture} +\title{Generate a (deterministic) mortality table with all probabilities starting at a given age set to 1} +\usage{ +mortalityTable.onceAndFuture(transitionAge, + name = "Deterministic mortality table", ages = 0:99) +} +\arguments{ +\item{transitionAge}{The age where the deterministic transition occurs} + +\item{name}{The name of the table} + +\item{ages}{The ages of the table} +} +\description{ +Generate a (deterministic) mortality table with all probabilities starting at a given age set to 1 +} -- GitLab