# create simulated population with artifical coarsening first
pop_sim <- pop.sim.gomp(n = 1000)
sim_ranges <- random.cat()
# apply random age categories to simulated ages
sim_appl <- random.cat.apply(pop_sim$result, age = "age",
age_ranges = sim_ranges, from = "from", to = "to")
# create halley bands
demo <- halley.band(sim_appl, n = 1000, uncert = 0.95, agebeg = "from",
ageend = "to", agerange = "excluded")
# plot band with ggplot
library(ggplot2)
ggplot(demo) + geom_ribbon(aes(x = age, ymin = lower_dx, ymax = upper_dx),
linetype = 0, fill = "grey")
ggplot(demo) + geom_ribbon(aes(x = age, ymin = lower_lx, ymax = upper_lx),
linetype = 0, fill = "grey")
ggplot(demo) + geom_ribbon(aes(x = age, ymin = lower_qx, ymax = upper_qx),
linetype = 0, fill = "grey")
Run the code above in your browser using DataLab