# NOT RUN {
# Load simulated data as example
data(simu_data)
### For the overall population and for those with a disease
diseased <- simu_data[!is.na(simu_data$age_disease), ]
# Estimate remaining life expectancy and Life Years
# Lost due to specific causes of death after age 45
# years and before age 95 years
lyl_estimation0 <- lyl(data = simu_data, t = age_death, status = cause_death,
age_specific = 45, tau = 95)
lyl_estimation1 <- lyl(data = diseased, t0 = age_disease,
t = age_death, status = cause_death,
age_specific = 45, tau = 95)
lyl_diff(lyl_estimation1, lyl_estimation0)
# Calculate bootstrapped confidence interval (3 iterations to test)
lyl_estimation1_ci <- lyl_ci(lyl_estimation1, niter = 3)
# }
# NOT RUN {
lyl_estimation0_ci <- lyl_ci(lyl_estimation0, niter = 3)
lyl_diff(lyl_estimation1_ci, lyl_estimation0_ci)
# }
# NOT RUN {
# It is also possible to assume no uncertainty for one of the estimates
lyl_diff(lyl_estimation1_ci, lyl_estimation0)
# }
# NOT RUN {
# 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 = simu_data, t = age_death, status = cause_death,
age_begin = 0, age_end = 94, tau = 95)
lyl_estimation3 <- lyl_range(data = diseased, t0 = age_disease,
t = age_death, status = cause_death,
age_begin = 0, age_end = 94, tau = 95)
lyl_diff(lyl_estimation3, lyl_estimation2)
lyl_diff(lyl_estimation3, lyl_estimation2, weights = diseased$age_disease)
# Calculate bootstrapped confidence interval (3 iterations to test)
lyl_estimation3_ci <- lyl_ci(lyl_estimation3, niter = 3)
lyl_diff(lyl_estimation3_ci, lyl_estimation2, weights = diseased$age_disease)
# }
Run the code above in your browser using DataCamp Workspace