attr_names <- EpiModelWHAMPDX::attr_names
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(magrittr))
suppressPackageStartupMessages(library(cowplot))
suppressPackageStartupMessages(library(ggrepel))
library(EpiModelWHAMPDX)
sim_dat <- readRDS("../../EpiModel/AE/sim_epimodel3/sim_at_2033_feb_19.rds")
  options(dplyr.summarise.inform = FALSE)

print_many_plots <- function(testing_plots, sim_dat, num_hash = 2){
  sml_temp <- paste0(c(rep("#", num_hash), " %s ", "
", " 
 "), collapse = "")
  sub_plot_info <- testing_plots
  if (is.null(sub_plot_info$plt_type)) {
    plt_type <- "line" }else{ 
      plt_type <- sub_plot_info$plt_type }
  meas_data <- make_epi_plot_data(sim_dat, sub_plot_info)
  for (ct_idx in seq(attr_names)) {
    this_cat <- names(attr_names)[ct_idx]
    targs <- EpiModelWHAMPDX::WHAMP.targs %>% 
      filter(measure == sub_plot_info$name)
    if (nrow(targs) == 0) {
      targs <- NULL
    }else{
      sub_trg <- targs %>% filter(cat == this_cat)
      if (nrow(sub_trg) == 0) {
        catgs <- EpiModelWHAMPDX::attr_names[[this_cat]]
        sub_trg <- do.call(rbind, rep(list(targs), length(catgs)))
        sub_trg$sub_cat <- catgs
        sub_trg$cat <- this_cat
      }
      targs <- sub_trg
    }
    if (this_cat == "ovr") {
      cat_meas_name <- "overall" 
    }else if (this_cat == "age.grp") {
      cat_meas_name <- "age"
    }else{
      cat_meas_name <- this_cat
    }
    cat(sprintf(sml_temp, cat_meas_name))
    print(EpiModelWHAMPDX::plot_epi(meas_data, this_cat,
                                    plot_type = plt_type, 
                                    targets = targs,
                                    year_range = c(1990, 2030)))
    cat("\n\n")
  }
}

1 Proportion of HIV- on PrEP

1.1 Construction rule

Open the first code chunk below to see the construction rule

# prop.of.neg.on.prep <- neg.prep.num / (num - i.num) 
#   (prepStats == 1 & status = 0) / (status == 0) = 
prop.prep <- list(name = "prop.prep",
                 plot_name = "Proportion of HIV- on PrEP",
                 plt_type = "line",
                 vars = c("neg.prep.num.", "num.", "i.num."),
                 sum_fun = function(x, y, z) x / (y - z))

print_many_plots(prop.prep, sim_dat)

1.2 overall

1.3 race

1.4 region

1.5 age

2 Proportion of HIV negative individuals who are PrEP indicated

2.1 Construction rule

Open the first code chunk below to see the construction rule

# prop.of.hiv.supr <- any.prep.ind / (num - i.num)   =
#   (prepIndic == 1 & status == 0)  / (status == 0)
prop.hivn.ind <- list(name = "prop.hivn.ind",
                      plot_name = "Proportion of HIV- who are PrEP indicated", 
                      plt_type = "line", 
                      vars = c("any.prep.ind.", "num.", "i.num."),
                      sum_fun = function(x, y, z) x/(y - z))
print_many_plots(prop.hivn.ind, sim_dat)

2.2 overall

2.3 race

2.4 region

2.5 age

3 Proportion of PrEP indicated on PrEP

3.1 Construction rule

Open the first code chunk below to see the construction rule

# prop.of.ind.on.prep <- on.prep.and.ind / any.prep.ind =
# (prepIndic == 1 & status == 0 & prepStat == 1) / (prepIndic == 1 & status == 0) 
prop.ind.on.prep <- list(name = "prop.ind.on.prep",
                         plot_name = "Proportion of PrEP indicated on PrEP",
                         vars = c("on.prep.and.ind.", "any.prep.ind."),
                         sum_fun = function(x, y) x / y,
                         plt_type = "line")

print_many_plots(prop.ind.on.prep, sim_dat)

3.2 overall

3.3 race

3.4 region

3.5 age