mortalityImprovement.R 2.02 KB
Newer Older
1
2
3
#' @include mortalityTable.R mortalityTable.period.R mortalityTable.ageShift.R mortalityTable.trendProjection.R mortalityTable.improvementFactors.R mortalityTable.mixed.R
NULL

Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
4
#' Return the mortality trend (yearly log-death-probability improvement) of the given period or the given generation.
5
6
7
8
#'
#' @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
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
9
10
11
12
13
#' @param Period The observation year for which the mortality improvement should
#'               be calculated. If both YOB and Period are given, YOB is ignored.
#'
#' @examples
#' mortalityTables.load("Austria_Annuities")
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
14
15
#' # AVOe 2005R includes a trend decline by default, compare the exact table
#' # with the table without decline:
Reinhold Kainhofer's avatar
Reinhold Kainhofer committed
16
17
#' mortalityImprovement(AVOe2005R.male, Period = 2017)
#' mortalityImprovement(AVOe2005R.male.nodamping, Period = 2017)
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#'
#' @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
          })