# Plotting the EQ-5D

## Why?

The EQ-5D is a HRQoL measure with 5 domains, where a person states they have either no, some or lots of problems. The combinations of the 3-levels can then by weighted to give an index score, that goes from below zero to one. With one representing perfect health, and zero death (meaning there are states worse than death).

In my PhD, I wanted to save space by showing both the EQ-5D index score, and how impairment was distributed, at the same time. So I setup the ggplot based function below to let me quickly plot the EQ-5D.

## What it looks like

## Using my function

Load up the functions from github.

```
library(devtools)
install_github('epijim/EpiJimFunctions')
library(EpiJimFunctions)
```

The first step is to run `jb_geteqvalues`

to take the index score and 5 domains of the EQ-5D and get back the data with the number of impaired domains calculated. The first variable is a numeric saying what bar you want that set of EQ-5D values to be.

```
timepoint_1 <- jb_geteqvalues(1,
data$eq5d_0,
data$eq_mobility_0,
data$eq_anxiety_0,
data$eq_selfcare_0,
data$eq_pain_0,
data$eq_usualactivities_0)
timepoint_2 <- jb_geteqvalues(2,
data$eq5d_1,
data$eq_mobility_1,
data$eq_anxiety_1,
data$eq_selfcare_1,
data$eq_pain_1,
data$eq_usualactivities_1)
timepoint_3 <- jb_geteqvalues(3,
data$eq5d_2,
data$eq_mobility_2,
data$eq_anxiety_2,
data$eq_selfcare_2,
data$eq_pain_2,
data$eq_usualactivities_2)
```

So now I have the three timepoints of the EQ-5D ready, so I stack them with `rbind`

. I drop the missing values as well. Not doing this will result in the stacked bar including a level for the proportion missing.

```
# Merge timepoints
data <- rbind(timepoint_1,timepoint_2,timepoint_3)
# Drop missing values (can be left in, and will be gray)
data_nona <- na.omit(data)
```

And then making the plots. `FALSE`

gives the violin above, `TRUE`

gives something more similar to a bullet plot below. The bullet plot has the mean as a bar graph, and the median as a red line.

```
jb_ploteq5d(data,F)
jb_ploteq5d(data,T)
```

## A more general function

This function is very specific to the EQ-5D. There is a non-ggplot version of the bullet graph available.^{1}

## Alluvial diagram

The data from `jb_geteqvalues`

can also be used make an alluvial figure, like the one below. I made the figure below using a published function called `alluvial`

^{2}, so the code is not included in this function.