## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4 ) ## ----data--------------------------------------------------------------------- library(HOME) age <- seq(20, 60, by = 5) sn <- c(0.987, 0.967, 0.934, 0.908, 0.882, 0.835, 0.769, 0.669, 0.565) mn <- rep(27, 9) date <- 1998.5 ## ----estimate----------------------------------------------------------------- result <- om_estimate_index( method = "luy", sex_parent = "Female", age_respondent = age, p_surv = sn, mean_age_parent = mn, surv_date = date, model_family = "General" ) ## ----print-------------------------------------------------------------------- print(result) ## ----summary------------------------------------------------------------------ summary(result) ## ----compare------------------------------------------------------------------ luy <- om_estimate_index("luy", "Female", age, sn, mn, date) brass <- om_estimate_index("brass", "Female", age, sn, mn, date) timaeus <- om_estimate_index("timaeus", "Female", age, sn, mn, date) ## ----compare-plot, fig.height=3.5--------------------------------------------- library(ggplot2) methods <- list( "Luy (2012)" = luy, "Brass and Hill (1973)"= brass, "Timaeus (1992)" = timaeus ) cols <- c( "Luy (2012)" = "#003082", "Brass and Hill (1973)" = "#E09B00", "Timaeus (1992)" = "#5A8FC2" ) df <- do.call(rbind, lapply(names(methods), function(nm) { d <- methods[[nm]]$estimates d$Method <- nm d })) df <- df[!is.na(df$RefYear) & !is.na(df[["30q30"]]), ] ggplot(df, aes(x = RefYear, y = `30q30`, colour = Method, group = Method)) + geom_line(linewidth = 0.7) + geom_point(size = 1.5, alpha = 0.6) + scale_colour_manual(values = cols, name = NULL) + labs(x = "Reference year", y = expression({}[30]*q[30])) + theme_bw() + theme(legend.position = "bottom") ## ----linearity, fig.height=3-------------------------------------------------- om_plot_linearity(luy) ## ----sens-m------------------------------------------------------------------- sens_m <- om_sensitivity(luy, range_m = seq(-2, 2, by = 0.5)) print(sens_m) summary(sens_m, index = "30q30") ## ----sens-m-plot, fig.height=3.5---------------------------------------------- plot(sens_m, index = "30q30") ## ----sens-fam----------------------------------------------------------------- sens_fam <- om_sensitivity_family(luy, type = "UN") print(sens_fam) summary(sens_fam, index = "30q30") ## ----sens-fam-plot, fig.height=3.5-------------------------------------------- plot(sens_fam, index = "30q30") ## ----dashboard, fig.height=6, fig.width=7------------------------------------- om_dashboard(luy, index = "30q30", family_type = "UN")