Reproduce Figure 5

This is run in a separate script from the other figures due to issues with RStudio crashing when all scenarios were run from a single script.

Currently depends on simmer.plot() function that doesn’t work on the imported results from the csv file, so need to allow to run model to produce this plot! Hence, you will only see results if run <- TRUE. Ordinarily, we leave as FALSE so that quarto site is still built quickly.

Run time: 6.165 minutes (will vary between machines)

Set up

# Clear environment
rm(list=ls())

# Start timer
start.time <- Sys.time()

# Disable scientific notation
options(scipen=999)

# Get the model and helper functions (but hide loading warnings for each package)
suppressMessages(source("model.R"))
suppressMessages(source("helpers.R"))
# Set the seed and default dimensions for figures
SEED = 200

# Set file paths to save results
folder = "../outputs"
path_fig5 <- file.path(folder, "fig5.png")

Run models

run <- FALSE
if (isTRUE(run)) {
  baseline_f5 <- run_model(seed = SEED, fig5=TRUE)
  exclusive_f5 <- run_model(exclusive_use = TRUE, seed = SEED, fig5=TRUE)
  twoangio_f5 <- run_model(angio_inr = 2, angio_ir=0, seed = SEED, fig5=TRUE)
}

Create figure

if (isTRUE(run)) {
  # Replace resource (which has been filtered to angioINR) with scenario
  baseline_f5$resource <- "Baseline"
  exclusive_f5$resource <-"Exclusive-use"
  twoangio_f5$resource <- "Two angio INRs"
  
  # Combine into single object
  fig5_df <- dplyr::bind_rows(baseline_f5, exclusive_f5, twoangio_f5)
  
  # Create figure using simmer's plot
  p <- plot(fig5_df, metric="utilization") +
    xlab("Scenarios") +
    ylab("Utilisation") +
    scale_y_continuous(labels = scales::percent, limits=c(0, 0.4)) +
    ggtitle("") +
    geom_text(aes(label=round(.data$Q50*100)), vjust=-1)
  p
  
  # Save to provided path
  ggsave(path_fig5, width=5, height=2.5)
}

Time elapsed

if (isTRUE(run)) {
  end.time <- Sys.time()
  elapsed.time <- round((end.time - start.time), 3)
  elapsed.time
}