Learn R Programming

LEdecomp (version 1.0.4)

sen_e0_mx_lt: A direct approximation of the sensitivity of life expectancy at birth to changes in mortality.

Description

This function tries to get the direct discrete life expectancy sensitivity to \(m(x)\), in continuous math it's \(-l(x)e(x)\), we just need to find the best approx with a discrete lifetable. This direct lifetable-based calculation requires a few approximations to get a usable value whenever we're working with discrete data. In continuous notation, we know that the sensitivity \(s(x)\) $$s(x) = -l(x)e(x)$$ but it is not obvious what to use from a discrete lifetable. In this implementation, we use \(L(x)\) and an \(a(x)\)-weighted average of successive \(e(x)\) values, specifically, we calculate: $$ s_x = -L_x \cdot \left( e_x \cdot \left( 1 - a_x \right) + e_{x+1} \cdot a_x\right) $$ This seems to be a very good approximation for ages >0, but we still have a small, but unaccounted-for discrepancy in age 0, at least when comparing with also-imperfect numerical derivatives.

Usage

sen_e0_mx_lt(
  mx,
  age = 0:(length(mx) - 1),
  nx = rep(1, length(mx)),
  sex = "t",
  closeout = TRUE
)

Value

numeric vector of sensitivity of life expectancy to perturbations in mx.

Arguments

mx

numeric vector of the mortality rates (central death rates)

age

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

nx

age interval width, assumes 1 by default

sex

character: Male ("m"), Female ("f"), or Total ("t")

closeout

logical. Default TRUE.

Examples

Run this code
x <- 0:100
mx <- 0.001 * exp(x * 0.07)
sl <-  sen_e0_mx_lt(mx,age=x,sex='t',closeout=TRUE)
sn <- numDeriv::grad(mx_to_e0, mx, age=x, sex = 't', closeout=TRUE)
# \donttest{
plot(x,sl)
lines(x,sn)
# }
# examine residuals:
sl - sn
# Note discrepancies in ages >0 are due to numerical precision only
# \donttest{
plot(x, sl - sn, main = "still uncertain what accounts for the age 0 discrepancy")
# }

Run the code above in your browser using DataLab