Learn R Programming

LEdecomp (version 1.0.4)

sen_min: sen_min

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. $$m_{x} = m_{x}^{1} * w + m_{x}^{2} * (1-w)$$

Usage

sen_min(
  mx1,
  mx2,
  age,
  sex1,
  sex2 = sex1,
  closeout = TRUE,
  sen_fun = sen_arriaga_instantaneous,
  tol = 1e-10,
  ...
)

Value

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

Arguments

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)

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_arriaga_instantaneous, sen_arriaga_instantaneous1, sen_arriaga_sym, sen_e0_mx_lt, sen_num

tol

double. tolerance level for residual, passed to optimise()

...

optional arguments to pass to sen_fun()

Details

We expect the value w to be close to .5, and only search the interval [.4,.6]. This may need to be revisited in case that proves too narrow.

Examples

Run this code
a   <- .001
b   <- .07
x   <- 0:100
mx1 <- a * exp(x * b)
mx2 <- a/2 * exp(x * b)
mx  <- (mx1 + mx2) / 2
s1 <- sen_min(mx1, mx2,
              age = x, sex1 = 't',
              closeout = TRUE,
              sen_fun = sen_arriaga_instantaneous)
s2 <- sen_min(mx1, mx2,
              age = x, sex1 = 't',
              closeout = TRUE,
              sen_fun = sen_e0_mx_lt,
              tol = 1e-12)

# check sums
e01 <- mx_to_e0(mx1,age=x,sex='t',closeout=TRUE)
e02 <- mx_to_e0(mx2,age=x,sex='t',closeout=TRUE)
(gap <- e02 - e01)
delta <- mx2 - mx1
(gap1 <- sum(s1 * delta))
(gap2 <- sum(s2 * delta))
gap2-gap

plot(x, s1, type= 'l')
lines(x, s2, col = 'red', lty = 2, lwd = 2)

plot(x, s2-s1, main = "age 0 difference is due to imprecision in
lifetable approach for this age")

Run the code above in your browser using DataLab