## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(dceasimR)

## ----baseline-----------------------------------------------------------------
baseline <- get_baseline_health("england", "imd_quintile")

## ----subgroup-data------------------------------------------------------------
subgroup_data <- tibble::tibble(
  group       = 1:5,
  group_label = paste("IMD Q", 1:5),
  inc_qaly    = c(0.28, 0.36, 0.44, 0.51, 0.57),
  inc_cost    = c(13200, 12800, 12400, 12000, 11600),
  pop_share   = c(0.28, 0.24, 0.20, 0.16, 0.12)
)
subgroup_data

## ----uptake-------------------------------------------------------------------
uptake <- c(0.58, 0.63, 0.68, 0.73, 0.77)

## ----run-full-dcea------------------------------------------------------------
result_full <- run_full_dcea(
  subgroup_cea_results       = subgroup_data,
  baseline_health            = baseline,
  wtp                        = 20000,
  opportunity_cost_threshold = 13000,
  uptake_by_group            = uptake
)
summary(result_full)

## ----plane, fig.width = 6, fig.height = 5-------------------------------------
plot_equity_impact_plane(result_full)

## ----staircase-data-----------------------------------------------------------
sc_data <- build_staircase_data(
  group           = 1:5,
  group_labels    = paste("IMD Q", 1:5),
  prevalence      = c(0.08, 0.07, 0.06, 0.05, 0.04),
  eligibility     = c(0.70, 0.72, 0.74, 0.76, 0.78),
  uptake          = uptake,
  clinical_effect = subgroup_data$inc_qaly,
  opportunity_cost = subgroup_data$inc_cost / 13000
)

## ----staircase-plot, fig.width = 7, fig.height = 6----------------------------
plot_inequality_staircase(sc_data)

