## Selecting the exposure and the death count of the year 1990, ranging from 0 to 90 years old:
USA1990 = USA[USA$Year == 1990,]
x = 0:90
Ex = USA1990$Ex.Male[x+1]
Dx = USA1990$Dx.Male[x+1]
## Fitting the poisson and the lognormal model:
fit = hp(x = x, Ex = Ex, Dx = Dx, model = "poisson",
M = 2000, bn = 1000, thin = 1)
fit2 = hp(x = x, Ex = Ex, Dx = Dx, model = "lognormal",
M = 2000, bn = 1000, thin = 1)
## Plot the life tables:
plot(fit)
plot(fit2, age = 0:110, plotIC = TRUE)
## To plot multiples life tables see ?plot.list
plot(list(fit, fit2),
age = 0:110, Ex = USA1990$Ex.Male,
plotIC = FALSE, colors = c("red", "blue"),
labels = c("Poisson", "Lognormal"))
Run the code above in your browser using DataLab