calc_ac_lifespan: Generate an age at other-cause death from a lifetable

Description Usage Arguments Value Examples

Description

Given a year of birth and current age, draws a random age at other-cause death from a lifetable

Usage

1
2
calc_ac_lifespan(ageentry, male, lifetable, n_sim = 100, time = FALSE,
  haz = 1, max100 = TRUE)

Arguments

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

Value

A vector of length n_sim containing ages at other-cause death (or times to other-cause death, if time=TRUE)

Examples

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)

cancerpolicy/bcimodel documentation built on June 30, 2019, 12:39 a.m.