|
| 1 | +--- |
| 2 | +title: "Maraca Plots - Alternative Endpoints" |
| 3 | +author: "Monika Huhn" |
| 4 | +date: "`r Sys.Date()`" |
| 5 | +output: rmarkdown::html_vignette |
| 6 | +vignette: > |
| 7 | + %\VignetteIndexEntry{Maraca Plots - Alternative Endpoints} |
| 8 | + %\VignetteEngine{knitr::rmarkdown} |
| 9 | + \usepackage[utf8]{inputenc} |
| 10 | +--- |
| 11 | + |
| 12 | +```{r setup, include = FALSE} |
| 13 | +knitr::opts_chunk$set(echo = TRUE, collapse = TRUE) |
| 14 | +library(dplyr) |
| 15 | +library(maraca) |
| 16 | +``` |
| 17 | + |
| 18 | +The maraca package can also be used for hierarchical endpoints containing other type of endpoints than |
| 19 | +time-to-event and continuous. Currently binary endpoints are also supported with further type of |
| 20 | +endpoints under development |
| 21 | + |
| 22 | + |
| 23 | +## Binary endpoints |
| 24 | + |
| 25 | +### Last outcome |
| 26 | + |
| 27 | +First we go through an example where the final outcome instead of being continuous, is a binary outcome. |
| 28 | +As an example, this could for example be weight loss above a certain threshold at the end of the study. |
| 29 | +The way the outcome should be included in the data is as a numeric vector with 1 for those patients that |
| 30 | +had the outcome and 0 for those that had not. |
| 31 | + |
| 32 | +We do not have any example dataset with a final binary endpoint included in the package, so for |
| 33 | +this vignette we modify an existing dataset: |
| 34 | + |
| 35 | +```{r} |
| 36 | +data("hce_scenario_a") |
| 37 | +# Create data with binary version of continuous final endpoint |
| 38 | +bin_data <- hce_scenario_a |
| 39 | +# Index of all continuous outcome rows |
| 40 | +idx_cont <- bin_data$GROUP == "Continuous outcome" |
| 41 | +# Rename outcome |
| 42 | +bin_data[idx_cont,"GROUP"] <- "Binary outcome" |
| 43 | +# Binary version (>= 0/< 0) |
| 44 | +bin_data[idx_cont,"AVAL0"] <- bin_data[idx_cont,"AVAL0"] >= 0 |
| 45 | +bin_data[idx_cont,"AVAL"] <- bin_data[idx_cont,"AVAL0"] + |
| 46 | + bin_data[idx_cont,"GROUPN"] |
| 47 | +head(bin_data) |
| 48 | +``` |
| 49 | + |
| 50 | +If we now want to create a maraca object for this data, we need to slightly update |
| 51 | +the default code. By default, maraca expects the last outcome to be continuous. In |
| 52 | +order for the function to know that the last outcome is binary, we have to update |
| 53 | +the parameter `last_type`. The parameter currently accepts the inputs `"binary"` and |
| 54 | +`"continuous"`. |
| 55 | +```{r} |
| 56 | +column_names <- c( |
| 57 | + outcome = "GROUP", |
| 58 | + arm = "TRTP", |
| 59 | + value = "AVAL0" |
| 60 | +) |
| 61 | +
|
| 62 | +step_outcomes <- c("Outcome I", "Outcome II", |
| 63 | + "Outcome III", "Outcome IV") |
| 64 | +
|
| 65 | +last_outcome <- "Binary outcome" |
| 66 | +
|
| 67 | +arm_levels <- c(active = "Active", |
| 68 | + control = "Control") |
| 69 | +
|
| 70 | +mar <- maraca( |
| 71 | + bin_data, step_outcomes, last_outcome, |
| 72 | + arm_levels, column_names, |
| 73 | + fixed_followup_days = 3*365, |
| 74 | + compute_win_odds = TRUE, |
| 75 | + # Important change: Add information that last endpoint is |
| 76 | + # not continuous (the default) |
| 77 | + last_type = "binary" |
| 78 | +) |
| 79 | +``` |
| 80 | + |
| 81 | +The maraca object can now be plotted. A binary endpoint is plotted |
| 82 | +as an ellipsis. The point in the middle of the ellipsis indicates the |
| 83 | +proportion that has met the binary endpoint. The width of the ellipsis |
| 84 | +(x-axis range) shows the confidence interval. |
| 85 | +Specifying `vline_type = "mean"` (the default) will add vertical lines |
| 86 | +indicating the proportions in each treatment group for easier readibility. |
| 87 | +Note that `vline_type = "median"` (the default for continuous endpoints) |
| 88 | +will result in an error. The same is true for setting `density_plot_type` to |
| 89 | +anything other than `"default"`. |
| 90 | +```{r fig.width = 7, fig.height = 6} |
| 91 | +plot(mar) |
| 92 | +``` |
| 93 | + |
| 94 | + |
| 95 | +### Step outcome |
| 96 | + |
| 97 | +What if the binary outcome is not the last outcome of the hierarchical endpoint |
| 98 | +but rather one (or several) of the previous outcomes? So rather than solely having |
| 99 | +time-to-event endpoints within the step function part of the plot, we also have |
| 100 | +at least one binary (so not time depending) variable. |
| 101 | +To include a binary variable, we expect the data for this outcome to include only |
| 102 | +patients that had the outcome and they all have to have the original analysis value 1. |
| 103 | + |
| 104 | +Let's create a dataset with 2 binary outcomes. |
| 105 | +```{r} |
| 106 | +data("hce_scenario_a") |
| 107 | +# Create data with binary version of continuous final endpoint |
| 108 | +bin_data2 <- hce_scenario_a |
| 109 | +# Index of all continuous outcome rows |
| 110 | +idx_bin <- bin_data2$GROUP %in% c("Outcome III", "Outcome IV") |
| 111 | +# Binary version (>= 0/< 0), coded as 1 |
| 112 | +bin_data2[idx_bin,"AVAL0"] <- bin_data2[idx_bin,"AVAL0"] >= 500 |
| 113 | +bin_data2[idx_bin,"AVAL"] <- bin_data2[idx_bin,"AVAL0"] + |
| 114 | + bin_data2[idx_bin,"GROUPN"] |
| 115 | +# Remove 0 rows (only include patients that had the outcome) |
| 116 | +bin_data2 <- bin_data2[bin_data2$AVAL0 != 0,] |
| 117 | +head(bin_data2) |
| 118 | +``` |
| 119 | + |
| 120 | +Again we need to slightly update the default code if we want to create a maraca object |
| 121 | +for this data. By default, maraca expects all the step outcomes to be time-to-event |
| 122 | +endpoints. In order for the function to know that there are binary outcomes, we have to |
| 123 | +update the parameter `step_types`. The parameter currently accepts the inputs `"binary"` and |
| 124 | +`"tte"`. If all the step outcomes are of the same type, the user can give the type as a string |
| 125 | +(such as by default `step_types = "tte"`). If there are different endpoint types, then the user |
| 126 | +has to provide a vector with one element for each step outcome. |
| 127 | +Similarly, the fixed-follow up time can be given as a single number or a vector. Note that the |
| 128 | +fixed-follow-up time is only needed for time-to-event endpoints, so if providing a vector then |
| 129 | +it should contain one value for each time-to-event endpoint. |
| 130 | +```{r} |
| 131 | +column_names <- c( |
| 132 | + outcome = "GROUP", |
| 133 | + arm = "TRTP", |
| 134 | + value = "AVAL0" |
| 135 | +) |
| 136 | +
|
| 137 | +step_outcomes <- c("Outcome I", "Outcome II", |
| 138 | + "Outcome III", "Outcome IV") |
| 139 | +
|
| 140 | +last_outcome <- "Continuous outcome" |
| 141 | +
|
| 142 | +arm_levels <- c(active = "Active", |
| 143 | + control = "Control") |
| 144 | +
|
| 145 | +mar <- maraca( |
| 146 | + bin_data2, step_outcomes, last_outcome, |
| 147 | + arm_levels, column_names, |
| 148 | + fixed_followup_days = 3*365, |
| 149 | + compute_win_odds = TRUE, |
| 150 | + # Important change: Add information that last endpoint is |
| 151 | + # not continuous (the default) |
| 152 | + step_types = c("tte","tte","binary","binary") |
| 153 | +) |
| 154 | +``` |
| 155 | + |
| 156 | +Again, we can plot the final object. |
| 157 | +```{r fig.width = 7, fig.height = 6} |
| 158 | +plot(mar) |
| 159 | +``` |
| 160 | + |
| 161 | + |
| 162 | +As with all maraca objects, the different plotting parameters can be |
| 163 | +used. |
| 164 | + |
| 165 | +```{r fig.width = 7, fig.height = 6} |
| 166 | +plot(mar, continuous_grid_spacing_x = 20, |
| 167 | + theme = "color1") |
| 168 | +``` |
| 169 | + |
| 170 | +Also, the win odds plots can be created as usual. |
| 171 | +```{r fig.width = 7, fig.height = 6} |
| 172 | +component_plot(mar, |
| 173 | + theme = "color2") |
| 174 | +``` |
| 175 | + |
| 176 | +```{r fig.width = 7, fig.height = 6} |
| 177 | +cumulative_plot(mar, |
| 178 | + theme = "color1") |
| 179 | +``` |
| 180 | + |
0 commit comments