## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") library(dceasimR) ## ----data--------------------------------------------------------------------- df <- tibble::tibble( group = 1:5, mean_hale = c(52.1, 56.3, 59.8, 63.2, 66.8), pop_share = rep(0.2, 5) ) ## ----sii---------------------------------------------------------------------- calc_sii(df, "mean_hale", "group", "pop_share") ## ----rii---------------------------------------------------------------------- calc_rii(df, "mean_hale", "group", "pop_share") ## ----ci----------------------------------------------------------------------- calc_concentration_index(df, "mean_hale", "group", "pop_share", type = "standard") ## ----atkinson----------------------------------------------------------------- calc_atkinson_index(df$mean_hale, df$pop_share, epsilon = 1) ## ----gini--------------------------------------------------------------------- calc_gini(df$mean_hale, df$pop_share) ## ----all---------------------------------------------------------------------- calc_all_inequality_indices(df, "mean_hale", "group", "pop_share", epsilon_values = c(0.5, 1, 2)) ## ----lorenz-data-------------------------------------------------------------- ld <- compute_lorenz_data(df$mean_hale, df$pop_share, "England 2019") ## ----lorenz-plot, fig.width = 5, fig.height = 4------------------------------- library(ggplot2) ggplot(ld, aes(cum_pop, cum_health)) + geom_line(colour = "steelblue", linewidth = 1) + geom_abline(linetype = "dashed") + labs(x = "Cumulative population", y = "Cumulative health", title = "Lorenz Curve") + theme_minimal()