## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## -----------------------------------------------------------------------------
suppressPackageStartupMessages(library(eq5d))

## Example EQ-5D-3L data included with the package
dat <- read.csv(
  system.file("extdata", "eq5d3l_example.csv", package = "eq5d")
)

## For an ungrouped population-level example
dat1 <- subset(dat, Group == "Group1")

## Example EQ-5D-3L profile (single observation)
scores <- unlist(dat1[1, c("MO", "SC", "UA", "PD", "AD")])

## ----eval=FALSE---------------------------------------------------------------
# # Example severity summaries
# lss(scores, version = "3L")
# lfs(scores, version = "3L")

## -----------------------------------------------------------------------------
# Shannon's entropy and evenness for a population
shannon(dat1, version = "3L")

## -----------------------------------------------------------------------------
# Health state cumulative frequency object
cf <- eq5dcf(dat1, version = "3L")

## -----------------------------------------------------------------------------
idx <- hsdi(dat1, version = "3L")
idx

## ----eval=TRUE, fig.width = 6, fig.height = 6, fig.align = "center"-----------
plot_hsdc(cf, hsdi = idx)

## ----eval=TRUE, fig.width = 6, fig.height = 6, fig.align = "center"-----------
# Grouped HSDI
hsdi_by_group <- make_hsdi_by_group(
  dat,
  group = "Group",
  version = "3L"
)

hsdi_by_group

# Grouped HSDC data
hsdc_by_group <- make_hsdc_by_group(
  dat,
  group = "Group",
  version = "3L"
)

plot_hsdc(hsdc_by_group, hsdi = hsdi_by_group, group = "Group")

