Maraca Plots - Frequently Asked Questions

Martin Karpefors, Stefano Borini, Monika Huhn

2023-10-24

I get the warning “Removed 1 rows containing missing values (geom_point).” when plotting using density_plot_type scatter.

This happens because when using scatter, some points are jittered and may end up visually outside of the plotting range, so they can’t be displayed. That warning informs you (in a cryptic way) of this fact. Given that the jittering is randomised, sometimes you might get that warning, sometimes you won’t, even for the same input.

If you want to silence the warning, use suppressWarning() when you print the plot for displaying.

I want to add other information to the plot rather than win odds.

The maraca package can only display the win odds within the plot. If the user wants to for example display the win ratio instead, they need to calculate those themselves and then add them to the plot.

library(hce)

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 <- 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 = 242424)

winRatio <- calcWINS(hce_dat)$WR1

plot <- plot(hce_dat, compute_win_odds = FALSE)
plot <-
  plot  +
  ggplot2::annotate(
    geom = "label",
    x = 0,
    y = Inf,
    label = paste(
      "Win ratio: ", round(winRatio[1,"WR"], 2),
      "\n95% CI: ", round(winRatio[1,"LCL1"], 2), " - ",
      round(winRatio[1,"UCL1"], 2), "\n",
      "p-value: ", format.pval(winRatio[1,"Pvalue1"], digits = 3, eps = 0.001),
      sep = ""
    ),
    hjust = 0, vjust = 1.4, size = 3
  )

plot