Description Usage Arguments Value Examples
Given a year of birth and current age, draws a random age at other-cause death from a lifetable
1 2 | calc_ac_lifespan(ageentry, male, lifetable, n_sim = 100, time = FALSE,
haz = 1, max100 = TRUE)
|
ageentry |
An integer age |
male |
Sex indicator: 1 for male, 0 for female |
lifetable |
Data frame with columns Survival, BirthCohort, Age, and Male |
n_sim |
Number of random draws to return |
time |
Set to TRUE to return time between ageentry and death, instead of age at death |
haz |
Hazard to apply to the life table survival |
max100 |
If TRUE, interpolate out to 100 as the max survival age |
A vector of length n_sim containing ages at other-cause death (or times to other-cause death, if time=TRUE)
1 2 3 4 5 6 7 8 9 | library(bcimodel)
data(allmortratesf)
surv <- interpolate_cumsurv(allmortratesf,
ratevar='Rate.Per.100K',
country='Uganda')
# Code compatibility tweaks for life table
surv <- transform(surv, Age=age, Survival=cumsurv, Male=0)
# Generate 5 death times for a female of age 30
calc <- ac <- lifespan(30, 0, surv, 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.