# NOT RUN {
# Load simulated data as example
data(simu_data)
# Estimate remaining life expectancy and Life Years
# Lost after age 45 years and before age 95 years
lyl_estimation <- lyl(data = simu_data, t = age_death, status = cause_death,
age_specific = 45, tau = 95)
# Same estimate for those with a specific 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)
# Plot the data
lyl_2plot(lyl_estimation1, lyl_estimation)
lyl_2plot(lyl_estimation1, lyl_estimation,
labels = c("Population with a disease", "General population"))
# The plot can be modified with a usual ggplot2 format
lyl_2plot(lyl_estimation1, lyl_estimation) +
ggplot2::xlab("Age [in years]") +
ggplot2::ggtitle("Differences in Life Years Lost at age 45 years")
# }
Run the code above in your browser using DataLab