# NOT RUN {
data(mxM, package = "wpp2017")
mx <- subset(mxM, name == "Burkina Faso")[,-(1:3)]
rownames(mx) <- c(0,1, seq(5, 100, by=5))
mxnew <- kannisto(mx)
ages <- as.integer(rownames(mxnew))
plot(ages, mxnew[,"2095-2100"], type="l", log="y",
xlab="age", ylab="mx", col="red")
lines(ages, mxnew[,"2010-2015"])
# Kannisto for 1-year age groups
# derive toy 1-year mx using model life tables at e0 of 70
mx1y <- mlt(70, sex = "male", nx = 1)
# Pretend we only observed mx for ages 0:100.
# Use 90-99 for estimation and extend mx from 100 to 140
mx1ynew <- kannisto(mx1y[1:100, , drop = FALSE], est.ages = 90:99, proj.ages = 100:140)
# Plot the new mx for old ages
plot(80:140, mx1ynew[81:141], type = "l", xlab="age", ylab="mx", col="red")
# Check how it compares to the original mx that was not used in the estimation
lines(100:130, mx1y[101:nrow(mx1y)])
# }
Run the code above in your browser using DataLab