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