# Load simulated data as example
data(simu_data)
data(pop_ref)
# Estimate remaining life expectancy and Life Years
# Lost due to specific causes of death after age 45
# years and before age 95 years for those with a disease
diseased <- simu_data[!is.na(simu_data$age_disease), ]
lyl_estimation1 <- lyl(data = diseased, t0 = age_disease,
t = age_death, status = cause_death,
age_specific = 45, tau = 95)
lyl_diff_ref(lyl_estimation1, pop_ref, age = age, surv = survival)
lyl_diff_ref(lyl_estimation1, pop_ref, age = age, rates = mortality_rates)
# Calculate bootstrapped confidence interval (3 iterations to test; more are necessary)
lyl_estimation1_ci <- lyl_ci(lyl_estimation1, niter = 3)
lyl_diff_ref(lyl_estimation1_ci, pop_ref, age = age, surv = survival)
# \donttest{
# Estimate remaining life expectancy and Life Years
# Lost due to specific causes of death after each age
# from 0 to 94 years and before age 95 years
lyl_estimation2 <- lyl_range(data = diseased, t0 = age_disease,
t = age_death, status = cause_death,
age_begin = 0, age_end = 94, tau = 95)
lyl_diff_ref(lyl_estimation2, pop_ref, age = age, surv = survival)
lyl_diff_ref(lyl_estimation2, pop_ref, age = age, surv = survival, weights = diseased$age_disease)
# }
Run the code above in your browser using DataLab