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