Commit 19ae857f authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Add function mortalityImprovement to calculate age-specific yearly...

Add function mortalityImprovement to calculate age-specific yearly log-mortality improvements (aka. mortality trends)
parent 65d28fba
......@@ -43,6 +43,7 @@ Collate:
'lifeTable.R'
'makeQxDataFrame.R'
'mortalityComparisonTable.R'
'mortalityImprovement.R'
'periodDeathProbabilities.R'
'mortalityTable.jointLives.R'
'mortalityTables.list.R'
......
......@@ -43,6 +43,7 @@ exportMethods(getCohortTable)
exportMethods(getOmega)
exportMethods(getPeriodTable)
exportMethods(lifeTable)
exportMethods(mortalityImprovement)
exportMethods(periodDeathProbabilities)
exportMethods(periodTransitionProbabilities)
exportMethods(setLoading)
......
#' @include mortalityTable.R mortalityTable.period.R mortalityTable.ageShift.R mortalityTable.trendProjection.R mortalityTable.improvementFactors.R mortalityTable.mixed.R
NULL
#' Return the mortality trend / yearly log-mortality improvement of the given period or the given generation.
#'
#' @param object The life table object (class inherited from mortalityTable)
#' @param ... Other parameters (currently unused)
#' @param YOB The birth year for which the mortality improvement should be calculated
#' @param Period The observation year for which the mortality improvement should be calculated. If both YOB and Period are given, YOB is ignored.
#'
#' @exportMethod mortalityImprovement
setGeneric("mortalityImprovement", function(object, ..., Period = NULL, YOB = 1975) standardGeneric("mortalityImprovement"));
#' @describeIn mortalityImprovement Return the yearly log-mortality improvement of the
#' life table given the birth or observation year
setMethod("mortalityImprovement", "mortalityTable",
function(object, ..., Period = NULL, YOB = 1975) {
ages = ages(object)
if (missing(Period) || is.null(Period)) {
# Improvement for generation YOB
qt1 = deathProbabilities(object, ..., YOB = YOB - 1)
qt = deathProbabilities(object, ..., YOB = YOB)
} else {
# Improvement for observation year Period
qt1 = periodDeathProbabilities(object, ..., Period = Period - 1)
qt = periodDeathProbabilities(object, ..., Period = Period)
}
lambda = -log(qt/qt1);
names(lambda) = ages;
lambda
})
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mortalityImprovement.R
\docType{methods}
\name{mortalityImprovement}
\alias{mortalityImprovement}
\alias{mortalityImprovement,mortalityTable-method}
\title{Return the mortality trend / yearly log-mortality improvement of the given period or the given generation.}
\usage{
mortalityImprovement(object, ..., Period = NULL, YOB = 1975)
\S4method{mortalityImprovement}{mortalityTable}(object, ..., Period = NULL,
YOB = 1975)
}
\arguments{
\item{object}{The life table object (class inherited from mortalityTable)}
\item{...}{Other parameters (currently unused)}
\item{Period}{The observation year for which the mortality improvement should be calculated. If both YOB and Period are given, YOB is ignored.}
\item{YOB}{The birth year for which the mortality improvement should be calculated}
}
\description{
Return the mortality trend / yearly log-mortality improvement of the given period or the given generation.
}
\section{Methods (by class)}{
\itemize{
\item \code{mortalityTable}: Return the yearly log-mortality improvement of the
life table given the birth or observation year
}}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment