Learn R Programming

LEdecomp (version 1.0.4)

sen_resid: sen_resid

Description

Most sensitivity methods in this packages (sen_arriaga_sym() excepted) are approximations; when used in decompositions they will tend to imply residuals. To acheive near-exact additivity for a decomposition using these sensitivity approaches, one can try to find a different weighting of rates from populations 1 and 2, rather than simply taking their arithmetic average. Here we turn this into an optimization problem, where we find the weighting w that implies an exactly additive decomposition to an arbitrary degree of tolerance. This function gives said residual, for purposes of optimizing using sen_min(). We export this auxiliary function because one might wish to know the value w that balances rates such that the decomposition is exact. $$m_{x} = m_{x}^{1} * w + m_{x}^{2} * (1-w)$$

Usage

sen_resid(
  w = 0.5,
  mx1,
  mx2,
  age = 0:(length(mx) - 1),
  nx = rep(1, length(mx)),
  sex1,
  sex2 = sex1,
  closeout = TRUE,
  sen_fun = sen_arriaga_instantaneous,
  ...
)

Value

age-specific sensitivity of life expectancy to changes in mortality rates.

Arguments

w

the parameter weight to optimize, default 0.5

mx1

numeric vector of the mortality rates (central death rates) for population 1

mx2

numeric vector of the mortality rates (central death rates) for population 2

age

integer vector of the lower bound of each age group (currently only single ages supported)

nx

integer vector of age intervals, default 1.

sex1

character either the sex for population 1: Male ("m"), Female ("f"), or Total ("t")

sex2

character either the sex for population 2: Male ("m"), Female ("f"), or Total ("t") assumed same as sex1 unless otherwise specified.

closeout

logical. Default TRUE. Shall we use the HMD Method Protocol to close out the ax and qx values? See details.

sen_fun

function name, current options include sen_e0_mx_lt, sen_arriaga_instantaneous, sen_arriaga_instantaneous2, sen_arriaga_sym, sen_num,sen_chandrasekaran_II_instantaneous ,sen_chandrasekaran_ii_instantaneous2,sen_chandrasekaran_iii_instantaneous, sen_chandrasekaran_iii_instantaneous2,sen_lopez_ruzicka_instantaneous, sen_lopez_ruzicka_instantaneous2

...

optional arguments passed to a given sensitivity function.

Examples

Run this code
a   <- .001
b   <- .07
x   <- 0:100
mx1 <- a * exp(x * b)
mx2 <- a/2 * exp(x * b)
w <- optimize(sen_resid,
              mx1 = mx1,
              mx2 = mx2,
              age = x,
              sen_fun = sen_arriaga_instantaneous,
              sex1 = 't',
              sex2 = 't',
              closeout = TRUE,
              interval = c(.4,.6))$minimum
w

Run the code above in your browser using DataLab