component_plot: Plotting components of win odds

View source: R/winOddsPlots.R

component_plotR Documentation

Plotting components of win odds

Description

Generic function to create a plot showing the components used in calculating win odds (wins and ties) separately for each outcome. Implemented for objects of type 'maraca' and 'hce.

Usage

component_plot(x, ...)

## Default S3 method:
component_plot(x, ...)

## S3 method for class 'maraca'
component_plot(x, theme = "maraca", ...)

## S3 method for class 'adhce'
component_plot(
  x,
  step_outcomes = NULL,
  last_outcome = "C",
  arm_levels = c(active = "A", control = "P"),
  theme = "maraca",
  lowerBetter = FALSE,
  ...
)

Arguments

x

an object of S3 class 'maraca' or 'adhce'.

...

not used

theme

Choose theme to style the plot. The default theme is "maraca". Options are "maraca", "color1", "color2" and none". For more details, check the vignette called "Maraca Plots - Plotting win odds".

step_outcomes

A vector of strings containing the outcome labels for all outcomes displayed as part of the step function on the left side of the plot. The order is kept for the plot. By default (when set to NULL) this is automatically updated by taking the non-continuous outcomes from the GROUP variable in alphabetical order.

last_outcome

A single string containing the last outcome label displayed on the right side of the plot. Default value "C".

arm_levels

A named vector of exactly two strings, mapping the values used for the active and control arms to the values used in the data. The names must be "active" and "control" in this order. Note that this parameter only need to be specified if you have labels different from "active" and "control".

lowerBetter

Flag for the final outcome variable, indicating if lower values are considered better/advantageous. This flag is need to make sure the win odds are calculated correctly. Default value is FALSE, meaning higher values are considered advantageous.

Details

Note that for this plot, if applying to a maraca object, in the original maraca() function run the argument "compute_win_odds" has to be set to TRUE.

Check the vignette "Maraca Plots - Plotting win odds" for more details.

Value

Component plot as a ggplot2 object.

Examples


data(hce_scenario_a)

maraca_dat <- maraca(data = hce_scenario_a,
                     step_outcomes = c("Outcome I", "Outcome II",
                                      "Outcome III", "Outcome IV"),
                     last_outcome = "Continuous outcome",
                     fixed_followup_days = 3 * 365,
                     column_names = c(outcome = "GROUP",
                                      arm = "TRTP",
                                      value = "AVAL0"),
                     arm_levels = c(active = "Active",
                                    control = "Control"),
                     compute_win_odds = TRUE
                     )

component_plot(maraca_dat)

Rates_A <- c(1.72, 1.74, 0.58, 1.5, 1)
Rates_P <- c(2.47, 2.24, 2.9, 4, 6)
hce_dat <- hce::simHCE(n = 2500, TTE_A = Rates_A, TTE_P = Rates_P,
             CM_A = -3, CM_P = -6, CSD_A = 16, CSD_P = 15, fixedfy = 3,
             seed = 31337)

component_plot(hce_dat)


maraca documentation built on Nov. 21, 2025, 1:07 a.m.