diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index b4ddd76..24aef03 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 2.0.0 -Date: 2026-03-19 19:14:10 UTC -SHA: 4795478e0caef4ec96b0827d2c20fa4275bcf2f3 +Version: 2.1.0 +Date: 2026-03-26 20:54:41 UTC +SHA: fc4bbc0e1097dc775fc299d3ef53cc42dbc163a6 diff --git a/DESCRIPTION b/DESCRIPTION index 6de3a16..c8210df 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: MetaRVM Title: Meta-Population Compartmental Model for Respiratory Virus Diseases -Version: 2.0.0 +Version: 2.1.0 Authors@R: c( person("Arindam", "Fadikar", , "afadikar@anl.gov", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0001-7396-0350")), person("Charles", "Macal", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 9c23cdc..c0d2aea 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,33 @@ +# MetaRVM 2.1.0 + +* Added `simulation_mode` (`deterministic`/`stochastic`) and `nrep` support in + configuration parsing and run metadata. + +* Improved stochastic reproducibility: provided `random_seed` is honored, and a + seed is generated/stored when missing. + +* Updated stochastic transition splitting to use binomial draws for integer + compartment flows (`n_EIpresymp`, `n_IsympH`, `n_HR`). + +* Improved metapopulation infection-flow indexing consistency for destination- + specific force of infection in `n_SE_eff` and `n_VE_eff`. + +* Added bounded vaccination and transition safeguards to reduce overdraw risks + (for example, capping applied vaccination by available susceptible count and + guarding zero effective population in force-of-infection calculations). + +* Added integer row allocation for stochastic mixing flows (`S` and `V`) using + floor-plus-residual adjustment so row totals are conserved. + +* Added regression tests for stochastic seed behavior, `nsim * nrep` instance + counts, and row-allocation conservation checks for `S`/`V` mixing. + +* Enhanced results helper APIs: + - `MetaRVMResults$plot()` now provides direct trajectory plotting before + summarization. + - `MetaRVMSummary$plot()` now supports instance-trajectory plotting. + - `summarize()` uses a more efficient single-pass grouped aggregation. + # MetaRVM 2.0.0 * Subpopulation categories are now user-defined from diff --git a/R/classes.R b/R/classes.R index 9667639..2a9504a 100644 --- a/R/classes.R +++ b/R/classes.R @@ -342,11 +342,57 @@ MetaRVMResults <- R6::R6Class( cat("Instances:", self$run_info$n_instances, "\n") cat("Populations:", self$run_info$n_populations, "\n") cat("Date range:", paste(self$run_info$date_range, collapse = " to "), "\n") + if (!is.null(self$run_info$nsim)) { + cat("Parameter sets (nsim):", self$run_info$nsim, "\n") + } + if (!is.null(self$run_info$nrep)) { + cat("Replicates per set (nrep):", self$run_info$nrep, "\n") + } + if (!is.null(self$run_info$simulation_mode)) { + cat("Simulation mode:", self$run_info$simulation_mode, "\n") + } + if (!is.null(self$run_info$random_seed)) { + cat("Random seed:", self$run_info$random_seed, "\n") + } cat("Total observations:", nrow(self$results), "\n") cat("Disease states:", paste(unique(self$results$disease_state), collapse = ", "), "\n") invisible(self) }, + #' @description Plot simulation trajectories directly from results + #' @param group_by Vector of demographic category names to group/facet by + #' @param disease_states Optional disease states to include + #' @param date_range Optional date range for filtering + #' @param instances Optional instance IDs to include + #' @param stats Statistics for summary plotting. If NULL, plots raw trajectories. + #' @param quantiles Quantiles for uncertainty bands when summary plotting + #' @param exclude_p_columns Logical, whether to exclude p_ columns (default: TRUE) + #' @param ci_level Confidence level label used in summary plot title + #' @param theme ggplot2 theme function (default: theme_minimal()) + #' @param title Optional custom title + #' @return ggplot object + plot = function(group_by = character(0), disease_states = NULL, date_range = NULL, + instances = NULL, stats = NULL, quantiles = c(0.25, 0.75), + exclude_p_columns = TRUE, ci_level = 0.95, + theme = theme_minimal(), title = NULL) { + + plot_data <- self$subset_data( + disease_states = disease_states, + date_range = date_range, + instances = instances, + exclude_p_columns = exclude_p_columns + ) + + summary_obj <- plot_data$summarize( + group_by = group_by, + stats = stats, + quantiles = quantiles, + exclude_p_columns = FALSE + ) + + summary_obj$plot(ci_level = ci_level, theme = theme, title = title) + }, + #' @description Subset the data based on any combination of parameters #' @param ... Named arguments for category filters (e.g., age = c("0-17"), income = c("low", "high")) #' @param disease_states Vector of disease states to include (default: all, excludes p_ columns) @@ -435,6 +481,13 @@ MetaRVMResults <- R6::R6Class( new_run_info <- list( created_at = Sys.time(), original_created_at = self$run_info$created_at, + N_pop = self$run_info$N_pop, + nsim = self$run_info$nsim, + nrep = self$run_info$nrep, + simulation_mode = self$run_info$simulation_mode, + random_seed = self$run_info$random_seed, + delta_t = self$run_info$delta_t, + checkpointing_enabled = self$run_info$checkpointing_enabled, n_instances = length(unique(subset_results$instance)), n_populations = private$calculate_n_populations(subset_results), date_range = if(nrow(subset_results) > 0) range(subset_results$date, na.rm = TRUE) else c(NA, NA), @@ -510,60 +563,45 @@ MetaRVMResults <- R6::R6Class( # Step 3: Calculate statistics across instances for each date/demographic/disease combination final_group_vars <- c("date", group_by, "disease_state") - - # Start with empty result - summary_result <- summed_data[, .(temp = mean(value)), by = final_group_vars][, temp := NULL] - - # Add each statistic individually - if ("mean" %in% stats) { - temp_mean <- summed_data[, .(mean_value = mean(value, na.rm = TRUE)), by = final_group_vars] - summary_result <- merge(summary_result, temp_mean, by = final_group_vars, all = TRUE) - } - - if ("median" %in% stats) { - temp_median <- summed_data[, .(median_value = median(value, na.rm = TRUE)), by = final_group_vars] - summary_result <- merge(summary_result, temp_median, by = final_group_vars, all = TRUE) - } - - if ("sd" %in% stats) { - temp_sd <- summed_data[, .(sd_value = sd(value, na.rm = TRUE)), by = final_group_vars] - summary_result <- merge(summary_result, temp_sd, by = final_group_vars, all = TRUE) - } - - if ("min" %in% stats) { - temp_min <- summed_data[, .(min_value = min(value, na.rm = TRUE)), by = final_group_vars] - summary_result <- merge(summary_result, temp_min, by = final_group_vars, all = TRUE) - } - - if ("max" %in% stats) { - temp_max <- summed_data[, .(max_value = max(value, na.rm = TRUE)), by = final_group_vars] - summary_result <- merge(summary_result, temp_max, by = final_group_vars, all = TRUE) - } - - if ("sum" %in% stats) { - temp_sum <- summed_data[, .(sum_value = sum(value, na.rm = TRUE)), by = final_group_vars] - summary_result <- merge(summary_result, temp_sum, by = final_group_vars, all = TRUE) - } - - # Handle quantiles - if ("quantile" %in% stats) { - for (q in quantiles) { - q_name <- paste0("q", sprintf("%02d", round(q * 100))) - temp_q <- summed_data[, .(temp_quantile = quantile(value, q, na.rm = TRUE)), by = final_group_vars] - setnames(temp_q, "temp_quantile", q_name) - summary_result <- merge(summary_result, temp_q, by = final_group_vars, all = TRUE) + summary_result <- summed_data[, { + out <- list() + + if ("mean" %in% stats) { + out$mean_value <- mean(value, na.rm = TRUE) } - } - - # Sort results for better readability - setorder(summary_result, date) + if ("median" %in% stats) { + out$median_value <- median(value, na.rm = TRUE) + } + if ("sd" %in% stats) { + out$sd_value <- stats::sd(value, na.rm = TRUE) + } + if ("min" %in% stats) { + out$min_value <- min(value, na.rm = TRUE) + } + if ("max" %in% stats) { + out$max_value <- max(value, na.rm = TRUE) + } + if ("sum" %in% stats) { + out$sum_value <- sum(value, na.rm = TRUE) + } + if ("quantile" %in% stats) { + for (q in quantiles) { + q_name <- paste0("q", sprintf("%02d", round(q * 100))) + out[[q_name]] <- stats::quantile(value, probs = q, na.rm = TRUE, names = FALSE) + } + } + + out + }, by = final_group_vars] # return(summary_result) # Return a chainable object if (is.null(stats)) { + setorder(summed_data, date, disease_state, instance) # Return summary object for chaining return(MetaRVMSummary$new(summed_data, self$config, type = "instances")) } else { + setorderv(summary_result, c("date", group_by, "disease_state")) # Return summary object for chaining return(MetaRVMSummary$new(summary_result, self$config, type = "summary")) } @@ -766,18 +804,7 @@ MetaRVMSummary <- R6::R6Class( plot = function(ci_level = 0.95, theme = theme_minimal(), title = NULL) { columns <- names(self$data) - - # Check if we have the required columns for plotting - if (!("median_value" %in% columns)) { - stop("Plot method requires 'median_value' column. Please call summarize() first with stats = c('median', 'quantile')") - } - - # Check for quantile columns - quantile_cols <- grep("^q[0-9]", columns, value = TRUE) - if (length(quantile_cols) < 2) { - stop("Plot method requires quantile columns for confidence bands. Please call summarize() with stats = c('median', 'quantile')") - } - + # Detect grouping variables dynamically available_categories <- self$config$get_category_names() group_vars <- if (length(available_categories) > 0) { @@ -786,12 +813,53 @@ MetaRVMSummary <- R6::R6Class( character(0) } - if (length(group_vars) == 0) { - stop("Data must be grouped by at least one demographic variable") + # Instance trajectory plotting mode + if (identical(self$type, "instances")) { + color_var <- if ("disease_state" %in% columns) "disease_state" else "instance" + + p <- ggplot(self$data, aes(x = date, y = value, + color = .data[[color_var]], + group = interaction(.data[["instance"]], .data[[color_var]], drop = TRUE))) + + geom_line(alpha = 0.45, linewidth = 0.5) + + if (length(group_vars) == 1) { + p <- p + facet_wrap(stats::as.formula(paste("~", group_vars[1])), scales = "free_y") + } else if (length(group_vars) >= 2) { + p <- p + facet_grid(stats::as.formula(paste(group_vars[1], "~", group_vars[2])), scales = "free_y") + } + + p <- p + + labs( + title = title %||% "Simulation Trajectories", + x = "Date", + y = "Value", + color = tools::toTitleCase(gsub("_", " ", color_var)) + ) + + theme + + theme(axis.text.x = element_text(angle = 45, hjust = 1)) + + return(p) + } + + # Check if we have the required columns for plotting + if (!("median_value" %in% columns)) { + stop("Plot method requires 'median_value' column. Please call summarize() first with stats = c('median', 'quantile')") + } + + # Check for quantile columns + quantile_cols <- grep("^q[0-9]+$", columns, value = TRUE) + quantile_levels <- suppressWarnings(as.numeric(sub("^q", "", quantile_cols))) + valid_q_idx <- which(!is.na(quantile_levels)) + if (length(valid_q_idx) < 2) { + stop("Plot method requires quantile columns for confidence bands. Please call summarize() with stats = c('median', 'quantile')") } + quantile_cols <- quantile_cols[valid_q_idx][order(quantile_levels[valid_q_idx])] # Create faceting strategy based on number of grouping variables - if (length(group_vars) == 1) { + if (length(group_vars) == 0) { + facet_formula <- NULL + color_var <- "disease_state" + } else if (length(group_vars) == 1) { # Single grouping variable: facet by that variable, color by disease_state facet_formula <- as.formula(paste("~", group_vars[1])) color_var <- "disease_state" @@ -808,16 +876,15 @@ MetaRVMSummary <- R6::R6Class( color_var <- group_vars[3] } - # Use first and last quantile columns for confidence bands + # Use lowest and highest quantile columns for confidence bands ci_lower_col <- quantile_cols[1] ci_upper_col <- quantile_cols[length(quantile_cols)] # Create the plot - p <- ggplot(self$data, aes(x = date, y = median_value, color = get(color_var))) + + p <- ggplot(self$data, aes(x = date, y = median_value, color = .data[[color_var]])) + geom_line(linewidth = 1) + - geom_ribbon(aes(ymin = get(ci_lower_col), ymax = get(ci_upper_col), - fill = get(color_var)), alpha = 0.2, color = NA) + - facet_grid(facet_formula, scales = "free_y") + + geom_ribbon(aes(ymin = .data[[ci_lower_col]], ymax = .data[[ci_upper_col]], + fill = .data[[color_var]]), alpha = 0.2, color = NA) + labs( title = title %||% paste0("Median Outcomes with ", ci_level*100, "% Empirical Quantiles"), x = "Date", @@ -827,6 +894,10 @@ MetaRVMSummary <- R6::R6Class( ) + theme + theme(axis.text.x = element_text(angle = 45, hjust = 1)) + + if (!is.null(facet_formula)) { + p <- p + facet_grid(facet_formula, scales = "free_y") + } return(p) } diff --git a/R/metaODIN.R b/R/metaODIN.R index 6cdc634..dc835d6 100644 --- a/R/metaODIN.R +++ b/R/metaODIN.R @@ -308,7 +308,7 @@ meta_sim <- function(N_pop, ts, dim(vac) <- user() # n_SV_eff[] <- n_SV[i] * vac_eff[i] - n_SV_eff[] <- n_SV[i] * 1 # all vaccinated people are moved to V + n_SV_eff[] <- if(n_SV[i] < 0) 0 else (if(n_SV[i] > S[i]) S[i] else n_SV[i]) # bounded by available S ## ================================================= # time/day specific mobility matrix @@ -334,37 +334,53 @@ meta_sim <- function(N_pop, ts, # first remove vaccinated people from S S_eff_prod[, ] <- m[i, j] * (S[i] - n_SV_eff[i]) - V_eff_prod[, ] <- m[i, j] * V[i] + S_src_int[] <- if((S[i] - n_SV_eff[i]) <= 0) 0 else floor(S[i] - n_SV_eff[i]) + S_target[, ] <- m[i, j] * S_src_int[i] + S_base[, ] <- floor(S_target[i, j]) + S_resid[] <- S_src_int[i] - sum(S_base[i, ]) + S_alloc[, ] <- if(j == N_pop) S_base[i, j] + S_resid[i] else S_base[i, j] + + V_src_int[] <- if(V[i] <= 0) 0 else floor(V[i]) + V_target[, ] <- m[i, j] * V_src_int[i] + V_base[, ] <- floor(V_target[i, j]) + V_resid[] <- V_src_int[i] - sum(V_base[i, ]) + V_alloc[, ] <- if(j == N_pop) V_base[i, j] + V_resid[i] else V_base[i, j] I_eff_prod[, ] <- m[i, j] * I_all[i] I_eff[] <- sum(I_eff_prod[, i]) # colSums ## ================================================= ## Force of infection - lambda_i[] <- beta_i[i] * I_eff[i] / P_eff[i] - lambda_v[] <- beta_i[i] * (1 - vac_eff[i]) * I_eff[i] / P_eff[i] + lambda_i[] <- if(P_eff[i] <= 0) 0 else beta_i[i] * I_eff[i] / P_eff[i] + lambda_v[] <- if(P_eff[i] <= 0) 0 else beta_i[i] * (1 - vac_eff[i]) * I_eff[i] / P_eff[i] ## ================================================= ## Draws from binomial distributions for numbers changing between ## compartments: - n_SE_eff[, ] <- if(S[i] <= 0) 0 else (if(stoch == 1) rbinom(S_eff_prod[j, i], p_SE[i]) else S_eff_prod[j, i] * p_SE[i]) - n_SE[] <- sum(n_SE_eff[i, ]) # rowSums + n_SE_eff[, ] <- if((S[i] - n_SV_eff[i]) <= 0) 0 else ( + if(stoch == 1) rbinom(S_alloc[i, j], p_SE[j]) else S_eff_prod[i, j] * p_SE[j] + ) + n_SE[] <- sum(n_SE_eff[i, ]) # sum over destinations for each origin i n_EI[] <- if(E[i] == 0) 0 else (if(stoch == 1) rbinom(E[i], p_EIpresymp[i]) else E[i] * p_EIpresymp[i]) - n_EIpresymp[] <- n_EI[i] * (1 - pea[i]) + n_EIpresymp[] <- if(stoch == 1) rbinom(n_EI[i], 1 - pea[i]) else n_EI[i] * (1 - pea[i]) n_EIasymp[] <- n_EI[i] - n_EIpresymp[i] n_preIsymp[] <- if(I_presymp[i] == 0) 0 else (if(stoch == 1) rbinom(I_presymp[i], p_preIsymp[i]) else I_presymp[i] * p_preIsymp[i]) n_IasympR[] <- if(I_asymp[i] == 0) 0 else (if(stoch == 1) rbinom(I_asymp[i], p_IasympR[i]) else I_asymp[i] * p_IasympR[i]) n_IsympRH[] <- if(I_symp[i] == 0) 0 else (if(stoch == 1) rbinom(I_symp[i], p_IsympRH[i]) else I_symp[i] * p_IsympRH[i]) - n_IsympH[] <- n_IsympRH[i] * (1 - psr[i]) + n_IsympH[] <- if(stoch == 1) rbinom(n_IsympRH[i], 1 - psr[i]) else n_IsympRH[i] * (1 - psr[i]) n_IsympR[] <- n_IsympRH[i] - n_IsympH[i] n_HRD[] <- if(H[i] == 0) 0 else (if(stoch == 1) rbinom(H[i], p_HRD[i]) else H[i] * p_HRD[i]) - n_HR[] <- n_HRD[i] * phr[i] + n_HR[] <- if(stoch == 1) rbinom(n_HRD[i], phr[i]) else n_HRD[i] * phr[i] n_HD[] <- n_HRD[i] - n_HR[i] n_RS[] <- if(R[i] == 0) 0 else (if(stoch == 1) rbinom(R[i], p_RS[i]) else R[i] * p_RS[i]) - n_VE_eff[, ] <- if(stoch == 1) rbinom(V_eff_prod[j, i], p_VE[i]) else V_eff_prod[j, i] * p_VE[i] + n_VE_eff[, ] <- if(V[i] <= 0) 0 else ( + if(stoch == 1) rbinom(V_alloc[i, j], p_VE[j]) else V_eff_prod[i, j] * p_VE[j] + ) n_VE[] <- sum(n_VE_eff[i, ]) # rowSums - n_VS[] <- if(stoch == 1) rbinom(V[i] - n_VE[i], p_VS[i]) else (V[i] - n_VE[i]) * p_VS[i] + n_VS[] <- if((V[i] - n_VE[i]) <= 0) 0 else ( + if(stoch == 1) rbinom(V[i] - n_VE[i], p_VS[i]) else (V[i] - n_VE[i]) * p_VS[i] + ) ## ================================================= ## Initial states: @@ -387,6 +403,7 @@ meta_sim <- function(N_pop, ts, output(p_SE) <- TRUE output(p_VE) <- TRUE output(p_HRD) <- TRUE + output(p_RS) <- TRUE output(I_eff) <- TRUE output(n_SE) <- TRUE output(n_SV) <- TRUE @@ -402,6 +419,14 @@ meta_sim <- function(N_pop, ts, output(n_HR) <- TRUE output(n_HD) <- TRUE output(n_IasympR) <- TRUE + output(n_RS) <- TRUE + + output(n_SE_eff) <- TRUE + output(S_eff_prod) <- TRUE + output(S_src_int) <- TRUE + output(S_alloc) <- TRUE + output(V_src_int) <- TRUE + output(V_alloc) <- TRUE ## ================================================= @@ -500,6 +525,16 @@ meta_sim <- function(N_pop, ts, dim(n_SV_eff) <- N_pop dim(n_SE_eff) <- c(N_pop, N_pop) dim(n_VE_eff) <- c(N_pop, N_pop) + dim(S_src_int) <- N_pop + dim(S_target) <- c(N_pop, N_pop) + dim(S_base) <- c(N_pop, N_pop) + dim(S_resid) <- N_pop + dim(S_alloc) <- c(N_pop, N_pop) + dim(V_src_int) <- N_pop + dim(V_target) <- c(N_pop, N_pop) + dim(V_base) <- c(N_pop, N_pop) + dim(V_resid) <- N_pop + dim(V_alloc) <- c(N_pop, N_pop) dim(lambda_i) <- N_pop dim(lambda_v) <- N_pop diff --git a/R/metaRVM.R b/R/metaRVM.R index 19c68f7..d08f3d0 100644 --- a/R/metaRVM.R +++ b/R/metaRVM.R @@ -114,6 +114,34 @@ metaRVM <- function(config_input) { # pass inputs to meta_sim nsim <- config_obj$config_data$nsim + nrep <- if ("nrep" %in% names(config_obj$config_data)) { + as.integer(config_obj$config_data$nrep) + } else { + 1L + } + if (is.na(nrep) || nrep < 1) { + stop("nrep must be a positive integer") + } + simulation_mode <- if ("simulation_mode" %in% names(config_obj$config_data)) { + config_obj$config_data$simulation_mode + } else { + "deterministic" + } + is_stoch <- identical(tolower(as.character(simulation_mode)), "stochastic") + run_seed_base <- NA_integer_ + if (is_stoch) { + run_seed <- config_obj$config_data$random_seed + if (is.null(run_seed)) { + run_seed <- sample.int(.Machine$integer.max, 1) + } else { + run_seed <- suppressWarnings(as.integer(run_seed)[1]) + if (is.na(run_seed)) { + stop("random_seed must be coercible to a single integer value") + } + } + config_obj$config_data$random_seed <- run_seed + run_seed_base <- run_seed + } nsteps <- floor(config_obj$config_data$sim_length / config_obj$config_data$delta_t) day_name <- weekdays(config_obj$config_data$start_date) start_day <- dplyr::case_when( @@ -128,51 +156,75 @@ metaRVM <- function(config_input) { ) out <- data.table::data.table() + run_idx <- 0L for (ii in 1:nsim){ + for (rr in 1:nrep){ + run_idx <- run_idx + 1L + if (is_stoch) { + set.seed(run_seed_base + run_idx - 1L) + } - o <- meta_sim(is.stoch = 0, - nsteps = nsteps, - N_pop = config_obj$config_data$N_pop, - S0 = config_obj$config_data$S_ini, - I0 = config_obj$config_data$I_symp_ini, - P0 = config_obj$config_data$P_ini, - V0 = config_obj$config_data$V_ini, - R0 = config_obj$config_data$R_ini, - H0 = config_obj$config_data$H_ini, - D0 = config_obj$config_data$D_ini, - E0 = config_obj$config_data$E_ini, - Ia0 = config_obj$config_data$I_asymp_ini, - Ip0 = config_obj$config_data$I_presymp_ini, - m_weekday_day = config_obj$config_data$m_wd_d, - m_weekday_night = config_obj$config_data$m_wd_n, - m_weekend_day = config_obj$config_data$m_we_d, - m_weekend_night = config_obj$config_data$m_we_n, - start_day = start_day, - delta_t = config_obj$config_data$delta_t, - vac_mat = config_obj$config_data$vac_mat, - ts = config_obj$config_data$ts[ii, ], - dv = config_obj$config_data$dv[ii, ], - de = config_obj$config_data$de[ii, ], - pea = config_obj$config_data$pea[ii, ], - dp = config_obj$config_data$dp[ii, ], - da = config_obj$config_data$da[ii, ], - ds = config_obj$config_data$ds[ii, ], - psr = config_obj$config_data$psr[ii, ], - dh = config_obj$config_data$dh[ii, ], - phr = config_obj$config_data$phr[ii, ], - dr = config_obj$config_data$dr[ii, ], - ve = config_obj$config_data$ve[ii, ], - do_chk = config_obj$config_data$do_chk, - chk_time_steps = config_obj$config_data$chk_time_steps, - chk_file_names = config_obj$config_data$chk_file_names[ii, ]) + o <- meta_sim(is.stoch = is_stoch, + nsteps = nsteps, + N_pop = config_obj$config_data$N_pop, + S0 = config_obj$config_data$S_ini, + I0 = config_obj$config_data$I_symp_ini, + P0 = config_obj$config_data$P_ini, + V0 = config_obj$config_data$V_ini, + R0 = config_obj$config_data$R_ini, + H0 = config_obj$config_data$H_ini, + D0 = config_obj$config_data$D_ini, + E0 = config_obj$config_data$E_ini, + Ia0 = config_obj$config_data$I_asymp_ini, + Ip0 = config_obj$config_data$I_presymp_ini, + m_weekday_day = config_obj$config_data$m_wd_d, + m_weekday_night = config_obj$config_data$m_wd_n, + m_weekend_day = config_obj$config_data$m_we_d, + m_weekend_night = config_obj$config_data$m_we_n, + start_day = start_day, + delta_t = config_obj$config_data$delta_t, + vac_mat = config_obj$config_data$vac_mat, + ts = config_obj$config_data$ts[ii, ], + dv = config_obj$config_data$dv[ii, ], + de = config_obj$config_data$de[ii, ], + pea = config_obj$config_data$pea[ii, ], + dp = config_obj$config_data$dp[ii, ], + da = config_obj$config_data$da[ii, ], + ds = config_obj$config_data$ds[ii, ], + psr = config_obj$config_data$psr[ii, ], + dh = config_obj$config_data$dh[ii, ], + phr = config_obj$config_data$phr[ii, ], + dr = config_obj$config_data$dr[ii, ], + ve = config_obj$config_data$ve[ii, ], + do_chk = config_obj$config_data$do_chk, + chk_time_steps = config_obj$config_data$chk_time_steps, + chk_file_names = config_obj$config_data$chk_file_names[run_idx, ]) - o$instance <- ii - out <- rbind(out, o) + o$instance <- run_idx + out <- rbind(out, o) + } } - + run_info <- list( + created_at = Sys.time(), + N_pop = config_obj$config_data$N_pop, + nsim = nsim, + nrep = nrep, + n_instances = nsim * nrep, + simulation_mode = simulation_mode, + random_seed = config_obj$config_data$random_seed, + delta_t = config_obj$config_data$delta_t, + date_range = if (nrow(out) > 0) { + c(config_obj$config_data$start_date + 1, + config_obj$config_data$start_date + floor(config_obj$config_data$sim_length)) + } else { + c(NA, NA) + }, + checkpointing_enabled = isTRUE(config_obj$config_data$do_chk) + ) + # Create and return MetaRVMResults object - results_obj <- MetaRVMResults$new(out, config_obj) + results_obj <- MetaRVMResults$new(out, config_obj, run_info = run_info) return(results_obj) # return(out) } diff --git a/R/parse_config.R b/R/parse_config.R index bb9f688..55c8f23 100644 --- a/R/parse_config.R +++ b/R/parse_config.R @@ -19,6 +19,9 @@ #' \itemize{ #' \item \code{random_seed}: Optional random seed for reproducibility in case of stochastic simulations or stochastic parameters #' \item \code{nsim}: Number of simulation instances (default: 1) +#' \item \code{nrep}: Number of stochastic replicates per parameter set (default: 1) +#' \item \code{simulation_mode}: Optional simulation mode. Must be one of +#' \code{"deterministic"} or \code{"stochastic"} (default: \code{"deterministic"}). #' \item \code{start_date}: Simulation start date in MM/DD/YYYY format #' \item \code{length}: Simulation length in days #' \item \code{checkpoint_dir}: Optional checkpoint directory for saving intermediate results @@ -72,6 +75,8 @@ #' \item{start_date}{Simulation start date as Date object} #' \item{sim_length}{Simulation length in days} #' \item{nsim}{Number of simulation instances} +#' \item{nrep}{Number of stochastic replicates per parameter set} +#' \item{simulation_mode}{Simulation mode: \code{"deterministic"} or \code{"stochastic"}} #' \item{random_seed}{Random seed used (if any)} #' \item{delta_t}{Time step size (fixed at 0.5)} #' \item{chk_file_names, chk_time_steps, do_chk}{Checkpointing configuration} @@ -142,14 +147,6 @@ parse_config <- function(config_file, return_object = FALSE){ setwd(yaml_file_path) on.exit(setwd(old_wd)) - # check random seed - if(!is.null(yaml_data$simulation_config$random_seed)){ - random_seed <- yaml_data$simulation_config$random_seed - set.seed(random_seed) - } else { - random_seed <- NULL - } - # ===================================================== # read mandatory parameters is_restore <- !is.null(yaml_data$simulation_config$restore_from) @@ -169,6 +166,43 @@ parse_config <- function(config_file, return_object = FALSE){ sim_length <- yaml_data$simulation_config$length nsim <- ifelse(!is.null(yaml_data$simulation_config$nsim), yaml_data$simulation_config$nsim, 1) + nrep <- ifelse(!is.null(yaml_data$simulation_config$nrep), + yaml_data$simulation_config$nrep, 1) + nrep <- suppressWarnings(as.integer(nrep)[1]) + if (is.na(nrep) || nrep < 1) { + setwd(old_wd) + stop("nrep must be a positive integer") + } + simulation_mode <- "deterministic" + if (!is.null(yaml_data$simulation_config$simulation_mode)) { + simulation_mode <- tolower(trimws(as.character(yaml_data$simulation_config$simulation_mode))) + } else if (!is.null(yaml_data$simulation_config$is_stoch)) { + is_stoch <- yaml_data$simulation_config$is_stoch + simulation_mode <- if (isTRUE(is_stoch) || (is.numeric(is_stoch) && is_stoch != 0)) { + "stochastic" + } else { + "deterministic" + } + } + if (!simulation_mode %in% c("deterministic", "stochastic")) { + setwd(old_wd) + stop("simulation_mode must be either 'deterministic' or 'stochastic'") + } + + # check random seed + if(!is.null(yaml_data$simulation_config$random_seed)){ + random_seed <- suppressWarnings(as.integer(yaml_data$simulation_config$random_seed)[1]) + if (is.na(random_seed)) { + setwd(old_wd) + stop("random_seed must be coercible to a single integer value") + } + set.seed(random_seed) + } else if (simulation_mode == "stochastic") { + random_seed <- sample.int(.Machine$integer.max, 1) + set.seed(random_seed) + } else { + random_seed <- NULL + } chk_time_steps <- NULL chk_file_names <- NULL @@ -192,7 +226,7 @@ parse_config <- function(config_file, return_object = FALSE){ # Generate a matrix of file names: rows for instances, columns for dates chk_file_names <- sapply(chk_dates, function(date) { date_str <- format(date, "%Y-%m-%d") - paste0(checkpoint_dir, "/checkpoint_", date_str, "_instance_", 1:nsim, ".Rda") + paste0(checkpoint_dir, "/checkpoint_", date_str, "_instance_", 1:(nsim * nrep), ".Rda") }) if (is.vector(chk_file_names)) { chk_file_names <- matrix(chk_file_names, ncol = 1) @@ -207,7 +241,7 @@ parse_config <- function(config_file, return_object = FALSE){ chk_time_steps <- as.integer(sim_length / delta_t) # Create a 1-column matrix for the single checkpoint date - chk_file_names <- matrix(paste0(checkpoint_dir, "/chk_", date_str, "_", 1:nsim, ".Rda"), ncol = 1) + chk_file_names <- matrix(paste0(checkpoint_dir, "/chk_", date_str, "_", 1:(nsim * nrep), ".Rda"), ncol = 1) } } @@ -576,6 +610,8 @@ parse_config <- function(config_file, return_object = FALSE){ start_date = start_date, sim_length = sim_length, nsim = nsim, + nrep = nrep, + simulation_mode = simulation_mode, random_seed = random_seed, delta_t = delta_t, chk_file_names = chk_file_names, diff --git a/README.Rmd b/README.Rmd index 37f70b0..4469882 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,6 +18,10 @@ knitr::opts_chunk$set( ``` +[](https://github.com/RESUME-Epi/MetaRVM/actions/workflows/R-CMD-check.yaml) +[](https://app.codecov.io/gh/RESUME-Epi/MetaRVM) +[](https://lifecycle.r-lib.org/articles/stages.html) +[](https://RESUME-Epi.github.io/MetaRVM/) [](https://CRAN.R-project.org/package=MetaRVM) [](https://cran.r-project.org/package=MetaRVM) @@ -88,6 +92,9 @@ simulation_config: start_date: 10/01/2023 # m/d/Y length: 150 nsim: 1 + nrep: 1 + simulation_mode: deterministic + random_seed: 42 ``` @@ -123,6 +130,13 @@ At the start of a simulation, nearly all individuals are in `S`, with optional s Transmission is stratified by user-defined demographic groups (e.g., age, zone, race). Time-varying mixing matrices define how these strata interact (daytime vs. nighttime, weekday vs. weekend), and `MetaRVM` computes stratum-specific forces of infection for susceptible and vaccinated individuals. Hospitalized and deceased individuals are excluded from the “effective” mixing population. The same model can be run in deterministic or stochastic mode, and parameters are supplied through a YAML configuration. +For simulation control: +- `nsim` is the number of parameter sets (rows in sampled parameter matrices when distributions are used) +- `nrep` is the number of simulation replicates per parameter set +- total runs = `nsim * nrep` +- `simulation_mode` chooses `"deterministic"` or `"stochastic"` +- `random_seed` ensures reproducibility for both parameter sampling and stochastic trajectories + --- ### Core disease progression parameters @@ -209,4 +223,3 @@ List of vignettes: For the complete function reference, visit: **https://resume-epi.github.io/MetaRVM/reference/** - diff --git a/README.md b/README.md index 8f6f4e8..eb4728a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,13 @@ +[](https://github.com/RESUME-Epi/MetaRVM/actions/workflows/R-CMD-check.yaml) +[](https://app.codecov.io/gh/RESUME-Epi/MetaRVM) +[](https://lifecycle.r-lib.org/articles/stages.html) +[](https://RESUME-Epi.github.io/MetaRVM/) [](https://CRAN.R-project.org/package=MetaRVM) [![CRAN @@ -95,6 +102,9 @@ simulation_config: start_date: 10/01/2023 # m/d/Y length: 150 nsim: 1 + nrep: 1 + simulation_mode: deterministic + random_seed: 42 ``` ``` r @@ -150,6 +160,13 @@ excluded from the “effective” mixing population. The same model can be run in deterministic or stochastic mode, and parameters are supplied through a YAML configuration. +For simulation control: - `nsim` is the number of parameter sets (rows +in sampled parameter matrices when distributions are used) - `nrep` is +the number of simulation replicates per parameter set - total runs = +`nsim * nrep` - `simulation_mode` chooses `"deterministic"` or +`"stochastic"` - `random_seed` ensures reproducibility for both +parameter sampling and stochastic trajectories + ------------------------------------------------------------------------ ### Core disease progression parameters diff --git a/docs/404.html b/docs/404.html index 4d7532f..99bbfd1 100644 --- a/docs/404.html +++ b/docs/404.html @@ -28,7 +28,7 @@ MetaRVM - 2.0.0 + 2.1.0
You can install the development version of MetaRVM from GitHub:
+The development version of MetaRVM can be installed from GitHub:
# install.packages("devtools")
devtools::install_github("RESUME-Epi/MetaRVM")extdata directory. To run the example, these files must
+first be located. The system.file() function in R is the
+recommended way to do this, as it finds the files wherever the package
+is installed.
# Locate the example YAML configuration file
yaml_file <- system.file("extdata", "example_config.yaml", package = "MetaRVM")
print(yaml_file)
-#> [1] "/tmp/RtmpwQdGR9/temp_libpath28fcb4e3605ac/MetaRVM/extdata/example_config.yaml"The yaml_file variable now holds the full path to the
example configuration file. This file is set up to use the other example
data files (also in the extdata directory) with relative
@@ -155,15 +155,18 @@
For a detailed explanation of all the configuration options, please
see the yaml-configuration.html vignette.
Once we have the path to the configuration file, the simulation can
-be run using the metaRVM() function.
Once the path to the configuration file is available, the simulation
+can be run using the metaRVM() function.
# Load the metaRVM library
library(MetaRVM)
@@ -172,26 +175,29 @@ Running the Simulationsim_out <- metaRVM(yaml_file)
#> Loading required namespace: pkgbuild
#> Generating model in c
-#> ℹ Re-compiling odin8b079812 (debug build)
-#> ℹ Loading odin8b079812
print(sim_out)
#> MetaRVM Results Object
#> =====================
#> Instances: 1
-#> Populations: 24
+#> Populations:
#> Date range: 2023-10-01 to 2024-02-27
-#> Total observations: 111600
-#> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, V, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_SE, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_SE, p_VE
+#> Parameter sets (nsim): 1
+#> Replicates per set (nrep): 1
+#> Simulation mode: deterministic
+#> Total observations: 388800
+#> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, S_alloc, S_eff_prod, S_src_int, V, V_alloc, V_src_int, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_RS, n_SE, n_SE_eff, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_RS, p_SE, p_VE
head(sim_out$results)
#> date age race zone disease_state value instance
#> <Date> <char> <char> <int> <char> <num> <int>
#> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1
-#> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1
+#> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1
#> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1
-#> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1
-#> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1
-#> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1For more details on running metaRVM, refer to the
running-a-simulation.html vignette.
The metaRVM package includes a set of example files in
-its extdata directory. To run the example, we first need to
-locate these files. The system.file() function in R is the
-recommended way to do this, as it will find the files wherever the
-package is installed.
extdata directory. To run the example, these files must
+first be located. The system.file() function in R is the
+recommended way to do this, as it finds the files wherever the package
+is installed.
# Locate the example YAML configuration file
yaml_file <- system.file("extdata", "example_config.yaml", package = "MetaRVM")
print(yaml_file)
-#> [1] "/tmp/RtmpwQdGR9/temp_libpath28fcb4e3605ac/MetaRVM/extdata/example_config.yaml"The yaml_file variable now holds the full path to the
example configuration file. This file is set up to use the other example
data files (also in the extdata directory) with relative
@@ -139,13 +139,16 @@
Once we have the path to the configuration file, the simulation can
-be run using the metaRVM() function.
Once the path to the configuration file is available, the simulation
+can be run using the metaRVM() function.
# Load the metaRVM library
library(MetaRVM)
@@ -174,8 +177,8 @@ Working with Configuration Filesconfig_obj
#> MetaRVM Configuration Object
#> ============================
-#> Config file: /tmp/RtmpwQdGR9/temp_libpath28fcb4e3605ac/MetaRVM/extdata/example_config.yaml
-#> Parameters: 40
+#> Config file: /tmp/RtmpdtpnKS/temp_libpath8a1dd6c7d1703/MetaRVM/extdata/example_config.yaml
+#> Parameters: 42
#> Parameter names (first 10): N_pop, pop_map, category_names, S_ini, E_ini, I_asymp_ini, I_presymp_ini, I_symp_ini, H_ini, D_ini ...
#> Population groups: 24
#> Start date: 2023-09-30
@@ -255,15 +258,15 @@ Exploring the Results#> date age race zone disease_state value instance
#> <Date> <char> <char> <int> <char> <num> <int>
#> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1
-#> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1
+#> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1
#> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1
-#> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1
-#> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1
-#> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1
+#> 4: 2023-10-01 0-17 A 11 I_all 2.742619e+01 1
+#> 5: 2023-10-01 0-17 A 11 I_asymp 3.555784e-01 1
+#> 6: 2023-10-01 0-17 A 11 I_eff 2.483657e+01 1
# Check unique values for key variables
cat("Disease states:", paste(unique(sim_out$results$disease_state), collapse = ", "), "\n")
-#> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, V, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_SE, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_SE, p_VE
+#> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, S_alloc, S_eff_prod, S_src_int, V, V_alloc, V_src_int, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_RS, n_SE, n_SE_eff, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_RS, p_SE, p_VE
cat("Date range:", paste(range(sim_out$results$date), collapse = " to "), "\n")
#> Date range: 2023-10-01 to 2024-02-27
To run a simulation with this configuration, we pass the file path to
-metaRVM.
To run a simulation with this configuration, the file path is passed
+to metaRVM.
# Run the simulation with the new configuration
sim_out_dist <- metaRVM(yaml_file_dist)summarize
method generates output of class MetaRVMSummary which has a
-plot method available to use. Now that we have run a
-simulation with parameter distributions, we can use the
-summarize method to see the variability in the results.
+plot method available. After a simulation is run with
+parameter distributions, the summarize method can be used
+to inspect variability in the results.

-
-# Summary of hospitalizations by two user-defined categories
-hospital_summary <- sim_out_dist$summarize(
- group_by = c("age", "zone"),
- disease_states = "n_IsympH",
- stats = c("median", "quantile"),
- quantiles = c(0.05, 0.95)
-)
-hospital_summary
-#> MetaRVM Summary Object
-#> ======================
-#> Data type: summary
-#> Observations: 900
-#> Grouped by: age, zone
-#> Disease states: n_IsympH
-#> Date range: 2023-01-01 to 2023-05-30
-#> Summary statistics: median_value, q05, q95
-
-# visualize the summary
-hospital_summary$plot() + ggtitle("Daily Hospitalizations by Age and Zone") + theme_bw()
A stochastic simulation can also be run by setting
+simulation_mode: stochastic.
An example YAML file with parameter distributions is included in the
+package, example_config_stochastic.yaml. Here is its
+content:
+# Locate the example YAML configuration file with distributions
+yaml_file_stoch <- system.file("extdata", "example_config_stochastic.yaml", package = "MetaRVM")run_id: ExampleRun_Stochastic_Static
+population_data:
+ initialization: population_init_n24.csv
+ vaccination: vaccination_n24.csv
+mixing_matrix:
+ weekday_day: m_weekday_day.csv
+ weekday_night: m_weekday_night.csv
+ weekend_day: m_weekend_day.csv
+ weekend_night: m_weekend_night.csv
+disease_params:
+ ts: 0.5
+ ve: 0.4
+ dv: 180
+ dp: 1
+ de: 3
+ da: 5
+ ds: 6
+ dh: 8
+ dr: 180
+ pea: 0.3
+ psr: 0.95
+ phr: 0.97
+simulation_config:
+ start_date: 01/01/2023 # m/d/Y
+ length: 150
+ nsim: 1
+ nrep: 5
+ simulation_mode: stochastic
+ random_seed: 42
+sim_out_stoch <- metaRVM(yaml_file_stoch)The disease parameters can also be specified for different @@ -447,61 +474,64 @@
example_config_subgroup_dist.yaml, that
demonstrates this feature. It also includes parameters defined by
distributions.
-+-# Locate the example YAML configuration file with subgroup parameters yaml_file_subgroup <- system.file("extdata", "example_config_subgroup_dist.yaml", package = "MetaRVM")+run_id: ExampleRun_Subgroup_Dist -population_data: - initialization: population_init_n24.csv - vaccination: vaccination_n24.csv -mixing_matrix: - weekday_day: m_weekday_day.csv - weekday_night: m_weekday_night.csv - weekend_day: m_weekend_day.csv - weekend_night: m_weekend_night.csv -disease_params: - ts: 0.5 - ve: - dist: uniform - min: 0.3 - max: 0.5 - dv: 180 - dp: 1 - de: 3 - da: 5 - ds: 6 - dh: - dist: lognormal - mu: 2 - sd: 0.5 - dr: 180 - pea: 0.3 - psr: 0.95 - phr: 0.97 -sub_disease_params: - age: - 0-17: - pea: 0.08 - 18-64: - ts: 0.6 - 65+: - # This fixed value will override the global lognormal distribution for dh - dh: 10 - phr: 0.9227 -simulation_config: - start_date: 01/01/2023 # m/d/Y - length: 150 - nsim: 20run_id: ExampleRun_Subgroup_Dist +population_data: + initialization: population_init_n24.csv + vaccination: vaccination_n24.csv +mixing_matrix: + weekday_day: m_weekday_day.csv + weekday_night: m_weekday_night.csv + weekend_day: m_weekend_day.csv + weekend_night: m_weekend_night.csv +disease_params: + ts: 0.5 + ve: + dist: uniform + min: 0.3 + max: 0.5 + dv: 180 + dp: 1 + de: 3 + da: 5 + ds: 6 + dh: + dist: lognormal + mu: 2 + sd: 0.5 + dr: 180 + pea: 0.3 + psr: 0.95 + phr: 0.97 +sub_disease_params: + age: + 0-17: + pea: 0.08 + 18-64: + ts: 0.6 + 65+: + # This fixed value will override the global lognormal distribution for dh + dh: 10 + phr: 0.9227 +simulation_config: + start_date: 01/01/2023 # m/d/Y + length: 150 + nsim: 20 + nrep: 1 + simulation_mode: deterministic + random_seed: 42Now, let’s run the simulation with this configuration.
-+ nrep: 1 + simulation_mode: deterministic + random_seed: 42+-# Run the simulation with the subgroup configuration sim_out_subgroup <- metaRVM(yaml_file_subgroup)We can now plot the results to see the impact of the -subgroup-specific parameters. For example, we can compare the number of +
The results can now be plotted to evaluate the impact of +subgroup-specific parameters. For example, the number of hospitalizations in the “65+” age group, which has a
-dhof -10, to other age groups that use the globaldhdrawn from a -lognormal distribution.diff --git a/docs/articles/running-a-simulation_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/running-a-simulation_files/figure-html/unnamed-chunk-12-1.png index 6601994..b329fcf 100644 Binary files a/docs/articles/running-a-simulation_files/figure-html/unnamed-chunk-12-1.png and b/docs/articles/running-a-simulation_files/figure-html/unnamed-chunk-12-1.png differ diff --git a/docs/articles/running-a-simulation_files/figure-html/unnamed-chunk-17-1.png b/docs/articles/running-a-simulation_files/figure-html/unnamed-chunk-17-1.png new file mode 100644 index 0000000..04e5f54 Binary files /dev/null and b/docs/articles/running-a-simulation_files/figure-html/unnamed-chunk-17-1.png differ diff --git a/docs/articles/yaml-configuration.html b/docs/articles/yaml-configuration.html index 897a3c3..f8d20c4 100644 --- a/docs/articles/yaml-configuration.html +++ b/docs/articles/yaml-configuration.html @@ -27,7 +27,7 @@ MetaRVM - 2.0.0 + 2.1.0+10, can be compared to other age groups that use the global +dhdrawn from a lognormal distribution. +-# Summarize hospitalizations by age group hospital_summary_subgroup <- sim_out_subgroup$summarize( group_by = c("age"), @@ -512,7 +542,7 @@Specifying Disease Parame # Plot the summary hospital_summary_subgroup$plot() + ggtitle("Daily Hospitalizations by Age Group (Subgroup Parameters)") + theme_bw()
+
@@ -128,13 +128,15 @@ Basic Configuration start_date: 01/01/2025 # m/d/Y length: 90 nsim: 1 - random_seed: 42
run_id: A unique name for your
+run_id: A unique name for the
simulation.population_data: Paths to CSV files
@@ -342,7 +344,7 @@ Instead of fixed values, you can define disease parameters using +
Instead of fixed values, disease parameters can be defined using
statistical distributions. This is useful for capturing uncertainty in
the parameters. metaRVM supports uniform and
lognormal distributions.
uniform distribution, you must specify
-min and max values.lognormal distribution, you must specify
-mu and sd (mean and standard deviation on the
-log scale).uniform distribution, min and
+max values must be specified.lognormal distribution, mu and
+sd (mean and standard deviation on the log scale) must be
+specified.metaRVM allows you to specify different disease
-parameters for various demographic subgroups using the
+
metaRVM allows different disease parameters to be
+specified for demographic subgroups using the
sub_disease_params section. These subgroup-specific
-parameters will override the global parameters defined in
+parameters override the global parameters defined in
disease_params.
The demographic categories used in this section must match the
user-defined category column names in the initialization CSV file
-specified under population_data. For example, if your
+specified under population_data. For example, if the
initialization file has columns named age,
-income_level, and occupation, you can use any
-of these categories in sub_disease_params. The specific
+income_level, and occupation, any of these
+categories can be used in sub_disease_params. The specific
values (e.g., "0-4", "low",
"healthcare") must exactly match the values in those
columns.
When both parameter uncertainty and stochastic disease transitions
+are represented, set simulation_mode: stochastic and define
+one or more disease parameters as distributions.
nsim: number of sampled parameter setsnrep: number of stochastic replicates per parameter
+setnsim * nrep
+Example:
+run_id: StochasticDistRun
+population_data:
+ initialization: data/population_init.csv
+ vaccination: data/vaccination.csv
+mixing_matrix:
+ weekday_day: data/m_weekday_day.csv
+ weekday_night: data/m_weekday_night.csv
+ weekend_day: data/m_weekend_day.csv
+ weekend_night: data/m_weekend_night.csv
+disease_params:
+ ts: 0.5
+ ve:
+ dist: uniform
+ min: 0.29
+ max: 0.53
+ dv: 158
+ dp: 1
+ de: 3
+ da:
+ dist: uniform
+ min: 3
+ max: 7
+ ds:
+ dist: uniform
+ min: 5
+ max: 7
+ dh:
+ dist: lognormal
+ mu: 2.0
+ sd: 0.5
+ dr: 187
+ pea: 0.333
+ psr: 0.95
+ phr: 0.97
+simulation_config:
+ start_date: 01/01/2025
+ length: 90
+ nsim: 20
+ nrep: 5
+ simulation_mode: stochastic
+ random_seed: 42For reproducibility, provide random_seed. This seed is
+used to reproduce both the parameter draws (for distributional
+parameters) and the stochastic model replicates.
For long-running simulations, it is useful to save the state of the
model at intermediate points. This is known as checkpointing.
-metaRVM allows you to save checkpoints and restore a
-simulation from a saved state.
metaRVM allows checkpoints to be saved and simulations to
+be restored from a saved state.
To enable checkpointing, you need to add the
-checkpoint_dir and optionally checkpoint_dates
-to the simulation_config section of your YAML file.
To enable checkpointing, checkpoint_dir and optionally
+checkpoint_dates need to be added to the
+simulation_config section of the YAML file.
Here is an example of how to configure checkpointing:
- +To restore a simulation from a checkpoint file, use the
-restore_from parameter in the
-simulation_config section. This will initialize the model
-with the state saved in the specified checkpoint file.
simulation_config:
- start_date: 01/30/2025 # Should be the next date of the checkpoint date
- length: 60 # Remaining simulation length
- nsim: 10
- restore_from: "path/to/checkpoints/checkpoint_2025-01-30_instance_1.Rda"To restore a simulation from a checkpoint file, the
+restore_from parameter is used in the
+simulation_config section. The model is initialized with
+the state saved in the specified checkpoint file.
simulation_config:
+ start_date: 01/30/2025 # Should be the next date of the checkpoint date
+ length: 60 # Remaining simulation length
+ nsim: 10
+ nrep: 1
+ simulation_mode: deterministic
+ random_seed: 42
+ restore_from: "path/to/checkpoints/checkpoint_2025-01-30_instance_1.Rda"When restoring, the start_date should correspond to the
next date of the checkpoint, and the length should be the
remaining duration of the simulation. Note that each instance of a
diff --git a/docs/authors.html b/docs/authors.html
index 602e4d1..746a116 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -7,7 +7,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
Running a simulationsimulation_config:
start_date: 10/01/2023 # m/d/Y
length: 150
- nsim: 1
# run simulation
sim_out <- metaRVM(cfg)
@@ -198,6 +201,7 @@ Model structure
At the start of a simulation, nearly all individuals are in S, with optional seeding of initial infections and/or vaccinated individuals in V. When susceptible or vaccinated individuals come into contact with infectious individuals, they become exposed (E) based on age/stratum-specific forces of infection and vaccine protection. Exposed individuals then progress through asymptomatic, presymptomatic, and symptomatic infectious states before either recovering, being hospitalized, or dying. Vaccinated and recovered immunity can wane over time, returning individuals to the susceptible pool, which allows MetaRVM to represent multiple respiratory pathogens with different natural histories.
Transmission is stratified by user-defined demographic groups (e.g., age, zone, race). Time-varying mixing matrices define how these strata interact (daytime vs. nighttime, weekday vs. weekend), and MetaRVM computes stratum-specific forces of infection for susceptible and vaccinated individuals. Hospitalized and deceased individuals are excluded from the “effective” mixing population. The same model can be run in deterministic or stochastic mode, and parameters are supplied through a YAML configuration.
+For simulation control: - nsim is the number of parameter sets (rows in sampled parameter matrices when distributions are used) - nrep is the number of simulation replicates per parameter set - total runs = nsim * nrep - simulation_mode chooses "deterministic" or "stochastic" - random_seed ensures reproducibility for both parameter sampling and stochastic trajectories
Core disease progression parameters
diff --git a/docs/news/index.html b/docs/news/index.html
index b7c05fb..600b07b 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -7,7 +7,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
@@ -49,6 +49,25 @@
Source: NEWS.md
+
+MetaRVM 2.1.0
+Added simulation_mode (deterministic/stochastic) and nrep support in configuration parsing and run metadata.
+Improved stochastic reproducibility: provided random_seed is honored, and a seed is generated/stored when missing.
+Updated stochastic transition splitting to use binomial draws for integer compartment flows (n_EIpresymp, n_IsympH, n_HR).
+Improved metapopulation infection-flow indexing consistency for destination- specific force of infection in n_SE_eff and n_VE_eff.
+Added bounded vaccination and transition safeguards to reduce overdraw risks (for example, capping applied vaccination by available susceptible count and guarding zero effective population in force-of-infection calculations).
+Added integer row allocation for stochastic mixing flows (S and V) using floor-plus-residual adjustment so row totals are conserved.
+Added regression tests for stochastic seed behavior, nsim * nrep instance counts, and row-allocation conservation checks for S/V mixing.
+-
+
Enhanced results helper APIs:
+-
+
MetaRVMResults$plot() now provides direct trajectory plotting before summarization.
+-
+
MetaRVMSummary$plot() now supports instance-trajectory plotting.
+-
+
summarize() uses a more efficient single-pass grouped aggregation.
+
+
MetaRVM 2.0.0
CRAN release: 2026-03-19
Subpopulation categories are now user-defined from population_data$initialization; non-reserved columns are detected automatically.
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 12b690a..207f3d7 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -6,7 +6,7 @@ articles:
getting-started: getting-started.html
running-a-simulation: running-a-simulation.html
yaml-configuration: yaml-configuration.html
-last_built: 2026-03-19T21:10Z
+last_built: 2026-03-26T18:51Z
urls:
reference: https://RESUME-Epi.github.io/MetaRVM/reference
article: https://RESUME-Epi.github.io/MetaRVM/articles
diff --git a/docs/reference/MetaRVM-package.html b/docs/reference/MetaRVM-package.html
index 5b69f54..2bbbf22 100644
--- a/docs/reference/MetaRVM-package.html
+++ b/docs/reference/MetaRVM-package.html
@@ -11,7 +11,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/MetaRVMCheck.html b/docs/reference/MetaRVMCheck.html
index e84b556..82054ed 100644
--- a/docs/reference/MetaRVMCheck.html
+++ b/docs/reference/MetaRVMCheck.html
@@ -11,7 +11,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/MetaRVMConfig.html b/docs/reference/MetaRVMConfig.html
index 87d22cf..430215d 100644
--- a/docs/reference/MetaRVMConfig.html
+++ b/docs/reference/MetaRVMConfig.html
@@ -11,7 +11,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/MetaRVMResults-1.png b/docs/reference/MetaRVMResults-1.png
index 5970741..72df3ac 100644
Binary files a/docs/reference/MetaRVMResults-1.png and b/docs/reference/MetaRVMResults-1.png differ
diff --git a/docs/reference/MetaRVMResults.html b/docs/reference/MetaRVMResults.html
index 049a29e..1500f1b 100644
--- a/docs/reference/MetaRVMResults.html
+++ b/docs/reference/MetaRVMResults.html
@@ -11,7 +11,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
@@ -96,6 +96,7 @@ Public methods
+
@@ -148,10 +149,77 @@ Returns
+Method plot()
+Plot simulation trajectories directly from results
+Usage
+MetaRVMResults$plot(
+ group_by = character(0),
+ disease_states = NULL,
+ date_range = NULL,
+ instances = NULL,
+ stats = NULL,
+ quantiles = c(0.25, 0.75),
+ exclude_p_columns = TRUE,
+ ci_level = 0.95,
+ theme = theme_minimal(),
+ title = NULL
+)
+
+
+
+Arguments
+group_by
+Vector of demographic category names to group/facet by
+
+
+disease_states
+Optional disease states to include
+
+
+date_range
+Optional date range for filtering
+
+
+instances
+Optional instance IDs to include
+
+
+stats
+Statistics for summary plotting. If NULL, plots raw trajectories.
+
+
+quantiles
+Quantiles for uncertainty bands when summary plotting
+
+
+exclude_p_columns
+Logical, whether to exclude p_ columns (default: TRUE)
+
+
+ci_level
+Confidence level label used in summary plot title
+
+
+theme
+ggplot2 theme function (default: theme_minimal())
+
+
+title
+Optional custom title
+
+
+
+
+
+
Method subset_data()
Subset the data based on any combination of parameters
-Usage
+Usage
-Arguments
+Arguments
...
Named arguments for category filters (e.g., age = c("0-17"), income = c("low", "high"))
@@ -186,14 +254,14 @@ Arguments
-Returns
+Returns
MetaRVMResults object with subset of results
Method summarize()
Summarize results across specified demographic characteristics
-Usage
+Usage
-Arguments
+Arguments
group_by
Vector of demographic category names to group by. Must be valid category
names from the configuration (e.g., c("age", "zone"), c("income_level", "occupation")).
@@ -235,19 +303,19 @@
Arguments
-Returns
+Returns
data.table with summarized time series data or all instances if stats = NULL
Method clone()
The objects of this class are cloneable with this method.
-Arguments
+Arguments
deep
Whether to make a deep clone.
@@ -272,11 +340,11 @@ Examples#> date age race zone disease_state value instance
#> <Date> <char> <char> <int> <char> <num> <int>
#> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1
-#> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1
+#> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1
#> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1
-#> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1
-#> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1
-#> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1
+#> 4: 2023-10-01 0-17 A 11 I_all 2.742619e+01 1
+#> 5: 2023-10-01 0-17 A 11 I_asymp 3.555784e-01 1
+#> 6: 2023-10-01 0-17 A 11 I_eff 2.483657e+01 1
# Subset data with multiple filters
subset_data <- results_obj$subset_data(
diff --git a/docs/reference/MetaRVMSummary-1.png b/docs/reference/MetaRVMSummary-1.png
index 7216b2d..7a09120 100644
Binary files a/docs/reference/MetaRVMSummary-1.png and b/docs/reference/MetaRVMSummary-1.png differ
diff --git a/docs/reference/MetaRVMSummary-2.png b/docs/reference/MetaRVMSummary-2.png
index d3157dc..65c7fe2 100644
Binary files a/docs/reference/MetaRVMSummary-2.png and b/docs/reference/MetaRVMSummary-2.png differ
diff --git a/docs/reference/MetaRVMSummary.html b/docs/reference/MetaRVMSummary.html
index d483725..dce8552 100644
--- a/docs/reference/MetaRVMSummary.html
+++ b/docs/reference/MetaRVMSummary.html
@@ -11,7 +11,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/draw_sample.html b/docs/reference/draw_sample.html
index a075edf..f9d94ad 100644
--- a/docs/reference/draw_sample.html
+++ b/docs/reference/draw_sample.html
@@ -7,7 +7,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/format_metarvm_output.html b/docs/reference/format_metarvm_output.html
index 948841e..af4d90c 100644
--- a/docs/reference/format_metarvm_output.html
+++ b/docs/reference/format_metarvm_output.html
@@ -23,7 +23,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/grapes-or-or-grapes.html b/docs/reference/grapes-or-or-grapes.html
index 30865b9..ed7cc23 100644
--- a/docs/reference/grapes-or-or-grapes.html
+++ b/docs/reference/grapes-or-or-grapes.html
@@ -9,7 +9,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 21b84c7..80ddb3c 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -7,7 +7,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/metaRVM-1.png b/docs/reference/metaRVM-1.png
index 5cc9f36..24bf43a 100644
Binary files a/docs/reference/metaRVM-1.png and b/docs/reference/metaRVM-1.png differ
diff --git a/docs/reference/metaRVM.html b/docs/reference/metaRVM.html
index c45620b..f31ce80 100644
--- a/docs/reference/metaRVM.html
+++ b/docs/reference/metaRVM.html
@@ -17,7 +17,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
@@ -157,21 +157,24 @@ Examples#> MetaRVM Results Object
#> =====================
#> Instances: 1
-#> Populations: 24
+#> Populations:
#> Date range: 2023-10-01 to 2024-02-27
-#> Total observations: 111600
-#> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, V, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_SE, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_SE, p_VE
+#> Parameter sets (nsim): 1
+#> Replicates per set (nrep): 1
+#> Simulation mode: deterministic
+#> Total observations: 388800
+#> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, S_alloc, S_eff_prod, S_src_int, V, V_alloc, V_src_int, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_RS, n_SE, n_SE_eff, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_RS, p_SE, p_VE
# Access the tidy results table
head(results$results)
#> date age race zone disease_state value instance
#> <Date> <char> <char> <int> <char> <num> <int>
#> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1
-#> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1
+#> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1
#> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1
-#> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1
-#> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1
-#> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1
+#> 4: 2023-10-01 0-17 A 11 I_all 2.742619e+01 1
+#> 5: 2023-10-01 0-17 A 11 I_asymp 3.555784e-01 1
+#> 6: 2023-10-01 0-17 A 11 I_eff 2.483657e+01 1
# Summarize and plot hospitalizations and deaths by user-defined categories
results$summarize(
diff --git a/docs/reference/meta_sim.html b/docs/reference/meta_sim.html
index 92f4fe9..b770060 100644
--- a/docs/reference/meta_sim.html
+++ b/docs/reference/meta_sim.html
@@ -15,7 +15,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/reference/parse_config.html b/docs/reference/parse_config.html
index 774383d..24efff6 100644
--- a/docs/reference/parse_config.html
+++ b/docs/reference/parse_config.html
@@ -11,7 +11,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
@@ -109,6 +109,12 @@ Value
nsim
Number of simulation instances
+- nrep
+Number of stochastic replicates per parameter set
+
+- simulation_mode
+Simulation mode: "deterministic" or "stochastic"
+
- random_seed
Random seed used (if any)
@@ -128,6 +134,9 @@ Details
main sections:
Simulation Configuration:
random_seed: Optional random seed for reproducibility in case of stochastic simulations or stochastic parameters
nsim: Number of simulation instances (default: 1)
+nrep: Number of stochastic replicates per parameter set (default: 1)
+simulation_mode: Optional simulation mode. Must be one of
+"deterministic" or "stochastic" (default: "deterministic").
start_date: Simulation start date in MM/DD/YYYY format
length: Simulation length in days
checkpoint_dir: Optional checkpoint directory for saving intermediate results
@@ -203,16 +212,17 @@ Examplesconfig_obj$get("N_pop")
#> [1] 24
config_obj$list_parameters()
-#> [1] "N_pop" "pop_map" "category_names" "S_ini"
-#> [5] "E_ini" "I_asymp_ini" "I_presymp_ini" "I_symp_ini"
-#> [9] "H_ini" "D_ini" "P_ini" "V_ini"
-#> [13] "R_ini" "vac_time_id" "vac_counts" "vac_mat"
-#> [17] "m_wd_d" "m_wd_n" "m_we_d" "m_we_n"
-#> [21] "ts" "ve" "dv" "de"
-#> [25] "dp" "da" "ds" "dh"
-#> [29] "dr" "pea" "psr" "phr"
-#> [33] "start_date" "sim_length" "nsim" "random_seed"
-#> [37] "delta_t" "chk_file_names" "chk_time_steps" "do_chk"
+#> [1] "N_pop" "pop_map" "category_names" "S_ini"
+#> [5] "E_ini" "I_asymp_ini" "I_presymp_ini" "I_symp_ini"
+#> [9] "H_ini" "D_ini" "P_ini" "V_ini"
+#> [13] "R_ini" "vac_time_id" "vac_counts" "vac_mat"
+#> [17] "m_wd_d" "m_wd_n" "m_we_d" "m_we_n"
+#> [21] "ts" "ve" "dv" "de"
+#> [25] "dp" "da" "ds" "dh"
+#> [29] "dr" "pea" "psr" "phr"
+#> [33] "start_date" "sim_length" "nsim" "nrep"
+#> [37] "simulation_mode" "random_seed" "delta_t" "chk_file_names"
+#> [41] "chk_time_steps" "do_chk"
# Use with MetaRVM simulation
results <- metaRVM(config_obj)
diff --git a/docs/reference/process_vac_data.html b/docs/reference/process_vac_data.html
index bc757ac..2c6e04c 100644
--- a/docs/reference/process_vac_data.html
+++ b/docs/reference/process_vac_data.html
@@ -9,7 +9,7 @@
MetaRVM
- 2.0.0
+ 2.1.0
diff --git a/docs/search.json b/docs/search.json
index 08e0a0c..454b7fc 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -1 +1 @@
-[{"path":"https://RESUME-Epi.github.io/MetaRVM/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 MetaRVM authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Checkpointing in MetaRVM","text":"vignette demonstrates configure use checkpointing functionality MetaRVM examples. Checkpointing allows store model state specific time points simulation, allowing one resume runs saved states.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"how-checkpointing-works","dir":"Articles","previous_headings":"","what":"How Checkpointing Works","title":"Checkpointing in MetaRVM","text":"MetaRVM’s checkpointing system configured YAML configuration file. Saving checkpoints: simulation, complete state (compartments, parameters, time step) saved disk specified dates Restoring checkpoints: new simulation can initialized previously saved checkpoint, continuing point forward Flexible scheduling: Exact dates checkpoints saved supplied, default checkpoint end--simulation date.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"configuration-parameters","dir":"Articles","previous_headings":"How Checkpointing Works","what":"Configuration Parameters","title":"Checkpointing in MetaRVM","text":"checkpointing system uses three main configuration options simulation_config section: checkpoint_dir: Directory checkpoint files saved (created doesn’t exist) checkpoint_dates: (Optional) List specific dates checkpoints saved restore_from: (Optional) Path checkpoint file resume ","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"example","dir":"Articles","previous_headings":"","what":"Example","title":"Checkpointing in MetaRVM","text":"purpose example, set checkpointed directory temporary directory, create temporary yaml configuration file based template.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"set-up","dir":"Articles","previous_headings":"Example","what":"Set Up","title":"Checkpointing in MetaRVM","text":"","code":"library(MetaRVM) options(odin.verbose = FALSE) # Get the example configuration file example_config <- system.file(\"extdata\", \"example_config_checkpoint.yaml\", package = \"MetaRVM\") # Create a temporary directory for checkpoints checkpoint_dir <- tempdir() cat(\"Checkpoint directory:\", checkpoint_dir, \"\\n\") #> Checkpoint directory: /tmp/RtmpwQdGR9"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"create-a-configuration-with-checkpointing","dir":"Articles","previous_headings":"Example","what":"Create a Configuration with Checkpointing","title":"Checkpointing in MetaRVM","text":"Now copy example configuration modify add checkpointing:","code":"# Read the example configuration yml <- yaml::read_yaml(example_config) yml_tmp <- data.table::copy(yml) # Assign checkpoint directory yml_tmp$simulation_config$checkpoint_dir <- checkpoint_dir # Create a temporary config temp_config <- tempfile(tmpdir = dirname(example_config), fileext = \".yaml\") yaml::write_yaml(yml_tmp, temp_config) temp_config <- normalizePath(temp_config)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"run-simulation-with-checkpoints","dir":"Articles","previous_headings":"Example","what":"Run Simulation with Checkpoints","title":"Checkpointing in MetaRVM","text":"","code":"# Run the simulation results <- metaRVM(temp_config) # Check what checkpoint files were created checkpoint_files <- list.files(checkpoint_dir, pattern = \"^chk_.*\\\\.Rda$\", full.names = FALSE) if (length(checkpoint_files) > 0) { for (file in checkpoint_files) { cat(\" -\", file, \"\\n\") } } else { cat(\" (No checkpoint files found)\\n\") } #> - chk_2024-12-29_1.Rda"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"examine-the-results","dir":"Articles","previous_headings":"Example","what":"Examine the Results","title":"Checkpointing in MetaRVM","text":"","code":"cat(\"Number of instances:\", results$run_info$n_instances, \"\\n\") #> Number of instances: 1 cat(\"Date range:\", format(results$run_info$date_range[1]), \"to\", format(results$run_info$date_range[2]), \"\\n\") #> Date range: 2024-10-01 to 2024-12-29 # Display first few rows print(head(results$results, 10)) #> date age race zone disease_state value instance #> #> 1: 2024-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2024-10-01 0-17 A 11 E 1.346375e+01 1 #> 3: 2024-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2024-10-01 0-17 A 11 I_all 2.739162e+01 1 #> 5: 2024-10-01 0-17 A 11 I_asymp 3.452058e-01 1 #> 6: 2024-10-01 0-17 A 11 I_eff 2.653406e+01 1 #> 7: 2024-10-01 0-17 A 11 I_presymp 8.054801e-01 1 #> 8: 2024-10-01 0-17 A 11 I_symp 2.624093e+01 1 #> 9: 2024-10-01 0-17 A 11 P 3.074200e+04 1 #> 10: 2024-10-01 0-17 A 11 R 1.148308e+01 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"resume-from-a-checkpoint","dir":"Articles","previous_headings":"Example","what":"Resume from a Checkpoint","title":"Checkpointing in MetaRVM","text":"’ll create new configuration restores checkpoint. need provide checkpoint file name, start date next day end date previous run.","code":"# Get the first checkpoint file checkpoint_files_full <- list.files(checkpoint_dir, pattern = \"^chk_.*\\\\.Rda$\", full.names = TRUE) if (length(checkpoint_files_full) > 0) { checkpoint_to_restore <- checkpoint_files_full[1] cat(checkpoint_to_restore, \"\\n\\n\") new_start_date <- \"12/30/2024\" yml_tmp <- data.table::copy(yml) yml_tmp$simulation_config$start_date <- new_start_date yml_tmp$simulation_config$restore_from <- checkpoint_to_restore yml_tmp$population_data$initialization <- \"population_init_n24_only_mapping.csv\" # ensure that we don't want to reinitialize the population with the original initial conditions temp_config_resume <- tempfile(tmpdir = dirname(example_config), fileext = \".yaml\") yaml::write_yaml(yml_tmp, temp_config_resume) temp_config_resume <- normalizePath(temp_config_resume) # Run the resumed simulation results_resumed <- metaRVM(temp_config_resume) cat(\"Number of instances:\", results_resumed$run_info$n_instances, \"\\n\") cat(\"Date range:\", format(results_resumed$run_info$date_range[1]), \"to\", format(results_resumed$run_info$date_range[2]), \"\\n\") } else { cat(\"No checkpoint files found to resume from.\\n\") } #> /tmp/RtmpwQdGR9/chk_2024-12-29_1.Rda #> #> Number of instances: 1 #> Date range: 2024-12-30 to 2025-03-29"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"plot","dir":"Articles","previous_headings":"Example","what":"Plot","title":"Checkpointing in MetaRVM","text":"plot chunk plot","code":"run1_hosp_sum <- results$results[disease_state == \"H\", .(total = sum(value)), by = \"date\"] run2_hosp_sum <- results_resumed$results[disease_state == \"H\", .(total = sum(value)), by = \"date\"] library(ggplot2) ggplot(rbind(run1_hosp_sum, run2_hosp_sum), aes(date, total)) + geom_line(, color = \"red\") + geom_vline(xintercept = as.Date(\"2024-12-29\"), linetype = \"dashed\") + labs(y = \"Hospitalizations\", x = \"Date\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"understanding-checkpoint-files","dir":"Articles","previous_headings":"","what":"Understanding Checkpoint Files","title":"Checkpointing in MetaRVM","text":"checkpointing enabled, MetaRVM creates checkpoint files following naming convention: : - YYYY-MM-DD checkpoint date - N simulation instance number (1 nsim) information configuring MetaRVM simulations, see YAML Configuration vignette.","code":"chk_YYYY-MM-DD_N.Rda"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting Started with MetaRVM","text":"MetaRVM comprehensive R package simulating respiratory virus epidemics using meta-population compartmental models. vignette guide basic usage package.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Getting Started with MetaRVM","text":"can install development version MetaRVM GitHub:","code":"# install.packages(\"devtools\") devtools::install_github(\"RESUME-Epi/MetaRVM\")"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"loading-the-package","dir":"Articles","previous_headings":"","what":"Loading the Package","title":"Getting Started with MetaRVM","text":"","code":"library(MetaRVM) library(ggplot2) options(odin.verbose = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"basic-example","dir":"Articles","previous_headings":"","what":"Basic Example","title":"Getting Started with MetaRVM","text":"example shows run basic meta-population simulation. metaRVM package includes set example files extdata directory. run example, first need locate files. system.file() function R recommended way , find files wherever package installed. yaml_file variable now holds full path example configuration file. file set use example data files (also extdata directory) relative paths. content yaml file. detailed explanation configuration options, please see yaml-configuration.html vignette.","code":"# Locate the example YAML configuration file yaml_file <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") print(yaml_file) #> [1] \"/tmp/RtmpwQdGR9/temp_libpath28fcb4e3605ac/MetaRVM/extdata/example_config.yaml\" run_id: ExampleRun population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"running-the-simulation","dir":"Articles","previous_headings":"","what":"Running the Simulation","title":"Getting Started with MetaRVM","text":"path configuration file, simulation can run using metaRVM() function. details running metaRVM, refer running--simulation.html vignette.","code":"# Load the metaRVM library library(MetaRVM) # Run the simulation sim_out <- metaRVM(yaml_file) #> Loading required namespace: pkgbuild #> Generating model in c #> ℹ Re-compiling odin8b079812 (debug build) #> ℹ Loading odin8b079812 print(sim_out) #> MetaRVM Results Object #> ===================== #> Instances: 1 #> Populations: 24 #> Date range: 2023-10-01 to 2024-02-27 #> Total observations: 111600 #> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, V, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_SE, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_SE, p_VE head(sim_out$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Running a Simulation with metaRVM","text":"vignette demonstrates run metaRVM simulation using example configuration data files included package. good way get started understand basic workflow.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"locating-the-example-files","dir":"Articles","previous_headings":"","what":"Locating the Example Files","title":"Running a Simulation with metaRVM","text":"metaRVM package includes set example files extdata directory. run example, first need locate files. system.file() function R recommended way , find files wherever package installed. yaml_file variable now holds full path example configuration file. file set use example data files (also extdata directory) relative paths. content yaml file.","code":"# Locate the example YAML configuration file yaml_file <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") print(yaml_file) #> [1] \"/tmp/RtmpwQdGR9/temp_libpath28fcb4e3605ac/MetaRVM/extdata/example_config.yaml\" run_id: ExampleRun population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"running-the-simulation","dir":"Articles","previous_headings":"","what":"Running the Simulation","title":"Running a Simulation with metaRVM","text":"path configuration file, simulation can run using metaRVM() function. metaRVM() function parse YAML file, read associated data files, run simulation, return MetaRVMResults object.","code":"# Load the metaRVM library library(MetaRVM) options(odin.verbose = FALSE) # Run the simulation sim_out <- metaRVM(yaml_file) #> Loading required namespace: pkgbuild"},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"working-with-configuration-files","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Working with Configuration Files","title":"Running a Simulation with metaRVM","text":"simulation can run directly providing YAML configuration file path, creating MetaRVMConfig object.","code":"# Load configuration from YAML file config_obj <- MetaRVMConfig$new(yaml_file) # Examine the configuration config_obj #> MetaRVM Configuration Object #> ============================ #> Config file: /tmp/RtmpwQdGR9/temp_libpath28fcb4e3605ac/MetaRVM/extdata/example_config.yaml #> Parameters: 40 #> Parameter names (first 10): N_pop, pop_map, category_names, S_ini, E_ini, I_asymp_ini, I_presymp_ini, I_symp_ini, H_ini, D_ini ... #> Population groups: 24 #> Start date: 2023-09-30 #> Population mapping: [ 24 rows x 4 columns]"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"exploring-configuration-parameters","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Exploring Configuration Parameters","title":"Running a Simulation with metaRVM","text":"MetaRVMConfig class provides several methods explore simulation arguments:","code":"# List all available parameters param_names <- config_obj$list_parameters() head(param_names, 10) #> [1] \"N_pop\" \"pop_map\" \"category_names\" \"S_ini\" #> [5] \"E_ini\" \"I_asymp_ini\" \"I_presymp_ini\" \"I_symp_ini\" #> [9] \"H_ini\" \"D_ini\" # Get a summary of parameter types and sizes param_summary <- config_obj$parameter_summary() head(param_summary, 10) #> parameter type length size #> N_pop N_pop integer 1 1 #> pop_map pop_map data.table 4 4 #> category_names category_names character 3 3 #> S_ini S_ini integer 24 24 #> E_ini E_ini numeric 24 24 #> I_asymp_ini I_asymp_ini numeric 24 24 #> I_presymp_ini I_presymp_ini numeric 24 24 #> I_symp_ini I_symp_ini integer 24 24 #> H_ini H_ini numeric 24 24 #> D_ini D_ini numeric 24 24"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"accessing-demographic-information","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Accessing Demographic Information","title":"Running a Simulation with metaRVM","text":"One MetaRVM’s key features demographic stratification, ’s ability define parameters specific demographic strata.","code":"# Get user-defined demographic category names and values category_names <- config_obj$get_category_names() cat(\"Available categories:\", paste(category_names, collapse = \", \"), \"\\n\") #> Available categories: age, race, zone # Example: inspect values for one category (if present) if (\"age\" %in% category_names) { age_categories <- config_obj$get_category_values(\"age\") cat(\"Age categories:\", paste(age_categories, collapse = \", \"), \"\\n\") } #> Age categories: 0-17, 18-64, 65+"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"alternative-ways-to-run-the-simulation","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Alternative Ways to Run the Simulation","title":"Running a Simulation with metaRVM","text":"","code":"# Method 1: Direct from file path # sim_out <- metaRVM(config_file) # Method 2: From MetaRVMConfig object sim_out <- metaRVM(config_obj) # Method 3: From parsed configuration list config_list <- parse_config(yaml_file) sim_out <- metaRVM(config_list)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"exploring-the-results","dir":"Articles","previous_headings":"","what":"Exploring the Results","title":"Running a Simulation with metaRVM","text":"metaRVM() function returns MetaRVMResults object formatted, analysis-ready data. results formatted calendar dates demographic attributes, stored data frame called results:","code":"# Look at the structure of formatted results head(sim_out$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1 # Check unique values for key variables cat(\"Disease states:\", paste(unique(sim_out$results$disease_state), collapse = \", \"), \"\\n\") #> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, V, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_SE, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_SE, p_VE cat(\"Date range:\", paste(range(sim_out$results$date), collapse = \" to \"), \"\\n\") #> Date range: 2023-10-01 to 2024-02-27"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"data-subsetting-and-filtering","dir":"Articles","previous_headings":"Exploring the Results","what":"Data Subsetting and Filtering","title":"Running a Simulation with metaRVM","text":"subset_data() method provides flexible filtering across demographic temporal dimensions. returns object class MetaRVMResults.","code":"# Subset by single criteria hospitalized_data <- sim_out$subset_data(disease_states = \"H\") hospitalized_data$results #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 H 0.2304447 1 #> 2: 2023-10-01 0-17 A 22 H 0.2081436 1 #> 3: 2023-10-01 0-17 B 11 H 0.5203590 1 #> 4: 2023-10-01 0-17 B 22 H 0.3939861 1 #> 5: 2023-10-01 0-17 C 11 H 0.6244308 1 #> --- #> 3596: 2024-02-27 65+ B 22 H 1.6779075 1 #> 3597: 2024-02-27 65+ C 11 H 2.4663331 1 #> 3598: 2024-02-27 65+ C 22 H 10.0053788 1 #> 3599: 2024-02-27 65+ D 11 H 5.6625439 1 #> 3600: 2024-02-27 65+ D 22 H 11.3371490 1 # Subset by multiple demographic categories elderly_data <- sim_out$subset_data( age = c(\"65+\"), disease_states = c(\"H\", \"D\") ) elderly_data$results #> date age race zone disease_state value instance #> #> 1: 2023-10-01 65+ A 11 D 2.179919e-05 1 #> 2: 2023-10-01 65+ A 11 H 2.230110e-02 1 #> 3: 2023-10-01 65+ A 22 D 1.453279e-05 1 #> 4: 2023-10-01 65+ A 22 H 1.486740e-02 1 #> 5: 2023-10-01 65+ B 11 D 8.719675e-05 1 #> --- #> 2396: 2024-02-27 65+ C 22 H 1.000538e+01 1 #> 2397: 2024-02-27 65+ D 11 D 3.844495e+01 1 #> 2398: 2024-02-27 65+ D 11 H 5.662544e+00 1 #> 2399: 2024-02-27 65+ D 22 D 8.556737e+01 1 #> 2400: 2024-02-27 65+ D 22 H 1.133715e+01 1 # Specific date range peak_period <- sim_out$subset_data( date_range = c(as.Date(\"2023-10-01\"), as.Date(\"2023-12-31\")), disease_states = \"H\" ) peak_period$results #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 H 0.2304447 1 #> 2: 2023-10-01 0-17 A 22 H 0.2081436 1 #> 3: 2023-10-01 0-17 B 11 H 0.5203590 1 #> 4: 2023-10-01 0-17 B 22 H 0.3939861 1 #> 5: 2023-10-01 0-17 C 11 H 0.6244308 1 #> --- #> 2204: 2023-12-31 65+ B 22 H 4.5130497 1 #> 2205: 2023-12-31 65+ C 11 H 6.5013954 1 #> 2206: 2023-12-31 65+ C 22 H 55.2465688 1 #> 2207: 2023-12-31 65+ D 11 H 27.2044176 1 #> 2208: 2023-12-31 65+ D 22 H 74.6798530 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"specifying-disease-parameters-via-distributions","dir":"Articles","previous_headings":"","what":"Specifying Disease Parameters via Distributions","title":"Running a Simulation with metaRVM","text":"metaRVM allows disease parameters specified distributions, useful capturing uncertainty. parameter defined distribution, simulation instance draw new value distribution. details available distributions parameters, refer yaml-configuration vignette. example YAML file parameter distributions included package, example_config_dist.yaml. content: run simulation configuration, pass file path metaRVM.","code":"# Locate the example YAML configuration file with distributions yaml_file_dist <- system.file(\"extdata\", \"example_config_dist.yaml\", package = \"MetaRVM\") run_id: ExampleRun_Dist population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: dist: uniform min: 0.3 max: 0.5 dv: 180 dp: 1 de: 3 da: dist: uniform min: 4 max: 6 ds: dist: uniform min: 5 max: 7 dh: dist: lognormal mu: 2 sd: 0.5 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 20 # Increased nsim for meaningful summary statistics # Run the simulation with the new configuration sim_out_dist <- metaRVM(yaml_file_dist)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"generating-summary-statistics-across-demographics","dir":"Articles","previous_headings":"Specifying Disease Parameters via Distributions","what":"Generating Summary Statistics across Demographics","title":"Running a Simulation with metaRVM","text":"MetaRVMResults class provides basic summarization functionality across multiple instances simulation, one disease parameters specified via distribution, one simulations per configurations. summarize method generates output class MetaRVMSummary plot method available use. Now run simulation parameter distributions, can use summarize method see variability results.","code":"library(ggplot2) # Summarize hospitalizations by age group hospital_summary_dist <- sim_out_dist$summarize( group_by = c(\"age\"), disease_states = \"n_IsympH\", stats = c(\"median\", \"quantile\"), quantiles = c(0.05, 0.95) ) # Plot the summary hospital_summary_dist$plot() + ggtitle(\"Daily Hospitalizations by Age Group (with 90% confidence interval)\") + theme_bw() # Summary of hospitalizations by two user-defined categories hospital_summary <- sim_out_dist$summarize( group_by = c(\"age\", \"zone\"), disease_states = \"n_IsympH\", stats = c(\"median\", \"quantile\"), quantiles = c(0.05, 0.95) ) hospital_summary #> MetaRVM Summary Object #> ====================== #> Data type: summary #> Observations: 900 #> Grouped by: age, zone #> Disease states: n_IsympH #> Date range: 2023-01-01 to 2023-05-30 #> Summary statistics: median_value, q05, q95 # visualize the summary hospital_summary$plot() + ggtitle(\"Daily Hospitalizations by Age and Zone\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"specifying-disease-parameters-by-demographics","dir":"Articles","previous_headings":"","what":"Specifying Disease Parameters by Demographics","title":"Running a Simulation with metaRVM","text":"disease parameters can also specified different demographic subgroups. subgroup-specific parameters override global parameters. details, refer yaml-configuration vignette. example YAML file provided, example_config_subgroup_dist.yaml, demonstrates feature. also includes parameters defined distributions. Now, let’s run simulation configuration. can now plot results see impact subgroup-specific parameters. example, can compare number hospitalizations “65+” age group, dh 10, age groups use global dh drawn lognormal distribution.","code":"# Locate the example YAML configuration file with subgroup parameters yaml_file_subgroup <- system.file(\"extdata\", \"example_config_subgroup_dist.yaml\", package = \"MetaRVM\") run_id: ExampleRun_Subgroup_Dist population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: dist: uniform min: 0.3 max: 0.5 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: dist: lognormal mu: 2 sd: 0.5 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 sub_disease_params: age: 0-17: pea: 0.08 18-64: ts: 0.6 65+: # This fixed value will override the global lognormal distribution for dh dh: 10 phr: 0.9227 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 20 # Run the simulation with the subgroup configuration sim_out_subgroup <- metaRVM(yaml_file_subgroup) # Summarize hospitalizations by age group hospital_summary_subgroup <- sim_out_subgroup$summarize( group_by = c(\"age\"), disease_states = \"H\", stats = c(\"median\", \"quantile\"), quantiles = c(0.025, 0.975) ) # Plot the summary hospital_summary_subgroup$plot() + ggtitle(\"Daily Hospitalizations by Age Group (Subgroup Parameters)\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"YAML Configuration for metaRVM","text":"metaRVM package uses YAML file configure model parameters. vignette describes structure YAML configuration file, starting simple example progressively introducing advanced features.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"basic-configuration","dir":"Articles","previous_headings":"","what":"Basic Configuration","title":"YAML Configuration for metaRVM","text":"minimal configuration file specifies data sources, simulation settings, disease parameters fixed scalar values.","code":"run_id: SimpleRun population_data: initialization: data/population_init.csv vaccination: data/vaccination.csv mixing_matrix: weekday_day: data/m_weekday_day.csv weekday_night: data/m_weekday_night.csv weekend_day: data/m_weekend_day.csv weekend_night: data/m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2025 # m/d/Y length: 90 nsim: 1 random_seed: 42"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"configuration-sections","dir":"Articles","previous_headings":"Basic Configuration","what":"Configuration Sections","title":"YAML Configuration for metaRVM","text":"run_id: unique name simulation. population_data: Paths CSV files population demographics, initial state, vaccination schedules. mixing_matrix: Paths CSV files defining contact patterns different times week. disease_params: Disease characteristics. example, parameters single, fixed values. simulation_config: Settings simulation run, start date, duration, number simulations.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"input-file-structures","dir":"Articles","previous_headings":"Basic Configuration","what":"Input File Structures","title":"YAML Configuration for metaRVM","text":"metaRVM package requires several CSV files structured specific way. descriptions required input files, along examples look like.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"population-data-files","dir":"Articles","previous_headings":"Basic Configuration > Input File Structures","what":"Population Data Files","title":"YAML Configuration for metaRVM","text":"population_id: unique identifier subpopulation (sequential natural numbers: 1, 2, 3, …) N: total number individuals subpopulation S0: initial number susceptible individuals I0: initial number symptomatic infected individuals V0: initial number vaccinated individuals R0: initial number recovered individuals age: Age groups (e.g., “0-17”, “18-64”, “65+”) race: Race ethnicity categories zone: Healthcare zones geographic regions custom categories like income_level, occupation, risk_group, etc. Example population initialization file: vaccination: vaccination schedule file contains number vaccinations administered time. first column must date MM/DD/YYYY format, followed columns subpopulation order population_id initialization file. Example vaccination schedule file:","code":"#> First 10 rows of population_init_n24.csv: #> population_id age race zone N S0 I0 V0 R0 #> 1 1 0-17 A 11 30742 30711 31 0 7 #> 2 2 18-64 A 11 41429 41388 41 0 9 #> 3 3 65+ A 11 3321 3318 3 0 0 #> 4 4 0-17 B 11 70138 70068 70 0 6 #> 5 5 18-64 B 11 12298 12286 12 0 32 #> 6 6 65+ B 11 11549 11537 12 0 0 #> 7 7 0-17 C 11 84178 84094 84 0 13 #> 8 8 18-64 C 11 113521 113407 114 0 15 #> 9 9 65+ C 11 11924 11912 12 0 0 #> 10 10 0-17 D 11 199686 199486 200 0 14 #> #> ... (24 total rows) #> First 10 rows of vaccination_n24.csv: #> date v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 #> 1 09/16/2023 0 0 0 0 0 0 11 5 4 8 6 4 2 5 1 8 11 #> 2 09/23/2023 5 12 1 11 7 2 180 187 99 362 293 72 311 163 24 519 203 #> 3 09/30/2023 3 5 2 19 10 3 198 235 88 424 364 89 445 255 36 625 251 #> 4 10/07/2023 20 14 15 46 19 8 403 385 124 846 580 187 675 389 45 1242 347 #> 5 10/14/2023 28 29 19 81 50 7 471 425 105 997 511 162 727 400 42 1351 313 #> 6 10/21/2023 37 55 24 110 43 8 378 499 115 980 483 160 623 511 39 1212 317 #> 7 10/28/2023 28 43 19 86 48 16 339 464 88 809 438 126 548 411 52 1090 287 #> 8 11/04/2023 22 53 19 91 49 28 329 391 70 765 431 147 522 391 22 956 259 #> 9 11/11/2023 36 62 21 110 60 10 337 396 87 769 414 148 575 425 39 966 199 #> 10 11/18/2023 40 65 14 102 55 14 340 431 97 875 392 118 513 417 28 1041 231 #> v18 v19 v20 v21 v22 v23 v24 #> 1 5 0 0 0 0 0 3 #> 2 113 2 3 26 4 13 10 #> 3 119 4 22 27 2 18 27 #> 4 193 8 41 50 4 70 44 #> 5 161 10 98 217 36 123 98 #> 6 202 18 160 214 51 149 168 #> 7 152 32 199 273 60 153 267 #> 8 126 26 168 239 33 149 225 #> 9 149 26 197 255 52 142 275 #> 10 141 26 212 242 50 153 191 #> #> ... (51 total rows) #> #> Note: Columns represent vaccination counts for each population_id (1-24)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"mixing-matrix-files","dir":"Articles","previous_headings":"Basic Configuration > Input File Structures","what":"Mixing Matrix Files","title":"YAML Configuration for metaRVM","text":"mixing matrix files define contact patterns different subpopulations. file CSV without header, rows columns correspond subpopulations order population_id initialization file. values matrix represent proportion time individuals one subpopulation spend individuals another. sum row must equal 1. Example mixing matrix file (weekday day):","code":"#> First 10 rows and 10 columns of m_weekday_day.csv: #> V1 V2 V3 V4 V5 V6 #> 1 0.860000000 0.0010475811 0.003377249 0.001710217 0.0011920273 0.006571116 #> 2 0.003611954 0.9100000000 0.001328864 0.003596329 0.0027309903 0.004173784 #> 3 0.001344397 0.0072452422 0.870000000 0.002513688 0.0050834111 0.009789632 #> 4 0.006689671 0.0005482346 0.004749909 0.920000000 0.0070678313 0.001806128 #> 5 0.007740689 0.0039632387 0.004643154 0.001091787 0.8700000000 0.009791262 #> 6 0.006379144 0.0032865609 0.003432134 0.001761560 0.0071883914 0.890000000 #> 7 0.001444749 0.0064237517 0.002656119 0.001968115 0.0043013059 0.001206245 #> 8 0.002179355 0.0070411463 0.001587234 0.003439760 0.0033650992 0.006414028 #> 9 0.005390480 0.0066530217 0.005482305 0.003007641 0.0006105881 0.003145261 #> 10 0.001666809 0.0029011017 0.008534104 0.001698315 0.0098720801 0.004586367 #> V7 V8 V9 V10 #> 1 1.464237e-02 0.0143653234 0.0118876071 0.0080742019 #> 2 6.528305e-03 0.0041375710 0.0057636782 0.0054420004 #> 3 8.763376e-03 0.0005057071 0.0007488488 0.0073198670 #> 4 2.822754e-04 0.0070548564 0.0009509153 0.0012611329 #> 5 1.004983e-02 0.0041073157 0.0088236656 0.0006445009 #> 6 3.144937e-05 0.0085528740 0.0063335264 0.0023219191 #> 7 9.200000e-01 0.0035656434 0.0070237063 0.0042256901 #> 8 4.098307e-03 0.9100000000 0.0067478716 0.0100518811 #> 9 9.597300e-04 0.0002268853 0.9200000000 0.0009418937 #> 10 5.236045e-03 0.0065183293 0.0012107981 0.8700000000 #> #> Matrix dimensions: 24 x 24 #> Row sums (should all equal 1): #> [1] 1 1 1 1 1 1 1 1 1 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"disease-parameter-descriptions","dir":"Articles","previous_headings":"Basic Configuration","what":"Disease Parameter Descriptions","title":"YAML Configuration for metaRVM","text":"list disease parameters used metaRVM: ts: Transmission rate symptomatic individuals susceptible population. ve: Vaccine effectiveness (proportion, range: [0, 1]). dv: Mean duration (days) vaccinated state immunity wanes. dp: Mean duration (days) presymptomatic infectious state. de: Mean duration (days) exposed state. da: Mean duration (days) asymptomatic infectious state. ds: Mean duration (days) symptomatic infectious state. dh: Mean duration (days) hospitalized state. dr: Mean duration (days) immunity recovered state. pea: Proportion exposed individuals become asymptomatic (vs. presymptomatic) (range: 0-1). psr: Proportion symptomatic individuals recover directly (vs. requiring hospitalization) (range: 0-1). phr: Proportion hospitalized individuals recover (vs. die) (range: 0-1).","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"defining-parameters-with-distributions","dir":"Articles","previous_headings":"","what":"Defining Parameters with Distributions","title":"YAML Configuration for metaRVM","text":"Instead fixed values, can define disease parameters using statistical distributions. useful capturing uncertainty parameters. metaRVM supports uniform lognormal distributions. example defining ve, da, ds, dh distributions: uniform distribution, must specify min max values. lognormal distribution, must specify mu sd (mean standard deviation log scale).","code":"disease_params: ts: 0.5 ve: dist: uniform min: 0.29 max: 0.53 dv: 158 dp: 1 de: 3 da: dist: uniform min: 3 max: 7 ds: dist: uniform min: 5 max: 7 dh: dist: lognormal mu: 8 sd: 8.9 dr: 187 pea: 0.333 psr: 0.95 phr: 0.97"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"specifying-subgroup-parameters","dir":"Articles","previous_headings":"","what":"Specifying Subgroup Parameters","title":"YAML Configuration for metaRVM","text":"metaRVM allows specify different disease parameters various demographic subgroups using sub_disease_params section. subgroup-specific parameters override global parameters defined disease_params. demographic categories used section must match user-defined category column names initialization CSV file specified population_data. example, initialization file columns named age, income_level, occupation, can use categories sub_disease_params. specific values (e.g., \"0-4\", \"low\", \"healthcare\") must exactly match values columns. following example defines different parameters different age groups: configuration, individuals “0-4” age group dh (duration hospitalization) 4, overriding global dh value. Similarly, transmission rate ts “18-49” group set 0.01.","code":"sub_disease_params: age: 0-17: dh: 4 pea: 0.08 psr: 0.9303 phr: 0.9920 18-64: dh: 4 pea: 0.08 psr: 0.9726 phr: 0.9920 65+: dh: 7 pea: 0.05 psr: 0.9091 phr: 0.9227"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"checkpointing-and-restoring-simulations","dir":"Articles","previous_headings":"","what":"Checkpointing and Restoring Simulations","title":"YAML Configuration for metaRVM","text":"long-running simulations, useful save state model intermediate points. known checkpointing. metaRVM allows save checkpoints restore simulation saved state.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"enabling-checkpointing","dir":"Articles","previous_headings":"Checkpointing and Restoring Simulations","what":"Enabling Checkpointing","title":"YAML Configuration for metaRVM","text":"enable checkpointing, need add checkpoint_dir optionally checkpoint_dates simulation_config section YAML file. checkpoint_dir: directory checkpoint files saved. checkpoint_dates: list dates (MM/DD/YYYY format) save checkpoint. provided, single checkpoint saved end simulation. example configure checkpointing:","code":"simulation_config: start_date: 01/01/2025 length: 90 nsim: 10 random_seed: 42 checkpoint_dir: \"path/to/checkpoints\" checkpoint_dates: [\"01/15/2025\", \"01/30/2025\"]"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"restoring-from-a-checkpoint","dir":"Articles","previous_headings":"Checkpointing and Restoring Simulations","what":"Restoring from a Checkpoint","title":"YAML Configuration for metaRVM","text":"restore simulation checkpoint file, use restore_from parameter simulation_config section. initialize model state saved specified checkpoint file. restoring, start_date correspond next date checkpoint, length remaining duration simulation. Note instance simulation must restored individually.","code":"simulation_config: start_date: 01/30/2025 # Should be the next date of the checkpoint date length: 60 # Remaining simulation length nsim: 10 restore_from: \"path/to/checkpoints/checkpoint_2025-01-30_instance_1.Rda\""},{"path":"https://RESUME-Epi.github.io/MetaRVM/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Arindam Fadikar. Author, maintainer, copyright holder. Charles Macal. Contributor. Martinez Moyano Ignacio Javier. Contributor. Ozik Jonathan. Contributor.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Fadikar , Stevens , Rimer S, Martinez-Moyano , Collier N, Mabil C, Jorgensen E, Ruestow P, McSorley VE, Ozik J, Macal C (2025). \"Developing Deploying Use-Inspired Metapopulation Modeling Framework Detailed Tracking Stratified Health Outcomes.\" 2025 Winter Simulation Conference (WSC), 734--745. doi:10.1109/WSC68292.2025.11338996.","code":"@InProceedings{, title = {Developing and Deploying a Use-Inspired Metapopulation Modeling Framework for Detailed Tracking of Stratified Health Outcomes}, author = {Arindam Fadikar and Abby Stevens and Sara Rimer and Ignacio Martinez-Moyano and Nicholson Collier and Chol Mabil and Emile Jorgensen and Peter Ruestow and V. Eloesa McSorley and Jonathan Ozik and Charles Macal}, booktitle = {2025 Winter Simulation Conference (WSC)}, year = {2025}, pages = {734--745}, doi = {10.1109/WSC68292.2025.11338996}, }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"metarvm-","dir":"","previous_headings":"","what":"MetaRVM - Meta-population Respiratory Virus Model","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"compartmental model simulation code generic respiratory virus diseases.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"model","dir":"","previous_headings":"","what":"Model","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM open-source R package modeling spread infectious diseases subpopulations, can flexibly defined geography, demographics, stratifications. designed support real-time public health decision-making. MetaRVM metapopulation model, extends classic Susceptible-Infected-Recovered (SIR) framework propagating infection across interacting subpopulations (e.g., age groups, neighborhoods), whose interactions governed realistic mixing patterns. MetaRVM model builds upon SEIR framework introducing additional compartments capture detailed dynamics disease progression, allowing heterogeneous mixing among different demographic stratum. generalizations allow model account factors vaccinations, hospitalizations, fatalities. Model schematics details, please refer paper: Developing deploying use-inspired metapopulation modeling framework detailed tracking stratified health outcomes","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"Full documentation available : https://RESUME-Epi.github.io/MetaRVM/","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"installation","dir":"","previous_headings":"Quickstart guide","what":"Installation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"current CRAN release 2.0.0. Install :","code":"install.packages(\"MetaRVM\")"},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"running-a-simulation","dir":"","previous_headings":"Quickstart guide","what":"Running a simulation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"content yaml configuration file:","code":"library(MetaRVM) options(odin.verbose = FALSE) ## prepare the configuration file cfg <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") run_id: ExampleRun population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 10/01/2023 # m/d/Y length: 150 nsim: 1 # run simulation sim_out <- metaRVM(cfg) #> Loading required namespace: pkgbuild # basic plot: daily hospitalizations by date library(ggplot2) hosp <- sim_out$results[disease_state == \"H\"] hosp_sum <- hosp[disease_state == \"H\", .(total = sum(value)), by = \"date\"] ggplot(hosp_sum, aes(date, total)) + geom_line(, color = \"red\") + labs(y = \"Hospitalizations\", x = \"Date\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"model-structure","dir":"","previous_headings":"","what":"Model structure","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM implements stratified SEIR-type metapopulation model vaccination, hospitalization, immunity waning, reinfection. core health states demographic stratum : Susceptible S Vaccinated V Exposed E Asymptomatic infectious I_asymp Presymptomatic infectious I_presymp Symptomatic infectious I_symp Hospitalized H Recovered R Deceased D start simulation, nearly individuals S, optional seeding initial infections /vaccinated individuals V. susceptible vaccinated individuals come contact infectious individuals, become exposed (E) based age/stratum-specific forces infection vaccine protection. Exposed individuals progress asymptomatic, presymptomatic, symptomatic infectious states either recovering, hospitalized, dying. Vaccinated recovered immunity can wane time, returning individuals susceptible pool, allows MetaRVM represent multiple respiratory pathogens different natural histories. Transmission stratified user-defined demographic groups (e.g., age, zone, race). Time-varying mixing matrices define strata interact (daytime vs. nighttime, weekday vs. weekend), MetaRVM computes stratum-specific forces infection susceptible vaccinated individuals. Hospitalized deceased individuals excluded “effective” mixing population. model can run deterministic stochastic mode, parameters supplied YAML configuration.","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"transmission-and-mixing-parameters","dir":"","previous_headings":"Model structure","what":"Transmission and mixing parameters","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"parameters drive transitions S V E, determine quickly individuals move infectious, hospitalized, recovered, deceased states.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"required-input-data-and-configuration","dir":"","previous_headings":"Model structure","what":"Required input data and configuration","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM configured YAML file small set CSV inputs.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"model-output-structure","dir":"","previous_headings":"Model structure","what":"Model output structure","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM produces simulation results unified tidy long-format table easy analyze data.table, dplyr, ggplot2. Every record corresponds single compartment count flow quantity specific demographic stratum, simulation date, scenario/instance. core output available : sim$results — compartment counts flows day sim$config — configuration object used generate run","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"further-examples-and-full-documentation","dir":"","previous_headings":"","what":"Further examples and full documentation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM includes several vignettes demonstrate common workflows using real model configurations data. provide detailed, step--step examples prepare inputs, configure model, run simulations, analyze outputs. vignettes can accessed : https://resume-epi.github.io/MetaRVM/articles/ List vignettes: Getting Started gentle introduction showing load configuration file, run simulation, inspect outputs. Model Configurations detailed walkthrough YAML structure, required fields, parameter blocks, optional modules, define population strata mixing patterns. Running Simulation Full example using complete set input files, showing MetaRVM reads population initialization data, mixing matrices, vaccination schedules. Checkpointing Restoring Demonstrates run many scenarios scale, resume long runs, store intermediate model states. complete function reference, visit: https://resume-epi.github.io/MetaRVM/reference/","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVM-package.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM: Meta-Population Compartmental Model for Respiratory Virus Diseases — MetaRVM-package","title":"MetaRVM: Meta-Population Compartmental Model for Respiratory Virus Diseases — MetaRVM-package","text":"Simulates respiratory virus epidemics using meta-population compartmental models following Fadikar et. al. (2025) doi:10.1109/WSC68292.2025.11338996 . 'MetaRVM' implements stochastic SEIRD (Susceptible-Exposed-Infected-Recovered-Dead) framework demographic stratification user provided attributes. supports complex epidemiological scenarios including asymptomatic presymptomatic transmission, hospitalization dynamics, vaccination schedules, time-varying contact patterns via mixing matrices.","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVM-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM: Meta-Population Compartmental Model for Respiratory Virus Diseases — MetaRVM-package","text":"Maintainer: Arindam Fadikar afadikar@anl.gov (ORCID) [copyright holder] contributors: Charles Macal [contributor] Martinez Moyano Ignacio Javier [contributor] Ozik Jonathan [contributor]","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Checkpoint Class — MetaRVMCheck","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"R6 class handle MetaRVM checkpoint data. class simplified version MetaRVMConfig tailored storing accessing simulation checkpoints.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVMCheck class designed hold state simulation specific time point, allowing continuation analysis. stores necessary parameters population states.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"super-class","dir":"Reference","previous_headings":"","what":"Super class","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVM::MetaRVMConfig -> MetaRVMCheck","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"check_data List containing parsed checkpoint data","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"methods","dir":"Reference","previous_headings":"","what":"Methods","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVM::MetaRVMConfig$get() MetaRVM::MetaRVMConfig$get_all() MetaRVM::MetaRVMConfig$get_all_categories() MetaRVM::MetaRVMConfig$get_category_names() MetaRVM::MetaRVMConfig$get_category_values() MetaRVM::MetaRVMConfig$get_pop_map() MetaRVM::MetaRVMConfig$list_parameters() MetaRVM::MetaRVMConfig$parameter_summary() MetaRVM::MetaRVMConfig$print() MetaRVM::MetaRVMConfig$set()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVMCheck$new() MetaRVMCheck$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"Initialize new MetaRVMCheck object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"","code":"MetaRVMCheck$new(input)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"input list containing checkpoint data.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"new MetaRVMCheck object.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"","code":"MetaRVMCheck$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Configuration Class — MetaRVMConfig","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"R6 class handle MetaRVM configuration data validation methods. class encapsulates configuration parameters needed MetaRVM simulations, providing methods parameter access, validation, introspection.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"MetaRVMConfig class stores parsed configuration data YAML files provides structured access simulation parameters. automatically validates configuration completeness provides convenient methods accessing demographic categories, initialization-derived population metadata, simulation settings.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"config_file Path original YAML config file (applicable) config_data List containing parsed configuration parameters","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"MetaRVMConfig$new() MetaRVMConfig$get() MetaRVMConfig$get_all() MetaRVMConfig$list_parameters() MetaRVMConfig$parameter_summary() MetaRVMConfig$set() MetaRVMConfig$print() MetaRVMConfig$get_pop_map() MetaRVMConfig$get_category_names() MetaRVMConfig$get_category_values() MetaRVMConfig$get_all_categories() MetaRVMConfig$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Initialize new MetaRVMConfig object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$new(input)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"input Either file path (character) parsed config list","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"New MetaRVMConfig object (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-","dir":"Reference","previous_headings":"","what":"Method get()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get configuration parameter","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get(param)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"param Parameter name","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"requested parameter value","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-all-","dir":"Reference","previous_headings":"","what":"Method get_all()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get configuration parameters list","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_all()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Named list configuration parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-list-parameters-","dir":"Reference","previous_headings":"","what":"Method list_parameters()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"List available parameter names","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$list_parameters()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-3","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Character vector parameter names","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-parameter-summary-","dir":"Reference","previous_headings":"","what":"Method parameter_summary()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Show summary parameter types sizes","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-4","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$parameter_summary()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-4","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Data frame parameter information","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-set-","dir":"Reference","previous_headings":"","what":"Method set()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Set configuration parameter","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-5","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$set(param, value)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"param Character string. Parameter name set value value assign parameter","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-5","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Self (invisible) method chaining","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Print summary configuration","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-6","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$print()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-6","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Self (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-pop-map-","dir":"Reference","previous_headings":"","what":"Method get_pop_map()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get population mapping data","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-7","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_pop_map()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-7","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"data.table containing population_id user-defined demographic category columns","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-category-names-","dir":"Reference","previous_headings":"","what":"Method get_category_names()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get names category columns","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-8","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_category_names()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"details-1","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Category columns automatically detected initialization CSV file. column reserved column (population_id, N, S0, I0, R0, V0, etc.) treated demographic category (e.g., age, zone, income_level, occupation).","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-8","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Character vector category column names, empty vector categories","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"\\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") category_names <- config$get_category_names() # e.g., c(\"age\", \"zone\", \"risk_group\") }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-category-values-","dir":"Reference","previous_headings":"","what":"Method get_category_values()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get unique values specific category","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-9","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_category_values(category_name)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-3","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"category_name Character string specifying category name","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-9","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Character/numeric vector unique values specified category","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"examples-1","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"\\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") ages <- config$get_category_values(\"age\") # if age is defined income_levels <- config$get_category_values(\"income_level\") # if defined }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-all-categories-","dir":"Reference","previous_headings":"","what":"Method get_all_categories()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get categories named list","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-10","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_all_categories()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-10","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Named list names category column names values vectors unique values category. Returns empty list categories.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"examples-2","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"\\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") all_cats <- config$get_all_categories() # Returns: list(age = c(\"0-17\", \"18-64\", \"65+\"), risk_group = c(\"low\", \"high\"), ...) }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-11","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-4","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"# Initialize from YAML file example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") config <- MetaRVMConfig$new(example_config) # Access parameters config$get(\"N_pop\") #> [1] 24 config$get(\"start_date\") #> [1] \"2023-09-30\" # Get demographic category names (user-defined) category_names <- config$get_category_names() # e.g., c(\"age\", \"zone\", \"risk_group\") # Get values for specific categories ages <- config$get_category_values(\"age\") # Get all categories as a named list all_categories <- config$get_all_categories() ## ------------------------------------------------ ## Method `MetaRVMConfig$get_category_names` ## ------------------------------------------------ if (FALSE) { # \\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") category_names <- config$get_category_names() # e.g., c(\"age\", \"zone\", \"risk_group\") } # } ## ------------------------------------------------ ## Method `MetaRVMConfig$get_category_values` ## ------------------------------------------------ if (FALSE) { # \\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") ages <- config$get_category_values(\"age\") # if age is defined income_levels <- config$get_category_values(\"income_level\") # if defined } # } ## ------------------------------------------------ ## Method `MetaRVMConfig$get_all_categories` ## ------------------------------------------------ if (FALSE) { # \\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") all_cats <- config$get_all_categories() # Returns: list(age = c(\"0-17\", \"18-64\", \"65+\"), risk_group = c(\"low\", \"high\"), ...) } # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Results Class — MetaRVMResults","title":"MetaRVM Results Class — MetaRVMResults","text":"R6 class handle MetaRVM simulation results comprehensive analysis visualization methods. class stores formatted simulation results provides methods data summarization, subsetting, visualization flexible demographic groupings.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Results Class — MetaRVMResults","text":"MetaRVMResults class automatically formats raw simulation output upon initialization, converting time steps calendar dates adding demographic attributes. provides methods flexible data summarization across user-defined demographic categories, plus method chaining streamlined analysis workflows.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Results Class — MetaRVMResults","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Results Class — MetaRVMResults","text":"config MetaRVMConfig object used generate results results data.table containing formatted simulation results run_info List containing run metadata","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Results Class — MetaRVMResults","text":"MetaRVMResults$new() MetaRVMResults$print() MetaRVMResults$subset_data() MetaRVMResults$summarize() MetaRVMResults$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Results Class — MetaRVMResults","text":"Initialize new MetaRVMResults object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$new( raw_results, config, run_info = NULL, formatted_results = NULL )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"raw_results Raw simulation results data.table config MetaRVMConfig object used simulation run_info Optional metadata run formatted_results formatted simulation results data.table","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"New MetaRVMResults object (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"MetaRVM Results Class — MetaRVMResults","text":"Print summary results","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$print()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"Self (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-subset-data-","dir":"Reference","previous_headings":"","what":"Method subset_data()","title":"MetaRVM Results Class — MetaRVMResults","text":"Subset data based combination parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$subset_data( ..., disease_states = NULL, date_range = NULL, instances = NULL, exclude_p_columns = TRUE )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"... Named arguments category filters (e.g., age = c(\"0-17\"), income = c(\"low\", \"high\")) disease_states Vector disease states include (default: , excludes p_ columns) date_range Vector two dates start_date, end_date filtering (default: ) instances Vector instance numbers include (default: ) exclude_p_columns Logical, whether exclude p_ columns (default: TRUE)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"MetaRVMResults object subset results","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-summarize-","dir":"Reference","previous_headings":"","what":"Method summarize()","title":"MetaRVM Results Class — MetaRVMResults","text":"Summarize results across specified demographic characteristics","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$summarize( group_by, disease_states = NULL, date_range = NULL, stats = c(\"mean\", \"median\", \"sd\"), quantiles = c(0.25, 0.75), exclude_p_columns = TRUE )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"group_by Vector demographic category names group . Must valid category names configuration (e.g., c(\"age\", \"zone\"), c(\"income_level\", \"occupation\")). Use config$get_category_names() see available categories. disease_states Vector disease states include (default: , excludes p_ columns) date_range Optional date range filtering stats Vector statistics calculate: c(\"mean\", \"median\", \"sd\", \"min\", \"max\", \"sum\", \"quantile\"). NULL, returns instances quantiles Vector quantiles calculate \"quantile\" stats (default: c(0.25, 0.75)) exclude_p_columns Logical, whether exclude p_ columns (default: TRUE)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns-3","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"data.table summarized time series data instances stats = NULL","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Results Class — MetaRVMResults","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-4","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments-3","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") # Run simulation results_obj <- metaRVM(example_config) #> Loading required namespace: pkgbuild # Access formatted results head(results_obj$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1 # Subset data with multiple filters subset_data <- results_obj$subset_data( age = c(\"18-64\", \"65+\"), disease_states = c(\"H\", \"D\"), date_range = c(as.Date(\"2024-01-01\"), as.Date(\"2024-02-01\")) ) # Method chaining for analysis and visualization results_obj$subset_data(disease_states = \"H\")$summarize( group_by = c(\"age\", \"zone\"), stats = c(\"median\", \"quantile\"), quantiles = c(0.25, 0.75) )$plot() # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Summary Class — MetaRVMSummary","title":"MetaRVM Summary Class — MetaRVMSummary","text":"R6 class summarized MetaRVM results plotting capabilities method chaining support. class stores summarized simulation data provides visualization methods automatically adapt based data structure grouping variables.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Summary Class — MetaRVMSummary","text":"MetaRVMSummary class designed work seamlessly method chaining MetaRVMResults. stores either summary statistics (mean, median, quantiles, etc.) individual instance data, provides intelligent plotting methods automatically determine appropriate visualizations based data structure demographic groupings. class supports two data types: Summary data: Contains aggregated statistics across simulation instances Instance data: Contains individual trajectory data simulation instance Plotting behavior adapts automatically: Single grouping variable: Facets demographic category, colors disease state Two grouping variables: Grid layout demographics facet dimensions Three grouping variables: Grid layout first two facets, third color","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public Fields","title":"MetaRVM Summary Class — MetaRVMSummary","text":"data data.table containing summarized results config MetaRVMConfig object original simulation type Character string indicating data type (\"summary\" \"instances\")","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"public-fields-1","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Summary Class — MetaRVMSummary","text":"data Summarized data config Original MetaRVMConfig object type Type summary (\"instances\" \"summary\")","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Summary Class — MetaRVMSummary","text":"MetaRVMSummary$new() MetaRVMSummary$print() MetaRVMSummary$plot() MetaRVMSummary$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Initialize MetaRVMSummary object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$new(data, config, type)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Summary Class — MetaRVMSummary","text":"data data.table containing summarized instance data config MetaRVMConfig object original simulation type Character string indicating data type (\"summary\" \"instances\")","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Summary Class — MetaRVMSummary","text":"New MetaRVMSummary object (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Print summary data object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$print()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Self (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-plot-","dir":"Reference","previous_headings":"","what":"Method plot()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Plot method shows median quantile bands","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$plot(ci_level = 0.95, theme = theme_minimal(), title = NULL)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Summary Class — MetaRVMSummary","text":"ci_level Confidence level empirical quantiles (default: 0.95). used quantile columns pre-specified theme ggplot2 theme function (default: theme_minimal()) title Optional custom plot title","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"details-1","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Summary Class — MetaRVMSummary","text":"method creates time series plots automatic layout adaptation based grouping variables: summary data: Shows median lines quantile confidence bands Automatically determines faceting strategy based number grouping variables Uses disease states color differentiation appropriate method requires specific data structure: Summary data must contain 'median_value' quantile columns (e.g., 'q25', 'q75') Instance data must contain 'instance' column individual trajectory grouping","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Summary Class — MetaRVMSummary","text":"ggplot object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Summary Class — MetaRVMSummary","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config_dist.yaml\", package = \"MetaRVM\") # Run simulation results <- metaRVM(example_config) # Typically created through method chaining summary_obj <- results$subset_data(disease_states = \"H\")$summarize( group_by = c(\"age\", \"zone\"), stats = c(\"median\", \"quantile\"), quantiles = c(0.25, 0.75) ) # Direct plotting summary_obj$plot() # Plot with custom ggplot theme and confidence level summary_obj$plot(theme = ggplot2::theme_bw()) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to draw samples for distributional parameters — draw_sample","title":"Function to draw samples for distributional parameters — draw_sample","text":"Function draw samples distributional parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to draw samples for distributional parameters — draw_sample","text":"","code":"draw_sample(config_list, N_pop, seed = NULL)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to draw samples for distributional parameters — draw_sample","text":"config_list list configurations N_pop Number subpopulations seed","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to draw samples for distributional parameters — draw_sample","text":"random sample drawn distribution specified dist component","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":null,"dir":"Reference","previous_headings":"","what":"Format MetaRVM simulation output — format_metarvm_output","title":"Format MetaRVM simulation output — format_metarvm_output","text":"function formats raw MetaRVM simulation output : Converting time steps calendar dates Adding user-defined demographic attributes initialization-derived population metadata Handling different disease states appropriately: Regular states (S, E, , etc.): Keep values integer time points New count states (n_ prefix): Sum pairs get daily counts","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format MetaRVM simulation output — format_metarvm_output","text":"","code":"format_metarvm_output(sim_output, config)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format MetaRVM simulation output — format_metarvm_output","text":"sim_output data.table containing raw simulation output meta_sim config MetaRVMConfig object config list containing parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format MetaRVM simulation output — format_metarvm_output","text":"data.table formatted output including calendar dates demographics","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Format MetaRVM simulation output — format_metarvm_output","text":"function used formatting meta_sim output MetaRVM function called.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":null,"dir":"Reference","previous_headings":"","what":"NULL Coalescing Operator — grapes-or-or-grapes","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"Returns left-hand side NULL, otherwise returns right-hand side. utility function used internally MetaRVM classes.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"","code":"x %||% y"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"x Left-hand side value y Right-hand side value (default/fallback)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"x x NULL, otherwise y","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"","code":"if (FALSE) { # \\dontrun{ user_title <- \"User Title\" # Internal usage in classes title <- user_title %||% \"Default Title\" } # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":null,"dir":"Reference","previous_headings":"","what":"Run a MetaRVM epidemic simulation — metaRVM","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"metaRVM() high-level entry point running MetaRVM metapopulation respiratory virus simulation. parses configuration, runs one simulation instances (deterministic stochastic), formats ODIN/MetaRVM output tidy long table calendar dates demographic attributes, returns MetaRVMResults object downstream analysis plotting.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"","code":"metaRVM(config_input)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"config_input Configuration specification one three forms: Character string: path YAML configuration file. MetaRVMConfig object: pre-initialized configuration. Named list: output parse_config() return_object = FALSE.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"MetaRVMResults R6 object three key components: $results tidy data.table one row per date–subpopulation–disease state–instance combination. Typical columns include: date: calendar date (Date) user-defined demographic category columns (present initialization file) disease_state: compartment flow label (e.g., S, E, I_symp, H, R, D, n_SE, n_IsympH, etc.) value: population count daily flow instance: simulation instance index (1, 2, …) $config MetaRVMConfig object used run. $run_info list metadata n_instances, date_range, delta_t, checkpoint information.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"configuration input controls: Population structure (user-defined categories initial compartment counts initialization file) Disease parameters (ts, ve, de, dp, da, ds, dh, dr, pea, psr, phr, dv, etc.) Mixing matrices (weekday/weekend, day/night contact patterns) Vaccination schedule immunity waning Simulation settings (start date, length, number instances, stochastic vs. deterministic mode, checkpointing) Internally, metaRVM(): Parses YAML configuration via parse_config(). Calls ODIN-based simulation engine meta_sim() instance. Uses format_metarvm_output() convert time steps dates attach demographic attributes. Wraps formatted output metadata MetaRVMResults object supports method chaining subsetting, summarizing, plotting.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"Fadikar, ., et al. \"Developing deploying use-inspired metapopulation modeling framework detailed tracking stratified health outcomes\"","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"Arindam Fadikar, Charles Macal, Ignacio Martinez-Moyano, Jonathan Ozik","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") # Run a single-instance simulation from a YAML file results <- metaRVM(example_config) # Print a high-level summary results #> MetaRVM Results Object #> ===================== #> Instances: 1 #> Populations: 24 #> Date range: 2023-10-01 to 2024-02-27 #> Total observations: 111600 #> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, V, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_SE, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_SE, p_VE # Access the tidy results table head(results$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.305178e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.731688e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.227854e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.476245e+01 1 # Summarize and plot hospitalizations and deaths by user-defined categories results$summarize( group_by = c(\"age\", \"zone\"), disease_states = c(\"H\", \"D\"), stats = c(\"median\", \"quantile\"), quantiles = c(0.25, 0.75) )$plot() # Using a pre-parsed configuration object cfg <- parse_config(example_config, return_object = TRUE) results2 <- metaRVM(cfg) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":null,"dir":"Reference","previous_headings":"","what":"Metapopulation Respiratory Virus Model Simulator — meta_sim","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"core simulation engine implements stochastic compartmental SEIRD (Susceptible-Exposed-Infected-Recovered-Dead) model respiratory virus epidemics across multiple demographic subpopulations. function compiles executes ODIN-based differential equation model time-varying contact patterns, vaccination dynamics, complex disease progression pathways.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"","code":"meta_sim( N_pop, ts, S0, I0, P0, R0, H0 = rep(0, N_pop), D0 = rep(0, N_pop), Ia0 = rep(0, N_pop), Ip0 = rep(0, N_pop), E0 = rep(0, N_pop), V0 = rep(0, N_pop), m_weekday_day, m_weekday_night, m_weekend_day, m_weekend_night, start_day = 0, delta_t, vac_mat, dv, de, pea, dp, da, ds, psr, dh, phr, dr, ve, nsteps, is.stoch = FALSE, seed = NULL, do_chk = FALSE, chk_time_steps = NULL, chk_file_names = NULL )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"N_pop Integer. Number demographic subpopulations model ts Numeric vector scalar. Transmission rate symptomatic individuals susceptible population. scalar, applied subpopulations S0 Numeric vector length N_pop. Initial number susceptible individuals subpopulation I0 Numeric vector length N_pop. Initial number symptomatic infected individuals subpopulation P0 Numeric vector length N_pop. Total population sizes subpopulation R0 Numeric vector length N_pop. Initial number recovered individuals subpopulation H0 Numeric vector length N_pop. Initial number hospitalized individuals subpopulation (default: rep(0, N_pop)) D0 Numeric vector length N_pop. Initial number deceased individuals subpopulation (default: rep(0, N_pop)) Ia0 Numeric vector length N_pop. Initial number asymptomatic infected individuals subpopulation (default: rep(0, N_pop)) Ip0 Numeric vector length N_pop. Initial number presymptomatic infected individuals subpopulation (default: rep(0, N_pop)) E0 Numeric vector length N_pop. Initial number exposed individuals subpopulation (default: rep(0, N_pop)) V0 Numeric vector length N_pop. Initial number vaccinated individuals subpopulation m_weekday_day Numeric matrix (N_pop × N_pop). Contact mixing matrix weekday daytime (6 - 6 PM) interactions m_weekday_night Numeric matrix (N_pop × N_pop). Contact mixing matrix weekday nighttime (6 PM - 6 ) interactions m_weekend_day Numeric matrix (N_pop × N_pop). Contact mixing matrix weekend daytime (6 - 6 PM) interactions m_weekend_night Numeric matrix (N_pop × N_pop). Contact mixing matrix weekend nighttime (6 PM - 6 ) interactions start_day Start day week expressed integer value 0 6, 0 Monday. Default simulation start day Monday. delta_t Positive numeric. Discrete time increment days (typically 0.5) vac_mat Numeric matrix. Vaccination schedule dimensions (nsteps × (1 + N_pop)). First column contains time indices, remaining columns contain vaccination counts subpopulation time step dv Numeric vector scalar. Mean duration (days) vaccinated state immunity waning. scalar, applied subpopulations de Numeric vector scalar. Mean duration (days) exposed state. scalar, applied subpopulations pea Numeric vector scalar. Proportion exposed individuals becoming asymptomatic infectious (vs. presymptomatic), values 0 1. scalar, applied subpopulations. scalar, applied subpopulations dp Numeric vector scalar. Mean duration (days) presymptomatic infectious state. scalar, applied subpopulations da Numeric vector scalar. Mean duration (days) asymptomatic infectious state. scalar, applied subpopulations ds Numeric vector scalar. Mean duration (days) symptomatic infectious state. scalar, applied subpopulations psr Numeric vector scalar. Proportion symptomatic individuals recovering directly (vs. hospitalization), values 0 1. scalar, applied subpopulations. scalar, applied subpopulations dh Numeric vector scalar. Mean duration (days) hospitalized state. scalar, applied subpopulations phr Numeric vector scalar. Proportion hospitalized individuals recovering (vs. death). , values 0 1. scalar, applied subpopulations. dr Numeric vector scalar. Mean duration (days) immunity recovered state. scalar, applied subpopulations ve Numeric vector scalar. Vaccine effectiveness (proportion) , values 0 1. scalar, applied subpopulations nsteps Integer. Total number discrete time evolution steps simulation .stoch Logical. Whether run stochastic simulation (TRUE) deterministic simulation (FALSE). Default: FALSE seed Integer NULL. Random seed reproducibility. used .stoch = TRUE. Default: NULL do_chk Logical. Whether save model checkpoint simulation end. Default: FALSE chk_time_steps Integer vector NULL. Time steps save checkpoints. chk_file_names List character vectors NULL. File names checkpoints. element list corresponds time step chk_time_steps.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"Returns data.table following structure: step Integer time step index (0 nsteps) time Continuous simulation time (step × delta_t) disease_state Character vector compartment names population_id Character vector subpopulation identifiers value Numeric values representing population counts compartment Available disease states output: Core compartments: S, E, I_presymp, I_asymp, I_symp, H, R, D, V, P Derived outputs: I_all (total infectious), cum_V (cumulative vaccinations) Transition flows: n_SE, n_EI, n_HR, n_HD, etc. (new infections, hospitalizations, deaths) Debug outputs: p_SE, p_VE, I_eff (probabilities effective populations)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"model implements metapopulation epidemiological framework following features: Compartmental Structure: S: Susceptible individuals E: Exposed (incubating) individuals I_presymp: Presymptomatic infectious individuals I_asymp: Asymptomatic infectious individuals I_symp: Symptomatic infectious individuals H: Hospitalized individuals R: Recovered individuals D: Deceased individuals V: Vaccinated individuals P: Total living population (excludes deaths) Disease Progression Pathways: S → E: Exposure contact infectious individuals E → I_asymp/I_presymp: Progression infectious states (proportion pea) I_presymp → I_symp: Development symptoms I_asymp → R: Direct recovery asymptomatic state I_symp → R/H: Recovery hospitalization (proportion psr) H → R/D: Hospital discharge death (proportion phr) R → S: Loss immunity S → V: Vaccination V → S/E: Vaccine waning breakthrough infection Mixing Patterns: Contact patterns vary : Day week: Weekday vs. weekend patterns Time day: Day (6 - 6 PM) vs. night (6 PM - 6 ) patterns pattern specified N_pop × N_pop contact matrix Force Infection: Transmission occurs contact susceptible/vaccinated individuals infectious compartments (I_presymp + I_asymp + I_symp), modified : Population-specific transmission rate, ts Time-varying contact patterns Vaccine effectiveness breakthrough infections Stochastic vs. Deterministic Mode: Deterministic: Uses exact differential equations Stochastic: Adds demographic stochasticity via binomial draws Vaccination Implementation: Vaccination implemented time-varying input : Scheduled vaccination counts per time step subpopulation Vaccine effectiveness reducing infection probability Waning immunity returning individuals susceptible state","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"parameter-scaling","dir":"Reference","previous_headings":"","what":"Parameter Scaling","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"duration parameters automatically converted rates (1/duration). Scalar parameters automatically expanded vectors length N_pop. allows flexible specification homogeneous heterogeneous parameters.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"checkpointing","dir":"Reference","previous_headings":"","what":"Checkpointing","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"do_chk = TRUE, function saves checkpoint file containing: Final compartment states simulation continuation model parameters reproducibility Vaccination schedule data Population structure information","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"ODIN package: https://mrc-ide.github.io/odin/ Fadikar, ., et al. \"Developing deploying use-inspired metapopulation modeling framework detailed tracking stratified health outcomes\"","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"Arindam Fadikar, Charles Macal, Ignacio Martinez-Moyano, Jonathan Ozik","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) # Basic deterministic simulation N_pop <- 2 nsteps <- 400 # Initialize populations S0 <- rep(1000, N_pop) I0 <- rep(10, N_pop) P0 <- S0 + I0 R0 <- rep(0, N_pop) # Contact matrices (simplified - identity matrices) contact_matrix <- diag(N_pop) # Basic vaccination schedule (10% vaccination) vac_mat <- matrix(0, nrow = nsteps + 1, ncol = N_pop + 1) vac_mat[, 1] <- 0:nsteps vac_mat[1, 1 + (1:N_pop)] <- P0 * 0.1 # Run simulation results <- meta_sim( N_pop = N_pop, ts = 0.5, S0 = S0, I0 = I0, P0 = P0, R0 = R0, m_weekday_day = contact_matrix, m_weekday_night = contact_matrix, m_weekend_day = contact_matrix, m_weekend_night = contact_matrix, delta_t = 0.5, vac_mat = vac_mat, dv = 365, de = 3, pea = 0.3, dp = 2, da = 7, ds = 7, psr = 0.95, dh = 10, phr = 0.9, dr = 180, ve = 0.8, nsteps = nsteps, is.stoch = FALSE ) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse MetaRVM Configuration File — parse_config","title":"Parse MetaRVM Configuration File — parse_config","text":"Reads parses YAML configuration file MetaRVM simulations, extracting necessary parameters epidemic modeling including population data, disease parameters, mixing matrices, vaccination schedules, simulation settings.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse MetaRVM Configuration File — parse_config","text":"","code":"parse_config(config_file, return_object = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse MetaRVM Configuration File — parse_config","text":"config_file Character string. Path YAML configuration file containing model parameters settings. return_object Logical. TRUE, returns MetaRVMConfig object method chaining enhanced functionality. FALSE (default), returns named list backward compatibility.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse MetaRVM Configuration File — parse_config","text":"return_object = FALSE (default), returns named list containing: N_pop Number population groups pop_map Data.table population_id user-defined demographic categories S_ini, E_ini, I_asymp_ini, I_presymp_ini, I_symp_ini, H_ini, D_ini, P_ini, V_ini, R_ini Initial compartment populations vac_time_id, vac_counts, vac_mat Vaccination schedule data m_wd_d, m_wd_n, m_we_d, m_we_n Contact mixing matrices ts, ve, dv, de, dp, da, ds, dh, dr, pea, psr, phr Disease parameter matrices (nsim × N_pop) start_date Simulation start date Date object sim_length Simulation length days nsim Number simulation instances random_seed Random seed used () delta_t Time step size (fixed 0.5) chk_file_names, chk_time_steps, do_chk Checkpointing configuration return_object = TRUE, returns MetaRVMConfig object methods parameter access validation.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Parse MetaRVM Configuration File — parse_config","text":"function processes YAML configuration file following main sections: Simulation Configuration: random_seed: Optional random seed reproducibility case stochastic simulations stochastic parameters nsim: Number simulation instances (default: 1) start_date: Simulation start date MM/DD/YYYY format length: Simulation length days checkpoint_dir: Optional checkpoint directory saving intermediate results checkpoint_dates: Optional list dates save checkpoints. restore_from: Optional path restore simulation checkpoint Population Data: initialization: CSV file initial population states optional user-defined category columns. file must contain columns population_id, N, S0, I0, V0, R0. additional columns treated demographic categories. vaccination: CSV file vaccination schedule time. first column must dates MM/DD/YYYY format. rest columns must corresponds respective subpopulations numeric order population_id. Mixing Matrices: Contact matrices different time periods. CSV file must matrix order (N_pop x N_pop), , N_pop number subpopulations. assumed -th row j-th column correspond -th j-th subpopulations. weekday_day, weekday_night: Weekday contact patterns weekend_day, weekend_night: Weekend contact patterns Disease Parameters: Epidemiological parameters (can scalars distributions): ts: Transmission rate symptomatic individuals ve: Vaccine effectiveness de, dp, da, ds, dh, dr: Duration parameters different disease states pea, psr, phr: Probability parameters disease transitions Sub-population Parameters: sub_disease_params allows specification different parameter values specific demographic categories (e.g., age groups, races). function supports stochastic parameters distribution specifications dist, mu, sd, shape, rate, etc.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"parameter-distributions","dir":"Reference","previous_headings":"","what":"Parameter Distributions","title":"Parse MetaRVM Configuration File — parse_config","text":"Disease parameters can specified distributions stochastic modeling: lognormal: dist: \"lognormal\", mu: value, sd: value gamma: dist: \"gamma\", shape: value, rate: value uniform: dist: \"uniform\", min: value, max: value beta: dist: \"beta\", shape1: value, shape2: value gaussian: dist: \"gaussian\", mean: value, sd: value","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"file-requirements","dir":"Reference","previous_headings":"","what":"File Requirements","title":"Parse MetaRVM Configuration File — parse_config","text":"Population initialization file must contain columns: population_id: Unique identifier population group, natural numbers N: Total population size subpopulation S0, I0, V0, R0: Initial compartment counts Optional user-defined category columns (e.g., age, race, zone, income_level, occupation) Vaccination file must contain: date (MM/DD/YYYY format) vaccination counts population group","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Parse MetaRVM Configuration File — parse_config","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Parse MetaRVM Configuration File — parse_config","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") # Parse configuration file and return list (backward compatible) config <- parse_config(example_config) # Parse and return MetaRVMConfig object for method chaining config_obj <- parse_config(example_config, return_object = TRUE) # Access parameters from config object config_obj$get(\"N_pop\") #> [1] 24 config_obj$list_parameters() #> [1] \"N_pop\" \"pop_map\" \"category_names\" \"S_ini\" #> [5] \"E_ini\" \"I_asymp_ini\" \"I_presymp_ini\" \"I_symp_ini\" #> [9] \"H_ini\" \"D_ini\" \"P_ini\" \"V_ini\" #> [13] \"R_ini\" \"vac_time_id\" \"vac_counts\" \"vac_mat\" #> [17] \"m_wd_d\" \"m_wd_n\" \"m_we_d\" \"m_we_n\" #> [21] \"ts\" \"ve\" \"dv\" \"de\" #> [25] \"dp\" \"da\" \"ds\" \"dh\" #> [29] \"dr\" \"pea\" \"psr\" \"phr\" #> [33] \"start_date\" \"sim_length\" \"nsim\" \"random_seed\" #> [37] \"delta_t\" \"chk_file_names\" \"chk_time_steps\" \"do_chk\" # Use with MetaRVM simulation results <- metaRVM(config_obj) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Read and prepare vaccination data — process_vac_data","title":"Read and prepare vaccination data — process_vac_data","text":"function takes vaccination schedule given data.table prepares according required structure needed meta_sim() function","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read and prepare vaccination data — process_vac_data","text":"","code":"process_vac_data(vac_dt, sim_start_date, sim_length, delta_t)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read and prepare vaccination data — process_vac_data","text":"vac_dt data.table vaccination schedule sim_start_date calendar date format yyyy-mm-dd sim_length Number calendar days simulation runs delta_t Step size simulation","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read and prepare vaccination data — process_vac_data","text":"data.table","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/news/index.html","id":"metarvm-200","dir":"Changelog","previous_headings":"","what":"MetaRVM 2.0.0","title":"MetaRVM 2.0.0","text":"CRAN release: 2026-03-19 Subpopulation categories now user-defined population_data$initialization; non-reserved columns detected automatically. Improved checkpoint restore behavior parse_config(): restore_from provided, population_data$initialization can used mapping-metadata (without N, S0, I0, etc.). Improved validation messages category filters: invalid category names now list available categories, invalid category values now list valid values selected category. Improved format_metarvm_output() handling population_id dynamic column selection user-defined categories. Updated documentation vignettes reflect user-defined subpopulation categories checkpoint restore behavior.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/news/index.html","id":"metarvm-101","dir":"Changelog","previous_headings":"","what":"MetaRVM 1.0.1","title":"MetaRVM 1.0.1","text":"CRAN release: 2026-01-09","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/news/index.html","id":"metarvm-100","dir":"Changelog","previous_headings":"","what":"MetaRVM 1.0.0","title":"MetaRVM 1.0.0","text":"CRAN release: 2025-12-19 Initial CRAN submission.","code":""}]
+[{"path":"https://RESUME-Epi.github.io/MetaRVM/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 MetaRVM authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Checkpointing in MetaRVM","text":"vignette demonstrates configure use checkpointing functionality MetaRVM examples. Checkpointing allows store model state specific time points simulation, allowing one resume runs saved states.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"how-checkpointing-works","dir":"Articles","previous_headings":"","what":"How Checkpointing Works","title":"Checkpointing in MetaRVM","text":"MetaRVM’s checkpointing system configured YAML configuration file. Saving checkpoints: simulation, complete state (compartments, parameters, time step) saved disk specified dates Restoring checkpoints: new simulation can initialized previously saved checkpoint, continuing point forward Flexible scheduling: Exact dates checkpoints saved supplied, default checkpoint end--simulation date.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"configuration-parameters","dir":"Articles","previous_headings":"How Checkpointing Works","what":"Configuration Parameters","title":"Checkpointing in MetaRVM","text":"checkpointing system uses three main configuration options simulation_config section: checkpoint_dir: Directory checkpoint files saved (created doesn’t exist) checkpoint_dates: (Optional) List specific dates checkpoints saved restore_from: (Optional) Path checkpoint file resume ","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"example","dir":"Articles","previous_headings":"","what":"Example","title":"Checkpointing in MetaRVM","text":"purpose example, set checkpointed directory temporary directory, create temporary yaml configuration file based template.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"set-up","dir":"Articles","previous_headings":"Example","what":"Set Up","title":"Checkpointing in MetaRVM","text":"","code":"library(MetaRVM) options(odin.verbose = FALSE) # Get the example configuration file example_config <- system.file(\"extdata\", \"example_config_checkpoint.yaml\", package = \"MetaRVM\") # Create a temporary directory for checkpoints checkpoint_dir <- tempdir() cat(\"Checkpoint directory:\", checkpoint_dir, \"\\n\") #> Checkpoint directory: /tmp/RtmpdtpnKS"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"create-a-configuration-with-checkpointing","dir":"Articles","previous_headings":"Example","what":"Create a Configuration with Checkpointing","title":"Checkpointing in MetaRVM","text":"Now copy example configuration modify add checkpointing:","code":"# Read the example configuration yml <- yaml::read_yaml(example_config) yml_tmp <- data.table::copy(yml) # Assign checkpoint directory yml_tmp$simulation_config$checkpoint_dir <- checkpoint_dir # Create a temporary config temp_config <- tempfile(tmpdir = dirname(example_config), fileext = \".yaml\") yaml::write_yaml(yml_tmp, temp_config) temp_config <- normalizePath(temp_config)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"run-simulation-with-checkpoints","dir":"Articles","previous_headings":"Example","what":"Run Simulation with Checkpoints","title":"Checkpointing in MetaRVM","text":"","code":"# Run the simulation results <- metaRVM(temp_config) # Check what checkpoint files were created checkpoint_files <- list.files(checkpoint_dir, pattern = \"^chk_.*\\\\.Rda$\", full.names = FALSE) if (length(checkpoint_files) > 0) { for (file in checkpoint_files) { cat(\" -\", file, \"\\n\") } } else { cat(\" (No checkpoint files found)\\n\") } #> - chk_2024-12-29_1.Rda"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"examine-the-results","dir":"Articles","previous_headings":"Example","what":"Examine the Results","title":"Checkpointing in MetaRVM","text":"","code":"cat(\"Number of instances:\", results$run_info$n_instances, \"\\n\") #> Number of instances: 1 cat(\"Date range:\", format(results$run_info$date_range[1]), \"to\", format(results$run_info$date_range[2]), \"\\n\") #> Date range: 2024-10-01 to 2024-12-29 # Display first few rows print(head(results$results, 10)) #> date age race zone disease_state value instance #> #> 1: 2024-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2024-10-01 0-17 A 11 E 1.366242e+01 1 #> 3: 2024-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2024-10-01 0-17 A 11 I_all 2.742766e+01 1 #> 5: 2024-10-01 0-17 A 11 I_asymp 3.560183e-01 1 #> 6: 2024-10-01 0-17 A 11 I_eff 2.656285e+01 1 #> 7: 2024-10-01 0-17 A 11 I_presymp 8.307093e-01 1 #> 8: 2024-10-01 0-17 A 11 I_symp 2.624093e+01 1 #> 9: 2024-10-01 0-17 A 11 P 3.074200e+04 1 #> 10: 2024-10-01 0-17 A 11 R 1.148308e+01 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"resume-from-a-checkpoint","dir":"Articles","previous_headings":"Example","what":"Resume from a Checkpoint","title":"Checkpointing in MetaRVM","text":"’ll create new configuration restores checkpoint. need provide checkpoint file name, start date next day end date previous run.","code":"# Get the first checkpoint file checkpoint_files_full <- list.files(checkpoint_dir, pattern = \"^chk_.*\\\\.Rda$\", full.names = TRUE) if (length(checkpoint_files_full) > 0) { checkpoint_to_restore <- checkpoint_files_full[1] cat(checkpoint_to_restore, \"\\n\\n\") new_start_date <- \"12/30/2024\" yml_tmp <- data.table::copy(yml) yml_tmp$simulation_config$start_date <- new_start_date yml_tmp$simulation_config$restore_from <- checkpoint_to_restore yml_tmp$population_data$initialization <- \"population_init_n24_only_mapping.csv\" # ensure that we don't want to reinitialize the population with the original initial conditions temp_config_resume <- tempfile(tmpdir = dirname(example_config), fileext = \".yaml\") yaml::write_yaml(yml_tmp, temp_config_resume) temp_config_resume <- normalizePath(temp_config_resume) # Run the resumed simulation results_resumed <- metaRVM(temp_config_resume) cat(\"Number of instances:\", results_resumed$run_info$n_instances, \"\\n\") cat(\"Date range:\", format(results_resumed$run_info$date_range[1]), \"to\", format(results_resumed$run_info$date_range[2]), \"\\n\") } else { cat(\"No checkpoint files found to resume from.\\n\") } #> /tmp/RtmpdtpnKS/chk_2024-12-29_1.Rda #> #> Number of instances: 1 #> Date range: 2024-12-30 to 2025-03-29"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"plot","dir":"Articles","previous_headings":"Example","what":"Plot","title":"Checkpointing in MetaRVM","text":"plot chunk plot","code":"run1_hosp_sum <- results$results[disease_state == \"H\", .(total = sum(value)), by = \"date\"] run2_hosp_sum <- results_resumed$results[disease_state == \"H\", .(total = sum(value)), by = \"date\"] library(ggplot2) ggplot(rbind(run1_hosp_sum, run2_hosp_sum), aes(date, total)) + geom_line(, color = \"red\") + geom_vline(xintercept = as.Date(\"2024-12-29\"), linetype = \"dashed\") + labs(y = \"Hospitalizations\", x = \"Date\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/checkpointing.html","id":"understanding-checkpoint-files","dir":"Articles","previous_headings":"","what":"Understanding Checkpoint Files","title":"Checkpointing in MetaRVM","text":"checkpointing enabled, MetaRVM creates checkpoint files following naming convention: : - YYYY-MM-DD checkpoint date - N simulation instance number (1 nsim) information configuring MetaRVM simulations, see YAML Configuration vignette.","code":"chk_YYYY-MM-DD_N.Rda"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Getting Started with MetaRVM","text":"MetaRVM comprehensive R package simulating respiratory virus epidemics using meta-population compartmental models. vignette describes basic usage package.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Getting Started with MetaRVM","text":"development version MetaRVM can installed GitHub:","code":"# install.packages(\"devtools\") devtools::install_github(\"RESUME-Epi/MetaRVM\")"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"loading-the-package","dir":"Articles","previous_headings":"","what":"Loading the Package","title":"Getting Started with MetaRVM","text":"","code":"library(MetaRVM) library(ggplot2) options(odin.verbose = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"basic-example","dir":"Articles","previous_headings":"","what":"Basic Example","title":"Getting Started with MetaRVM","text":"example shows run basic meta-population simulation. metaRVM package includes set example files extdata directory. run example, files must first located. system.file() function R recommended way , finds files wherever package installed. yaml_file variable now holds full path example configuration file. file set use example data files (also extdata directory) relative paths. content yaml file. detailed explanation configuration options, please see yaml-configuration.html vignette.","code":"# Locate the example YAML configuration file yaml_file <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") print(yaml_file) #> [1] \"/tmp/RtmpdtpnKS/temp_libpath8a1dd6c7d1703/MetaRVM/extdata/example_config.yaml\" run_id: ExampleRun population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 1 nrep: 1 simulation_mode: deterministic random_seed: 42"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/getting-started.html","id":"running-the-simulation","dir":"Articles","previous_headings":"","what":"Running the Simulation","title":"Getting Started with MetaRVM","text":"path configuration file available, simulation can run using metaRVM() function. details running metaRVM, refer running--simulation.html vignette.","code":"# Load the metaRVM library library(MetaRVM) # Run the simulation sim_out <- metaRVM(yaml_file) #> Loading required namespace: pkgbuild #> Generating model in c #> ℹ Re-compiling odinf64d486c (debug build) #> ℹ Loading odinf64d486c print(sim_out) #> MetaRVM Results Object #> ===================== #> Instances: 1 #> Populations: #> Date range: 2023-10-01 to 2024-02-27 #> Parameter sets (nsim): 1 #> Replicates per set (nrep): 1 #> Simulation mode: deterministic #> Total observations: 388800 #> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, S_alloc, S_eff_prod, S_src_int, V, V_alloc, V_src_int, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_RS, n_SE, n_SE_eff, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_RS, p_SE, p_VE head(sim_out$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.742619e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.555784e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.483657e+01 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Running a Simulation with metaRVM","text":"vignette demonstrates run metaRVM simulation using example configuration data files included package. good way get started understand basic workflow.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"locating-the-example-files","dir":"Articles","previous_headings":"","what":"Locating the Example Files","title":"Running a Simulation with metaRVM","text":"metaRVM package includes set example files extdata directory. run example, files must first located. system.file() function R recommended way , finds files wherever package installed. yaml_file variable now holds full path example configuration file. file set use example data files (also extdata directory) relative paths. content yaml file.","code":"# Locate the example YAML configuration file yaml_file <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") print(yaml_file) #> [1] \"/tmp/RtmpdtpnKS/temp_libpath8a1dd6c7d1703/MetaRVM/extdata/example_config.yaml\" run_id: ExampleRun population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 1 nrep: 1 simulation_mode: deterministic random_seed: 42"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"running-the-simulation","dir":"Articles","previous_headings":"","what":"Running the Simulation","title":"Running a Simulation with metaRVM","text":"path configuration file available, simulation can run using metaRVM() function. metaRVM() function parse YAML file, read associated data files, run simulation, return MetaRVMResults object.","code":"# Load the metaRVM library library(MetaRVM) options(odin.verbose = FALSE) # Run the simulation sim_out <- metaRVM(yaml_file) #> Loading required namespace: pkgbuild"},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"working-with-configuration-files","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Working with Configuration Files","title":"Running a Simulation with metaRVM","text":"simulation can run directly providing YAML configuration file path, creating MetaRVMConfig object.","code":"# Load configuration from YAML file config_obj <- MetaRVMConfig$new(yaml_file) # Examine the configuration config_obj #> MetaRVM Configuration Object #> ============================ #> Config file: /tmp/RtmpdtpnKS/temp_libpath8a1dd6c7d1703/MetaRVM/extdata/example_config.yaml #> Parameters: 42 #> Parameter names (first 10): N_pop, pop_map, category_names, S_ini, E_ini, I_asymp_ini, I_presymp_ini, I_symp_ini, H_ini, D_ini ... #> Population groups: 24 #> Start date: 2023-09-30 #> Population mapping: [ 24 rows x 4 columns]"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"exploring-configuration-parameters","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Exploring Configuration Parameters","title":"Running a Simulation with metaRVM","text":"MetaRVMConfig class provides several methods explore simulation arguments:","code":"# List all available parameters param_names <- config_obj$list_parameters() head(param_names, 10) #> [1] \"N_pop\" \"pop_map\" \"category_names\" \"S_ini\" #> [5] \"E_ini\" \"I_asymp_ini\" \"I_presymp_ini\" \"I_symp_ini\" #> [9] \"H_ini\" \"D_ini\" # Get a summary of parameter types and sizes param_summary <- config_obj$parameter_summary() head(param_summary, 10) #> parameter type length size #> N_pop N_pop integer 1 1 #> pop_map pop_map data.table 4 4 #> category_names category_names character 3 3 #> S_ini S_ini integer 24 24 #> E_ini E_ini numeric 24 24 #> I_asymp_ini I_asymp_ini numeric 24 24 #> I_presymp_ini I_presymp_ini numeric 24 24 #> I_symp_ini I_symp_ini integer 24 24 #> H_ini H_ini numeric 24 24 #> D_ini D_ini numeric 24 24"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"accessing-demographic-information","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Accessing Demographic Information","title":"Running a Simulation with metaRVM","text":"One MetaRVM’s key features demographic stratification, ’s ability define parameters specific demographic strata.","code":"# Get user-defined demographic category names and values category_names <- config_obj$get_category_names() cat(\"Available categories:\", paste(category_names, collapse = \", \"), \"\\n\") #> Available categories: age, race, zone # Example: inspect values for one category (if present) if (\"age\" %in% category_names) { age_categories <- config_obj$get_category_values(\"age\") cat(\"Age categories:\", paste(age_categories, collapse = \", \"), \"\\n\") } #> Age categories: 0-17, 18-64, 65+"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"alternative-ways-to-run-the-simulation","dir":"Articles","previous_headings":"Deep-dive into MetaRVM Classes","what":"Alternative Ways to Run the Simulation","title":"Running a Simulation with metaRVM","text":"","code":"# Method 1: Direct from file path # sim_out <- metaRVM(config_file) # Method 2: From MetaRVMConfig object sim_out <- metaRVM(config_obj) # Method 3: From parsed configuration list config_list <- parse_config(yaml_file) sim_out <- metaRVM(config_list)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"exploring-the-results","dir":"Articles","previous_headings":"","what":"Exploring the Results","title":"Running a Simulation with metaRVM","text":"metaRVM() function returns MetaRVMResults object formatted, analysis-ready data. results formatted calendar dates demographic attributes, stored data frame called results:","code":"# Look at the structure of formatted results head(sim_out$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.742619e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.555784e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.483657e+01 1 # Check unique values for key variables cat(\"Disease states:\", paste(unique(sim_out$results$disease_state), collapse = \", \"), \"\\n\") #> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, S_alloc, S_eff_prod, S_src_int, V, V_alloc, V_src_int, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_RS, n_SE, n_SE_eff, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_RS, p_SE, p_VE cat(\"Date range:\", paste(range(sim_out$results$date), collapse = \" to \"), \"\\n\") #> Date range: 2023-10-01 to 2024-02-27"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"data-subsetting-and-filtering","dir":"Articles","previous_headings":"Exploring the Results","what":"Data Subsetting and Filtering","title":"Running a Simulation with metaRVM","text":"subset_data() method provides flexible filtering across demographic temporal dimensions. returns object class MetaRVMResults.","code":"# Subset by single criteria hospitalized_data <- sim_out$subset_data(disease_states = \"H\") hospitalized_data$results #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 H 0.2304447 1 #> 2: 2023-10-01 0-17 A 22 H 0.2081436 1 #> 3: 2023-10-01 0-17 B 11 H 0.5203590 1 #> 4: 2023-10-01 0-17 B 22 H 0.3939861 1 #> 5: 2023-10-01 0-17 C 11 H 0.6244308 1 #> --- #> 3596: 2024-02-27 65+ B 22 H 1.2118718 1 #> 3597: 2024-02-27 65+ C 11 H 1.8624622 1 #> 3598: 2024-02-27 65+ C 22 H 10.2755842 1 #> 3599: 2024-02-27 65+ D 11 H 5.5349332 1 #> 3600: 2024-02-27 65+ D 22 H 12.4195984 1 # Subset by multiple demographic categories elderly_data <- sim_out$subset_data( age = c(\"65+\"), disease_states = c(\"H\", \"D\") ) elderly_data$results #> date age race zone disease_state value instance #> #> 1: 2023-10-01 65+ A 11 D 2.179919e-05 1 #> 2: 2023-10-01 65+ A 11 H 2.230110e-02 1 #> 3: 2023-10-01 65+ A 22 D 1.453279e-05 1 #> 4: 2023-10-01 65+ A 22 H 1.486740e-02 1 #> 5: 2023-10-01 65+ B 11 D 8.719675e-05 1 #> --- #> 2396: 2024-02-27 65+ C 22 H 1.027558e+01 1 #> 2397: 2024-02-27 65+ D 11 D 3.831713e+01 1 #> 2398: 2024-02-27 65+ D 11 H 5.534933e+00 1 #> 2399: 2024-02-27 65+ D 22 D 8.635266e+01 1 #> 2400: 2024-02-27 65+ D 22 H 1.241960e+01 1 # Specific date range peak_period <- sim_out$subset_data( date_range = c(as.Date(\"2023-10-01\"), as.Date(\"2023-12-31\")), disease_states = \"H\" ) peak_period$results #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 H 0.2304447 1 #> 2: 2023-10-01 0-17 A 22 H 0.2081436 1 #> 3: 2023-10-01 0-17 B 11 H 0.5203590 1 #> 4: 2023-10-01 0-17 B 22 H 0.3939861 1 #> 5: 2023-10-01 0-17 C 11 H 0.6244308 1 #> --- #> 2204: 2023-12-31 65+ B 22 H 7.0258803 1 #> 2205: 2023-12-31 65+ C 11 H 9.7905521 1 #> 2206: 2023-12-31 65+ C 22 H 52.9246952 1 #> 2207: 2023-12-31 65+ D 11 H 28.3456494 1 #> 2208: 2023-12-31 65+ D 22 H 63.2860726 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"specifying-disease-parameters-via-distributions","dir":"Articles","previous_headings":"","what":"Specifying Disease Parameters via Distributions","title":"Running a Simulation with metaRVM","text":"metaRVM allows disease parameters specified distributions, useful capturing uncertainty. parameter defined distribution, simulation instance draw new value distribution. details available distributions parameters, refer yaml-configuration vignette. example YAML file parameter distributions included package, example_config_dist.yaml. content: run simulation configuration, file path passed metaRVM.","code":"# Locate the example YAML configuration file with distributions yaml_file_dist <- system.file(\"extdata\", \"example_config_dist.yaml\", package = \"MetaRVM\") run_id: ExampleRun_Dist population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: dist: uniform min: 0.3 max: 0.5 dv: 180 dp: 1 de: 3 da: dist: uniform min: 4 max: 6 ds: dist: uniform min: 5 max: 7 dh: dist: lognormal mu: 2 sd: 0.5 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 20 # Increased nsim for meaningful summary statistics nrep: 1 simulation_mode: deterministic random_seed: 42 # Run the simulation with the new configuration sim_out_dist <- metaRVM(yaml_file_dist)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"generating-summary-statistics-across-demographics","dir":"Articles","previous_headings":"Specifying Disease Parameters via Distributions","what":"Generating Summary Statistics across Demographics","title":"Running a Simulation with metaRVM","text":"MetaRVMResults class provides basic summarization functionality across multiple instances simulation, one disease parameters specified via distribution, one simulations per configurations. summarize method generates output class MetaRVMSummary plot method available. simulation run parameter distributions, summarize method can used inspect variability results.","code":"library(ggplot2) # Summarize hospitalizations by age group hospital_summary_dist <- sim_out_dist$summarize( group_by = c(\"age\"), disease_states = \"n_IsympH\", stats = c(\"median\", \"quantile\"), quantiles = c(0.05, 0.95) ) # Plot the summary hospital_summary_dist$plot() + ggtitle(\"Daily Hospitalizations by Age Group (with 90% confidence interval)\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"running-a-stochastic-simulation-with-static-parameters","dir":"Articles","previous_headings":"","what":"Running a Stochastic Simulation with Static Parameters","title":"Running a Simulation with metaRVM","text":"stochastic simulation can also run setting simulation_mode: stochastic. example YAML file parameter distributions included package, example_config_stochastic.yaml. content:","code":"# Locate the example YAML configuration file with distributions yaml_file_stoch <- system.file(\"extdata\", \"example_config_stochastic.yaml\", package = \"MetaRVM\") run_id: ExampleRun_Stochastic_Static population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 1 nrep: 5 simulation_mode: stochastic random_seed: 42 sim_out_stoch <- metaRVM(yaml_file_stoch)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/running-a-simulation.html","id":"specifying-disease-parameters-by-demographics","dir":"Articles","previous_headings":"","what":"Specifying Disease Parameters by Demographics","title":"Running a Simulation with metaRVM","text":"disease parameters can also specified different demographic subgroups. subgroup-specific parameters override global parameters. details, refer yaml-configuration vignette. example YAML file provided, example_config_subgroup_dist.yaml, demonstrates feature. also includes parameters defined distributions. Now, let’s run simulation configuration. results can now plotted evaluate impact subgroup-specific parameters. example, number hospitalizations “65+” age group, dh 10, can compared age groups use global dh drawn lognormal distribution.","code":"# Locate the example YAML configuration file with subgroup parameters yaml_file_subgroup <- system.file(\"extdata\", \"example_config_subgroup_dist.yaml\", package = \"MetaRVM\") run_id: ExampleRun_Subgroup_Dist population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: dist: uniform min: 0.3 max: 0.5 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: dist: lognormal mu: 2 sd: 0.5 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 sub_disease_params: age: 0-17: pea: 0.08 18-64: ts: 0.6 65+: # This fixed value will override the global lognormal distribution for dh dh: 10 phr: 0.9227 simulation_config: start_date: 01/01/2023 # m/d/Y length: 150 nsim: 20 nrep: 1 simulation_mode: deterministic random_seed: 42 # Run the simulation with the subgroup configuration sim_out_subgroup <- metaRVM(yaml_file_subgroup) # Summarize hospitalizations by age group hospital_summary_subgroup <- sim_out_subgroup$summarize( group_by = c(\"age\"), disease_states = \"H\", stats = c(\"median\", \"quantile\"), quantiles = c(0.025, 0.975) ) # Plot the summary hospital_summary_subgroup$plot() + ggtitle(\"Daily Hospitalizations by Age Group (Subgroup Parameters)\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"YAML Configuration for metaRVM","text":"metaRVM package uses YAML file configure model parameters. vignette describes structure YAML configuration file, starting simple example progressively introducing advanced features.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"basic-configuration","dir":"Articles","previous_headings":"","what":"Basic Configuration","title":"YAML Configuration for metaRVM","text":"minimal configuration file specifies data sources, simulation settings, disease parameters fixed scalar values.","code":"run_id: SimpleRun population_data: initialization: data/population_init.csv vaccination: data/vaccination.csv mixing_matrix: weekday_day: data/m_weekday_day.csv weekday_night: data/m_weekday_night.csv weekend_day: data/m_weekend_day.csv weekend_night: data/m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2025 # m/d/Y length: 90 nsim: 1 nrep: 1 simulation_mode: deterministic random_seed: 42"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"configuration-sections","dir":"Articles","previous_headings":"Basic Configuration","what":"Configuration Sections","title":"YAML Configuration for metaRVM","text":"run_id: unique name simulation. population_data: Paths CSV files population demographics, initial state, vaccination schedules. mixing_matrix: Paths CSV files defining contact patterns different times week. disease_params: Disease characteristics. example, parameters single, fixed values. simulation_config: Settings simulation run, start date, duration, number simulations.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"input-file-structures","dir":"Articles","previous_headings":"Basic Configuration","what":"Input File Structures","title":"YAML Configuration for metaRVM","text":"metaRVM package requires several CSV files structured specific way. descriptions required input files, along examples look like.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"population-data-files","dir":"Articles","previous_headings":"Basic Configuration > Input File Structures","what":"Population Data Files","title":"YAML Configuration for metaRVM","text":"population_id: unique identifier subpopulation (sequential natural numbers: 1, 2, 3, …) N: total number individuals subpopulation S0: initial number susceptible individuals I0: initial number symptomatic infected individuals V0: initial number vaccinated individuals R0: initial number recovered individuals age: Age groups (e.g., “0-17”, “18-64”, “65+”) race: Race ethnicity categories zone: Healthcare zones geographic regions custom categories like income_level, occupation, risk_group, etc. Example population initialization file: vaccination: vaccination schedule file contains number vaccinations administered time. first column must date MM/DD/YYYY format, followed columns subpopulation order population_id initialization file. Example vaccination schedule file:","code":"#> First 10 rows of population_init_n24.csv: #> population_id age race zone N S0 I0 V0 R0 #> 1 1 0-17 A 11 30742 30711 31 0 7 #> 2 2 18-64 A 11 41429 41388 41 0 9 #> 3 3 65+ A 11 3321 3318 3 0 0 #> 4 4 0-17 B 11 70138 70068 70 0 6 #> 5 5 18-64 B 11 12298 12286 12 0 32 #> 6 6 65+ B 11 11549 11537 12 0 0 #> 7 7 0-17 C 11 84178 84094 84 0 13 #> 8 8 18-64 C 11 113521 113407 114 0 15 #> 9 9 65+ C 11 11924 11912 12 0 0 #> 10 10 0-17 D 11 199686 199486 200 0 14 #> #> ... (24 total rows) #> First 10 rows of vaccination_n24.csv: #> date v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15 v16 v17 #> 1 09/16/2023 0 0 0 0 0 0 11 5 4 8 6 4 2 5 1 8 11 #> 2 09/23/2023 5 12 1 11 7 2 180 187 99 362 293 72 311 163 24 519 203 #> 3 09/30/2023 3 5 2 19 10 3 198 235 88 424 364 89 445 255 36 625 251 #> 4 10/07/2023 20 14 15 46 19 8 403 385 124 846 580 187 675 389 45 1242 347 #> 5 10/14/2023 28 29 19 81 50 7 471 425 105 997 511 162 727 400 42 1351 313 #> 6 10/21/2023 37 55 24 110 43 8 378 499 115 980 483 160 623 511 39 1212 317 #> 7 10/28/2023 28 43 19 86 48 16 339 464 88 809 438 126 548 411 52 1090 287 #> 8 11/04/2023 22 53 19 91 49 28 329 391 70 765 431 147 522 391 22 956 259 #> 9 11/11/2023 36 62 21 110 60 10 337 396 87 769 414 148 575 425 39 966 199 #> 10 11/18/2023 40 65 14 102 55 14 340 431 97 875 392 118 513 417 28 1041 231 #> v18 v19 v20 v21 v22 v23 v24 #> 1 5 0 0 0 0 0 3 #> 2 113 2 3 26 4 13 10 #> 3 119 4 22 27 2 18 27 #> 4 193 8 41 50 4 70 44 #> 5 161 10 98 217 36 123 98 #> 6 202 18 160 214 51 149 168 #> 7 152 32 199 273 60 153 267 #> 8 126 26 168 239 33 149 225 #> 9 149 26 197 255 52 142 275 #> 10 141 26 212 242 50 153 191 #> #> ... (51 total rows) #> #> Note: Columns represent vaccination counts for each population_id (1-24)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"mixing-matrix-files","dir":"Articles","previous_headings":"Basic Configuration > Input File Structures","what":"Mixing Matrix Files","title":"YAML Configuration for metaRVM","text":"mixing matrix files define contact patterns different subpopulations. file CSV without header, rows columns correspond subpopulations order population_id initialization file. values matrix represent proportion time individuals one subpopulation spend individuals another. sum row must equal 1. Example mixing matrix file (weekday day):","code":"#> First 10 rows and 10 columns of m_weekday_day.csv: #> V1 V2 V3 V4 V5 V6 #> 1 0.860000000 0.0010475811 0.003377249 0.001710217 0.0011920273 0.006571116 #> 2 0.003611954 0.9100000000 0.001328864 0.003596329 0.0027309903 0.004173784 #> 3 0.001344397 0.0072452422 0.870000000 0.002513688 0.0050834111 0.009789632 #> 4 0.006689671 0.0005482346 0.004749909 0.920000000 0.0070678313 0.001806128 #> 5 0.007740689 0.0039632387 0.004643154 0.001091787 0.8700000000 0.009791262 #> 6 0.006379144 0.0032865609 0.003432134 0.001761560 0.0071883914 0.890000000 #> 7 0.001444749 0.0064237517 0.002656119 0.001968115 0.0043013059 0.001206245 #> 8 0.002179355 0.0070411463 0.001587234 0.003439760 0.0033650992 0.006414028 #> 9 0.005390480 0.0066530217 0.005482305 0.003007641 0.0006105881 0.003145261 #> 10 0.001666809 0.0029011017 0.008534104 0.001698315 0.0098720801 0.004586367 #> V7 V8 V9 V10 #> 1 1.464237e-02 0.0143653234 0.0118876071 0.0080742019 #> 2 6.528305e-03 0.0041375710 0.0057636782 0.0054420004 #> 3 8.763376e-03 0.0005057071 0.0007488488 0.0073198670 #> 4 2.822754e-04 0.0070548564 0.0009509153 0.0012611329 #> 5 1.004983e-02 0.0041073157 0.0088236656 0.0006445009 #> 6 3.144937e-05 0.0085528740 0.0063335264 0.0023219191 #> 7 9.200000e-01 0.0035656434 0.0070237063 0.0042256901 #> 8 4.098307e-03 0.9100000000 0.0067478716 0.0100518811 #> 9 9.597300e-04 0.0002268853 0.9200000000 0.0009418937 #> 10 5.236045e-03 0.0065183293 0.0012107981 0.8700000000 #> #> Matrix dimensions: 24 x 24 #> Row sums (should all equal 1): #> [1] 1 1 1 1 1 1 1 1 1 1"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"disease-parameter-descriptions","dir":"Articles","previous_headings":"Basic Configuration","what":"Disease Parameter Descriptions","title":"YAML Configuration for metaRVM","text":"list disease parameters used metaRVM: ts: Transmission rate symptomatic individuals susceptible population. ve: Vaccine effectiveness (proportion, range: [0, 1]). dv: Mean duration (days) vaccinated state immunity wanes. dp: Mean duration (days) presymptomatic infectious state. de: Mean duration (days) exposed state. da: Mean duration (days) asymptomatic infectious state. ds: Mean duration (days) symptomatic infectious state. dh: Mean duration (days) hospitalized state. dr: Mean duration (days) immunity recovered state. pea: Proportion exposed individuals become asymptomatic (vs. presymptomatic) (range: 0-1). psr: Proportion symptomatic individuals recover directly (vs. requiring hospitalization) (range: 0-1). phr: Proportion hospitalized individuals recover (vs. die) (range: 0-1).","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"defining-parameters-with-distributions","dir":"Articles","previous_headings":"","what":"Defining Parameters with Distributions","title":"YAML Configuration for metaRVM","text":"Instead fixed values, disease parameters can defined using statistical distributions. useful capturing uncertainty parameters. metaRVM supports uniform lognormal distributions. example defining ve, da, ds, dh distributions: uniform distribution, min max values must specified. lognormal distribution, mu sd (mean standard deviation log scale) must specified.","code":"disease_params: ts: 0.5 ve: dist: uniform min: 0.29 max: 0.53 dv: 158 dp: 1 de: 3 da: dist: uniform min: 3 max: 7 ds: dist: uniform min: 5 max: 7 dh: dist: lognormal mu: 8 sd: 8.9 dr: 187 pea: 0.333 psr: 0.95 phr: 0.97"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"specifying-subgroup-parameters","dir":"Articles","previous_headings":"","what":"Specifying Subgroup Parameters","title":"YAML Configuration for metaRVM","text":"metaRVM allows different disease parameters specified demographic subgroups using sub_disease_params section. subgroup-specific parameters override global parameters defined disease_params. demographic categories used section must match user-defined category column names initialization CSV file specified population_data. example, initialization file columns named age, income_level, occupation, categories can used sub_disease_params. specific values (e.g., \"0-4\", \"low\", \"healthcare\") must exactly match values columns. following example defines different parameters different age groups: configuration, individuals “0-4” age group dh (duration hospitalization) 4, overriding global dh value. Similarly, transmission rate ts “18-49” group set 0.01.","code":"sub_disease_params: age: 0-17: dh: 4 pea: 0.08 psr: 0.9303 phr: 0.9920 18-64: dh: 4 pea: 0.08 psr: 0.9726 phr: 0.9920 65+: dh: 7 pea: 0.05 psr: 0.9091 phr: 0.9227"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"stochastic-simulation-with-distributional-parameters","dir":"Articles","previous_headings":"","what":"Stochastic Simulation with Distributional Parameters","title":"YAML Configuration for metaRVM","text":"parameter uncertainty stochastic disease transitions represented, set simulation_mode: stochastic define one disease parameters distributions. nsim: number sampled parameter sets nrep: number stochastic replicates per parameter set total runs = nsim * nrep Example: reproducibility, provide random_seed. seed used reproduce parameter draws (distributional parameters) stochastic model replicates.","code":"run_id: StochasticDistRun population_data: initialization: data/population_init.csv vaccination: data/vaccination.csv mixing_matrix: weekday_day: data/m_weekday_day.csv weekday_night: data/m_weekday_night.csv weekend_day: data/m_weekend_day.csv weekend_night: data/m_weekend_night.csv disease_params: ts: 0.5 ve: dist: uniform min: 0.29 max: 0.53 dv: 158 dp: 1 de: 3 da: dist: uniform min: 3 max: 7 ds: dist: uniform min: 5 max: 7 dh: dist: lognormal mu: 2.0 sd: 0.5 dr: 187 pea: 0.333 psr: 0.95 phr: 0.97 simulation_config: start_date: 01/01/2025 length: 90 nsim: 20 nrep: 5 simulation_mode: stochastic random_seed: 42"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"checkpointing-and-restoring-simulations","dir":"Articles","previous_headings":"","what":"Checkpointing and Restoring Simulations","title":"YAML Configuration for metaRVM","text":"long-running simulations, useful save state model intermediate points. known checkpointing. metaRVM allows checkpoints saved simulations restored saved state.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"enabling-checkpointing","dir":"Articles","previous_headings":"Checkpointing and Restoring Simulations","what":"Enabling Checkpointing","title":"YAML Configuration for metaRVM","text":"enable checkpointing, checkpoint_dir optionally checkpoint_dates need added simulation_config section YAML file. checkpoint_dir: directory checkpoint files saved. checkpoint_dates: list dates (MM/DD/YYYY format) save checkpoint. provided, single checkpoint saved end simulation. example configure checkpointing:","code":"simulation_config: start_date: 01/01/2025 length: 90 nsim: 10 nrep: 1 simulation_mode: deterministic random_seed: 42 checkpoint_dir: \"path/to/checkpoints\" checkpoint_dates: [\"01/15/2025\", \"01/30/2025\"]"},{"path":"https://RESUME-Epi.github.io/MetaRVM/articles/yaml-configuration.html","id":"restoring-from-a-checkpoint","dir":"Articles","previous_headings":"Checkpointing and Restoring Simulations","what":"Restoring from a Checkpoint","title":"YAML Configuration for metaRVM","text":"restore simulation checkpoint file, restore_from parameter used simulation_config section. model initialized state saved specified checkpoint file. restoring, start_date correspond next date checkpoint, length remaining duration simulation. Note instance simulation must restored individually.","code":"simulation_config: start_date: 01/30/2025 # Should be the next date of the checkpoint date length: 60 # Remaining simulation length nsim: 10 nrep: 1 simulation_mode: deterministic random_seed: 42 restore_from: \"path/to/checkpoints/checkpoint_2025-01-30_instance_1.Rda\""},{"path":"https://RESUME-Epi.github.io/MetaRVM/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Arindam Fadikar. Author, maintainer, copyright holder. Charles Macal. Contributor. Martinez Moyano Ignacio Javier. Contributor. Ozik Jonathan. Contributor.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Fadikar , Stevens , Rimer S, Martinez-Moyano , Collier N, Mabil C, Jorgensen E, Ruestow P, McSorley VE, Ozik J, Macal C (2025). \"Developing Deploying Use-Inspired Metapopulation Modeling Framework Detailed Tracking Stratified Health Outcomes.\" 2025 Winter Simulation Conference (WSC), 734--745. doi:10.1109/WSC68292.2025.11338996.","code":"@InProceedings{, title = {Developing and Deploying a Use-Inspired Metapopulation Modeling Framework for Detailed Tracking of Stratified Health Outcomes}, author = {Arindam Fadikar and Abby Stevens and Sara Rimer and Ignacio Martinez-Moyano and Nicholson Collier and Chol Mabil and Emile Jorgensen and Peter Ruestow and V. Eloesa McSorley and Jonathan Ozik and Charles Macal}, booktitle = {2025 Winter Simulation Conference (WSC)}, year = {2025}, pages = {734--745}, doi = {10.1109/WSC68292.2025.11338996}, }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"metarvm-","dir":"","previous_headings":"","what":"MetaRVM - Meta-population Respiratory Virus Model","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"compartmental model simulation code generic respiratory virus diseases.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"model","dir":"","previous_headings":"","what":"Model","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM open-source R package modeling spread infectious diseases subpopulations, can flexibly defined geography, demographics, stratifications. designed support real-time public health decision-making. MetaRVM metapopulation model, extends classic Susceptible-Infected-Recovered (SIR) framework propagating infection across interacting subpopulations (e.g., age groups, neighborhoods), whose interactions governed realistic mixing patterns. MetaRVM model builds upon SEIR framework introducing additional compartments capture detailed dynamics disease progression, allowing heterogeneous mixing among different demographic stratum. generalizations allow model account factors vaccinations, hospitalizations, fatalities. Model schematics details, please refer paper: Developing deploying use-inspired metapopulation modeling framework detailed tracking stratified health outcomes","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"Full documentation available : https://RESUME-Epi.github.io/MetaRVM/","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"installation","dir":"","previous_headings":"Quickstart guide","what":"Installation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"current CRAN release 2.0.0. Install :","code":"install.packages(\"MetaRVM\")"},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"running-a-simulation","dir":"","previous_headings":"Quickstart guide","what":"Running a simulation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"content yaml configuration file:","code":"library(MetaRVM) options(odin.verbose = FALSE) ## prepare the configuration file cfg <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") run_id: ExampleRun population_data: initialization: population_init_n24.csv vaccination: vaccination_n24.csv mixing_matrix: weekday_day: m_weekday_day.csv weekday_night: m_weekday_night.csv weekend_day: m_weekend_day.csv weekend_night: m_weekend_night.csv disease_params: ts: 0.5 ve: 0.4 dv: 180 dp: 1 de: 3 da: 5 ds: 6 dh: 8 dr: 180 pea: 0.3 psr: 0.95 phr: 0.97 simulation_config: start_date: 10/01/2023 # m/d/Y length: 150 nsim: 1 nrep: 1 simulation_mode: deterministic random_seed: 42 # run simulation sim_out <- metaRVM(cfg) #> Loading required namespace: pkgbuild # basic plot: daily hospitalizations by date library(ggplot2) hosp <- sim_out$results[disease_state == \"H\"] hosp_sum <- hosp[disease_state == \"H\", .(total = sum(value)), by = \"date\"] ggplot(hosp_sum, aes(date, total)) + geom_line(, color = \"red\") + labs(y = \"Hospitalizations\", x = \"Date\") + theme_bw()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"model-structure","dir":"","previous_headings":"","what":"Model structure","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM implements stratified SEIR-type metapopulation model vaccination, hospitalization, immunity waning, reinfection. core health states demographic stratum : Susceptible S Vaccinated V Exposed E Asymptomatic infectious I_asymp Presymptomatic infectious I_presymp Symptomatic infectious I_symp Hospitalized H Recovered R Deceased D start simulation, nearly individuals S, optional seeding initial infections /vaccinated individuals V. susceptible vaccinated individuals come contact infectious individuals, become exposed (E) based age/stratum-specific forces infection vaccine protection. Exposed individuals progress asymptomatic, presymptomatic, symptomatic infectious states either recovering, hospitalized, dying. Vaccinated recovered immunity can wane time, returning individuals susceptible pool, allows MetaRVM represent multiple respiratory pathogens different natural histories. Transmission stratified user-defined demographic groups (e.g., age, zone, race). Time-varying mixing matrices define strata interact (daytime vs. nighttime, weekday vs. weekend), MetaRVM computes stratum-specific forces infection susceptible vaccinated individuals. Hospitalized deceased individuals excluded “effective” mixing population. model can run deterministic stochastic mode, parameters supplied YAML configuration. simulation control: - nsim number parameter sets (rows sampled parameter matrices distributions used) - nrep number simulation replicates per parameter set - total runs = nsim * nrep - simulation_mode chooses \"deterministic\" \"stochastic\" - random_seed ensures reproducibility parameter sampling stochastic trajectories","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"transmission-and-mixing-parameters","dir":"","previous_headings":"Model structure","what":"Transmission and mixing parameters","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"parameters drive transitions S V E, determine quickly individuals move infectious, hospitalized, recovered, deceased states.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"required-input-data-and-configuration","dir":"","previous_headings":"Model structure","what":"Required input data and configuration","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM configured YAML file small set CSV inputs.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"model-output-structure","dir":"","previous_headings":"Model structure","what":"Model output structure","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM produces simulation results unified tidy long-format table easy analyze data.table, dplyr, ggplot2. Every record corresponds single compartment count flow quantity specific demographic stratum, simulation date, scenario/instance. core output available : sim$results — compartment counts flows day sim$config — configuration object used generate run","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/index.html","id":"further-examples-and-full-documentation","dir":"","previous_headings":"","what":"Further examples and full documentation","title":"MetaRVM - Meta-population Respiratory Virus Model","text":"MetaRVM includes several vignettes demonstrate common workflows using real model configurations data. provide detailed, step--step examples prepare inputs, configure model, run simulations, analyze outputs. vignettes can accessed : https://resume-epi.github.io/MetaRVM/articles/ List vignettes: Getting Started gentle introduction showing load configuration file, run simulation, inspect outputs. Model Configurations detailed walkthrough YAML structure, required fields, parameter blocks, optional modules, define population strata mixing patterns. Running Simulation Full example using complete set input files, showing MetaRVM reads population initialization data, mixing matrices, vaccination schedules. Checkpointing Restoring Demonstrates run many scenarios scale, resume long runs, store intermediate model states. complete function reference, visit: https://resume-epi.github.io/MetaRVM/reference/","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVM-package.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM: Meta-Population Compartmental Model for Respiratory Virus Diseases — MetaRVM-package","title":"MetaRVM: Meta-Population Compartmental Model for Respiratory Virus Diseases — MetaRVM-package","text":"Simulates respiratory virus epidemics using meta-population compartmental models following Fadikar et. al. (2025) doi:10.1109/WSC68292.2025.11338996 . 'MetaRVM' implements stochastic SEIRD (Susceptible-Exposed-Infected-Recovered-Dead) framework demographic stratification user provided attributes. supports complex epidemiological scenarios including asymptomatic presymptomatic transmission, hospitalization dynamics, vaccination schedules, time-varying contact patterns via mixing matrices.","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVM-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM: Meta-Population Compartmental Model for Respiratory Virus Diseases — MetaRVM-package","text":"Maintainer: Arindam Fadikar afadikar@anl.gov (ORCID) [copyright holder] contributors: Charles Macal [contributor] Martinez Moyano Ignacio Javier [contributor] Ozik Jonathan [contributor]","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Checkpoint Class — MetaRVMCheck","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"R6 class handle MetaRVM checkpoint data. class simplified version MetaRVMConfig tailored storing accessing simulation checkpoints.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVMCheck class designed hold state simulation specific time point, allowing continuation analysis. stores necessary parameters population states.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"super-class","dir":"Reference","previous_headings":"","what":"Super class","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVM::MetaRVMConfig -> MetaRVMCheck","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"check_data List containing parsed checkpoint data","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"methods","dir":"Reference","previous_headings":"","what":"Methods","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVM::MetaRVMConfig$get() MetaRVM::MetaRVMConfig$get_all() MetaRVM::MetaRVMConfig$get_all_categories() MetaRVM::MetaRVMConfig$get_category_names() MetaRVM::MetaRVMConfig$get_category_values() MetaRVM::MetaRVMConfig$get_pop_map() MetaRVM::MetaRVMConfig$list_parameters() MetaRVM::MetaRVMConfig$parameter_summary() MetaRVM::MetaRVMConfig$print() MetaRVM::MetaRVMConfig$set()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"MetaRVMCheck$new() MetaRVMCheck$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"Initialize new MetaRVMCheck object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"","code":"MetaRVMCheck$new(input)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"input list containing checkpoint data.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"new MetaRVMCheck object.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"","code":"MetaRVMCheck$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMCheck.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Checkpoint Class — MetaRVMCheck","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Configuration Class — MetaRVMConfig","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"R6 class handle MetaRVM configuration data validation methods. class encapsulates configuration parameters needed MetaRVM simulations, providing methods parameter access, validation, introspection.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"MetaRVMConfig class stores parsed configuration data YAML files provides structured access simulation parameters. automatically validates configuration completeness provides convenient methods accessing demographic categories, initialization-derived population metadata, simulation settings.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"config_file Path original YAML config file (applicable) config_data List containing parsed configuration parameters","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"MetaRVMConfig$new() MetaRVMConfig$get() MetaRVMConfig$get_all() MetaRVMConfig$list_parameters() MetaRVMConfig$parameter_summary() MetaRVMConfig$set() MetaRVMConfig$print() MetaRVMConfig$get_pop_map() MetaRVMConfig$get_category_names() MetaRVMConfig$get_category_values() MetaRVMConfig$get_all_categories() MetaRVMConfig$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Initialize new MetaRVMConfig object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$new(input)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"input Either file path (character) parsed config list","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"New MetaRVMConfig object (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-","dir":"Reference","previous_headings":"","what":"Method get()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get configuration parameter","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get(param)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"param Parameter name","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"requested parameter value","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-all-","dir":"Reference","previous_headings":"","what":"Method get_all()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get configuration parameters list","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_all()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Named list configuration parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-list-parameters-","dir":"Reference","previous_headings":"","what":"Method list_parameters()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"List available parameter names","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$list_parameters()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-3","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Character vector parameter names","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-parameter-summary-","dir":"Reference","previous_headings":"","what":"Method parameter_summary()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Show summary parameter types sizes","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-4","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$parameter_summary()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-4","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Data frame parameter information","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-set-","dir":"Reference","previous_headings":"","what":"Method set()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Set configuration parameter","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-5","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$set(param, value)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"param Character string. Parameter name set value value assign parameter","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-5","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Self (invisible) method chaining","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Print summary configuration","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-6","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$print()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-6","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Self (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-pop-map-","dir":"Reference","previous_headings":"","what":"Method get_pop_map()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get population mapping data","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-7","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_pop_map()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-7","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"data.table containing population_id user-defined demographic category columns","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-category-names-","dir":"Reference","previous_headings":"","what":"Method get_category_names()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get names category columns","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-8","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_category_names()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"details-1","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Category columns automatically detected initialization CSV file. column reserved column (population_id, N, S0, I0, R0, V0, etc.) treated demographic category (e.g., age, zone, income_level, occupation).","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-8","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Character vector category column names, empty vector categories","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"\\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") category_names <- config$get_category_names() # e.g., c(\"age\", \"zone\", \"risk_group\") }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-category-values-","dir":"Reference","previous_headings":"","what":"Method get_category_values()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get unique values specific category","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-9","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_category_values(category_name)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-3","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"category_name Character string specifying category name","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-9","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Character/numeric vector unique values specified category","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"examples-1","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"\\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") ages <- config$get_category_values(\"age\") # if age is defined income_levels <- config$get_category_values(\"income_level\") # if defined }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-get-all-categories-","dir":"Reference","previous_headings":"","what":"Method get_all_categories()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Get categories named list","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-10","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$get_all_categories()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"returns-10","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"Named list names category column names values vectors unique values category. Returns empty list categories.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"examples-2","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"\\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") all_cats <- config$get_all_categories() # Returns: list(age = c(\"0-17\", \"18-64\", \"65+\"), risk_group = c(\"low\", \"high\"), ...) }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"usage-11","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"MetaRVMConfig$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"arguments-4","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMConfig.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Configuration Class — MetaRVMConfig","text":"","code":"# Initialize from YAML file example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") config <- MetaRVMConfig$new(example_config) # Access parameters config$get(\"N_pop\") #> [1] 24 config$get(\"start_date\") #> [1] \"2023-09-30\" # Get demographic category names (user-defined) category_names <- config$get_category_names() # e.g., c(\"age\", \"zone\", \"risk_group\") # Get values for specific categories ages <- config$get_category_values(\"age\") # Get all categories as a named list all_categories <- config$get_all_categories() ## ------------------------------------------------ ## Method `MetaRVMConfig$get_category_names` ## ------------------------------------------------ if (FALSE) { # \\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") category_names <- config$get_category_names() # e.g., c(\"age\", \"zone\", \"risk_group\") } # } ## ------------------------------------------------ ## Method `MetaRVMConfig$get_category_values` ## ------------------------------------------------ if (FALSE) { # \\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") ages <- config$get_category_values(\"age\") # if age is defined income_levels <- config$get_category_values(\"income_level\") # if defined } # } ## ------------------------------------------------ ## Method `MetaRVMConfig$get_all_categories` ## ------------------------------------------------ if (FALSE) { # \\dontrun{ config <- MetaRVMConfig$new(\"config.yaml\") all_cats <- config$get_all_categories() # Returns: list(age = c(\"0-17\", \"18-64\", \"65+\"), risk_group = c(\"low\", \"high\"), ...) } # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Results Class — MetaRVMResults","title":"MetaRVM Results Class — MetaRVMResults","text":"R6 class handle MetaRVM simulation results comprehensive analysis visualization methods. class stores formatted simulation results provides methods data summarization, subsetting, visualization flexible demographic groupings.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Results Class — MetaRVMResults","text":"MetaRVMResults class automatically formats raw simulation output upon initialization, converting time steps calendar dates adding demographic attributes. provides methods flexible data summarization across user-defined demographic categories, plus method chaining streamlined analysis workflows.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Results Class — MetaRVMResults","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Results Class — MetaRVMResults","text":"config MetaRVMConfig object used generate results results data.table containing formatted simulation results run_info List containing run metadata","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Results Class — MetaRVMResults","text":"MetaRVMResults$new() MetaRVMResults$print() MetaRVMResults$plot() MetaRVMResults$subset_data() MetaRVMResults$summarize() MetaRVMResults$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Results Class — MetaRVMResults","text":"Initialize new MetaRVMResults object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$new( raw_results, config, run_info = NULL, formatted_results = NULL )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"raw_results Raw simulation results data.table config MetaRVMConfig object used simulation run_info Optional metadata run formatted_results formatted simulation results data.table","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"New MetaRVMResults object (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"MetaRVM Results Class — MetaRVMResults","text":"Print summary results","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$print()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"Self (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-plot-","dir":"Reference","previous_headings":"","what":"Method plot()","title":"MetaRVM Results Class — MetaRVMResults","text":"Plot simulation trajectories directly results","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$plot( group_by = character(0), disease_states = NULL, date_range = NULL, instances = NULL, stats = NULL, quantiles = c(0.25, 0.75), exclude_p_columns = TRUE, ci_level = 0.95, theme = theme_minimal(), title = NULL )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"group_by Vector demographic category names group/facet disease_states Optional disease states include date_range Optional date range filtering instances Optional instance IDs include stats Statistics summary plotting. NULL, plots raw trajectories. quantiles Quantiles uncertainty bands summary plotting exclude_p_columns Logical, whether exclude p_ columns (default: TRUE) ci_level Confidence level label used summary plot title theme ggplot2 theme function (default: theme_minimal()) title Optional custom title","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"ggplot object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-subset-data-","dir":"Reference","previous_headings":"","what":"Method subset_data()","title":"MetaRVM Results Class — MetaRVMResults","text":"Subset data based combination parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$subset_data( ..., disease_states = NULL, date_range = NULL, instances = NULL, exclude_p_columns = TRUE )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"... Named arguments category filters (e.g., age = c(\"0-17\"), income = c(\"low\", \"high\")) disease_states Vector disease states include (default: , excludes p_ columns) date_range Vector two dates start_date, end_date filtering (default: ) instances Vector instance numbers include (default: ) exclude_p_columns Logical, whether exclude p_ columns (default: TRUE)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns-3","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"MetaRVMResults object subset results","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-summarize-","dir":"Reference","previous_headings":"","what":"Method summarize()","title":"MetaRVM Results Class — MetaRVMResults","text":"Summarize results across specified demographic characteristics","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-4","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$summarize( group_by, disease_states = NULL, date_range = NULL, stats = c(\"mean\", \"median\", \"sd\"), quantiles = c(0.25, 0.75), exclude_p_columns = TRUE )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments-3","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"group_by Vector demographic category names group . Must valid category names configuration (e.g., c(\"age\", \"zone\"), c(\"income_level\", \"occupation\")). Use config$get_category_names() see available categories. disease_states Vector disease states include (default: , excludes p_ columns) date_range Optional date range filtering stats Vector statistics calculate: c(\"mean\", \"median\", \"sd\", \"min\", \"max\", \"sum\", \"quantile\"). NULL, returns instances quantiles Vector quantiles calculate \"quantile\" stats (default: c(0.25, 0.75)) exclude_p_columns Logical, whether exclude p_ columns (default: TRUE)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"returns-4","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Results Class — MetaRVMResults","text":"data.table summarized time series data instances stats = NULL","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Results Class — MetaRVMResults","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"usage-5","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"MetaRVMResults$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"arguments-4","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Results Class — MetaRVMResults","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMResults.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Results Class — MetaRVMResults","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") # Run simulation results_obj <- metaRVM(example_config) #> Loading required namespace: pkgbuild # Access formatted results head(results_obj$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.742619e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.555784e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.483657e+01 1 # Subset data with multiple filters subset_data <- results_obj$subset_data( age = c(\"18-64\", \"65+\"), disease_states = c(\"H\", \"D\"), date_range = c(as.Date(\"2024-01-01\"), as.Date(\"2024-02-01\")) ) # Method chaining for analysis and visualization results_obj$subset_data(disease_states = \"H\")$summarize( group_by = c(\"age\", \"zone\"), stats = c(\"median\", \"quantile\"), quantiles = c(0.25, 0.75) )$plot() # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":null,"dir":"Reference","previous_headings":"","what":"MetaRVM Summary Class — MetaRVMSummary","title":"MetaRVM Summary Class — MetaRVMSummary","text":"R6 class summarized MetaRVM results plotting capabilities method chaining support. class stores summarized simulation data provides visualization methods automatically adapt based data structure grouping variables.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Summary Class — MetaRVMSummary","text":"MetaRVMSummary class designed work seamlessly method chaining MetaRVMResults. stores either summary statistics (mean, median, quantiles, etc.) individual instance data, provides intelligent plotting methods automatically determine appropriate visualizations based data structure demographic groupings. class supports two data types: Summary data: Contains aggregated statistics across simulation instances Instance data: Contains individual trajectory data simulation instance Plotting behavior adapts automatically: Single grouping variable: Facets demographic category, colors disease state Two grouping variables: Grid layout demographics facet dimensions Three grouping variables: Grid layout first two facets, third color","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"public-fields","dir":"Reference","previous_headings":"","what":"Public Fields","title":"MetaRVM Summary Class — MetaRVMSummary","text":"data data.table containing summarized results config MetaRVMConfig object original simulation type Character string indicating data type (\"summary\" \"instances\")","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"public-fields-1","dir":"Reference","previous_headings":"","what":"Public fields","title":"MetaRVM Summary Class — MetaRVMSummary","text":"data Summarized data config Original MetaRVMConfig object type Type summary (\"instances\" \"summary\")","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"public-methods","dir":"Reference","previous_headings":"","what":"Public methods","title":"MetaRVM Summary Class — MetaRVMSummary","text":"MetaRVMSummary$new() MetaRVMSummary$print() MetaRVMSummary$plot() MetaRVMSummary$clone()","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-new-","dir":"Reference","previous_headings":"","what":"Method new()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Initialize MetaRVMSummary object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$new(data, config, type)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Summary Class — MetaRVMSummary","text":"data data.table containing summarized instance data config MetaRVMConfig object original simulation type Character string indicating data type (\"summary\" \"instances\")","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"returns","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Summary Class — MetaRVMSummary","text":"New MetaRVMSummary object (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-print-","dir":"Reference","previous_headings":"","what":"Method print()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Print summary data object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage-1","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$print()"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"returns-1","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Self (invisible)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-plot-","dir":"Reference","previous_headings":"","what":"Method plot()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"Plot method shows median quantile bands","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage-2","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$plot(ci_level = 0.95, theme = theme_minimal(), title = NULL)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"arguments-1","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Summary Class — MetaRVMSummary","text":"ci_level Confidence level empirical quantiles (default: 0.95). used quantile columns pre-specified theme ggplot2 theme function (default: theme_minimal()) title Optional custom plot title","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"details-1","dir":"Reference","previous_headings":"","what":"Details","title":"MetaRVM Summary Class — MetaRVMSummary","text":"method creates time series plots automatic layout adaptation based grouping variables: summary data: Shows median lines quantile confidence bands Automatically determines faceting strategy based number grouping variables Uses disease states color differentiation appropriate method requires specific data structure: Summary data must contain 'median_value' quantile columns (e.g., 'q25', 'q75') Instance data must contain 'instance' column individual trajectory grouping","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"returns-2","dir":"Reference","previous_headings":"","what":"Returns","title":"MetaRVM Summary Class — MetaRVMSummary","text":"ggplot object","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"method-clone-","dir":"Reference","previous_headings":"","what":"Method clone()","title":"MetaRVM Summary Class — MetaRVMSummary","text":"objects class cloneable method.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"usage-3","dir":"Reference","previous_headings":"","what":"Usage","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"MetaRVMSummary$clone(deep = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"arguments-2","dir":"Reference","previous_headings":"","what":"Arguments","title":"MetaRVM Summary Class — MetaRVMSummary","text":"deep Whether make deep clone.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/MetaRVMSummary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"MetaRVM Summary Class — MetaRVMSummary","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config_dist.yaml\", package = \"MetaRVM\") # Run simulation results <- metaRVM(example_config) # Typically created through method chaining summary_obj <- results$subset_data(disease_states = \"H\")$summarize( group_by = c(\"age\", \"zone\"), stats = c(\"median\", \"quantile\"), quantiles = c(0.25, 0.75) ) # Direct plotting summary_obj$plot() # Plot with custom ggplot theme and confidence level summary_obj$plot(theme = ggplot2::theme_bw()) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to draw samples for distributional parameters — draw_sample","title":"Function to draw samples for distributional parameters — draw_sample","text":"Function draw samples distributional parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to draw samples for distributional parameters — draw_sample","text":"","code":"draw_sample(config_list, N_pop, seed = NULL)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to draw samples for distributional parameters — draw_sample","text":"config_list list configurations N_pop Number subpopulations seed","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/draw_sample.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to draw samples for distributional parameters — draw_sample","text":"random sample drawn distribution specified dist component","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":null,"dir":"Reference","previous_headings":"","what":"Format MetaRVM simulation output — format_metarvm_output","title":"Format MetaRVM simulation output — format_metarvm_output","text":"function formats raw MetaRVM simulation output : Converting time steps calendar dates Adding user-defined demographic attributes initialization-derived population metadata Handling different disease states appropriately: Regular states (S, E, , etc.): Keep values integer time points New count states (n_ prefix): Sum pairs get daily counts","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format MetaRVM simulation output — format_metarvm_output","text":"","code":"format_metarvm_output(sim_output, config)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format MetaRVM simulation output — format_metarvm_output","text":"sim_output data.table containing raw simulation output meta_sim config MetaRVMConfig object config list containing parameters","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format MetaRVM simulation output — format_metarvm_output","text":"data.table formatted output including calendar dates demographics","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/format_metarvm_output.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Format MetaRVM simulation output — format_metarvm_output","text":"function used formatting meta_sim output MetaRVM function called.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":null,"dir":"Reference","previous_headings":"","what":"NULL Coalescing Operator — grapes-or-or-grapes","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"Returns left-hand side NULL, otherwise returns right-hand side. utility function used internally MetaRVM classes.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"","code":"x %||% y"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"x Left-hand side value y Right-hand side value (default/fallback)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"x x NULL, otherwise y","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/grapes-or-or-grapes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"NULL Coalescing Operator — grapes-or-or-grapes","text":"","code":"if (FALSE) { # \\dontrun{ user_title <- \"User Title\" # Internal usage in classes title <- user_title %||% \"Default Title\" } # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":null,"dir":"Reference","previous_headings":"","what":"Run a MetaRVM epidemic simulation — metaRVM","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"metaRVM() high-level entry point running MetaRVM metapopulation respiratory virus simulation. parses configuration, runs one simulation instances (deterministic stochastic), formats ODIN/MetaRVM output tidy long table calendar dates demographic attributes, returns MetaRVMResults object downstream analysis plotting.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"","code":"metaRVM(config_input)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"config_input Configuration specification one three forms: Character string: path YAML configuration file. MetaRVMConfig object: pre-initialized configuration. Named list: output parse_config() return_object = FALSE.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"MetaRVMResults R6 object three key components: $results tidy data.table one row per date–subpopulation–disease state–instance combination. Typical columns include: date: calendar date (Date) user-defined demographic category columns (present initialization file) disease_state: compartment flow label (e.g., S, E, I_symp, H, R, D, n_SE, n_IsympH, etc.) value: population count daily flow instance: simulation instance index (1, 2, …) $config MetaRVMConfig object used run. $run_info list metadata n_instances, date_range, delta_t, checkpoint information.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"configuration input controls: Population structure (user-defined categories initial compartment counts initialization file) Disease parameters (ts, ve, de, dp, da, ds, dh, dr, pea, psr, phr, dv, etc.) Mixing matrices (weekday/weekend, day/night contact patterns) Vaccination schedule immunity waning Simulation settings (start date, length, number instances, stochastic vs. deterministic mode, checkpointing) Internally, metaRVM(): Parses YAML configuration via parse_config(). Calls ODIN-based simulation engine meta_sim() instance. Uses format_metarvm_output() convert time steps dates attach demographic attributes. Wraps formatted output metadata MetaRVMResults object supports method chaining subsetting, summarizing, plotting.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"Fadikar, ., et al. \"Developing deploying use-inspired metapopulation modeling framework detailed tracking stratified health outcomes\"","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"Arindam Fadikar, Charles Macal, Ignacio Martinez-Moyano, Jonathan Ozik","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/metaRVM.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run a MetaRVM epidemic simulation — metaRVM","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") # Run a single-instance simulation from a YAML file results <- metaRVM(example_config) # Print a high-level summary results #> MetaRVM Results Object #> ===================== #> Instances: 1 #> Populations: #> Date range: 2023-10-01 to 2024-02-27 #> Parameter sets (nsim): 1 #> Replicates per set (nrep): 1 #> Simulation mode: deterministic #> Total observations: 388800 #> Disease states: D, E, H, I_all, I_asymp, I_eff, I_presymp, I_symp, P, R, S, S_alloc, S_eff_prod, S_src_int, V, V_alloc, V_src_int, cum_V, mob_pop, n_EI, n_EIpresymp, n_HD, n_HR, n_HRD, n_IasympR, n_IsympH, n_IsympR, n_IsympRH, n_RS, n_SE, n_SE_eff, n_SV, n_VE, n_VS, n_preIsymp, p_HRD, p_RS, p_SE, p_VE # Access the tidy results table head(results$results) #> date age race zone disease_state value instance #> #> 1: 2023-10-01 0-17 A 11 D 2.252583e-04 1 #> 2: 2023-10-01 0-17 A 11 E 1.365434e+01 1 #> 3: 2023-10-01 0-17 A 11 H 2.304447e-01 1 #> 4: 2023-10-01 0-17 A 11 I_all 2.742619e+01 1 #> 5: 2023-10-01 0-17 A 11 I_asymp 3.555784e-01 1 #> 6: 2023-10-01 0-17 A 11 I_eff 2.483657e+01 1 # Summarize and plot hospitalizations and deaths by user-defined categories results$summarize( group_by = c(\"age\", \"zone\"), disease_states = c(\"H\", \"D\"), stats = c(\"median\", \"quantile\"), quantiles = c(0.25, 0.75) )$plot() # Using a pre-parsed configuration object cfg <- parse_config(example_config, return_object = TRUE) results2 <- metaRVM(cfg) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":null,"dir":"Reference","previous_headings":"","what":"Metapopulation Respiratory Virus Model Simulator — meta_sim","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"core simulation engine implements stochastic compartmental SEIRD (Susceptible-Exposed-Infected-Recovered-Dead) model respiratory virus epidemics across multiple demographic subpopulations. function compiles executes ODIN-based differential equation model time-varying contact patterns, vaccination dynamics, complex disease progression pathways.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"","code":"meta_sim( N_pop, ts, S0, I0, P0, R0, H0 = rep(0, N_pop), D0 = rep(0, N_pop), Ia0 = rep(0, N_pop), Ip0 = rep(0, N_pop), E0 = rep(0, N_pop), V0 = rep(0, N_pop), m_weekday_day, m_weekday_night, m_weekend_day, m_weekend_night, start_day = 0, delta_t, vac_mat, dv, de, pea, dp, da, ds, psr, dh, phr, dr, ve, nsteps, is.stoch = FALSE, seed = NULL, do_chk = FALSE, chk_time_steps = NULL, chk_file_names = NULL )"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"N_pop Integer. Number demographic subpopulations model ts Numeric vector scalar. Transmission rate symptomatic individuals susceptible population. scalar, applied subpopulations S0 Numeric vector length N_pop. Initial number susceptible individuals subpopulation I0 Numeric vector length N_pop. Initial number symptomatic infected individuals subpopulation P0 Numeric vector length N_pop. Total population sizes subpopulation R0 Numeric vector length N_pop. Initial number recovered individuals subpopulation H0 Numeric vector length N_pop. Initial number hospitalized individuals subpopulation (default: rep(0, N_pop)) D0 Numeric vector length N_pop. Initial number deceased individuals subpopulation (default: rep(0, N_pop)) Ia0 Numeric vector length N_pop. Initial number asymptomatic infected individuals subpopulation (default: rep(0, N_pop)) Ip0 Numeric vector length N_pop. Initial number presymptomatic infected individuals subpopulation (default: rep(0, N_pop)) E0 Numeric vector length N_pop. Initial number exposed individuals subpopulation (default: rep(0, N_pop)) V0 Numeric vector length N_pop. Initial number vaccinated individuals subpopulation m_weekday_day Numeric matrix (N_pop × N_pop). Contact mixing matrix weekday daytime (6 - 6 PM) interactions m_weekday_night Numeric matrix (N_pop × N_pop). Contact mixing matrix weekday nighttime (6 PM - 6 ) interactions m_weekend_day Numeric matrix (N_pop × N_pop). Contact mixing matrix weekend daytime (6 - 6 PM) interactions m_weekend_night Numeric matrix (N_pop × N_pop). Contact mixing matrix weekend nighttime (6 PM - 6 ) interactions start_day Start day week expressed integer value 0 6, 0 Monday. Default simulation start day Monday. delta_t Positive numeric. Discrete time increment days (typically 0.5) vac_mat Numeric matrix. Vaccination schedule dimensions (nsteps × (1 + N_pop)). First column contains time indices, remaining columns contain vaccination counts subpopulation time step dv Numeric vector scalar. Mean duration (days) vaccinated state immunity waning. scalar, applied subpopulations de Numeric vector scalar. Mean duration (days) exposed state. scalar, applied subpopulations pea Numeric vector scalar. Proportion exposed individuals becoming asymptomatic infectious (vs. presymptomatic), values 0 1. scalar, applied subpopulations. scalar, applied subpopulations dp Numeric vector scalar. Mean duration (days) presymptomatic infectious state. scalar, applied subpopulations da Numeric vector scalar. Mean duration (days) asymptomatic infectious state. scalar, applied subpopulations ds Numeric vector scalar. Mean duration (days) symptomatic infectious state. scalar, applied subpopulations psr Numeric vector scalar. Proportion symptomatic individuals recovering directly (vs. hospitalization), values 0 1. scalar, applied subpopulations. scalar, applied subpopulations dh Numeric vector scalar. Mean duration (days) hospitalized state. scalar, applied subpopulations phr Numeric vector scalar. Proportion hospitalized individuals recovering (vs. death). , values 0 1. scalar, applied subpopulations. dr Numeric vector scalar. Mean duration (days) immunity recovered state. scalar, applied subpopulations ve Numeric vector scalar. Vaccine effectiveness (proportion) , values 0 1. scalar, applied subpopulations nsteps Integer. Total number discrete time evolution steps simulation .stoch Logical. Whether run stochastic simulation (TRUE) deterministic simulation (FALSE). Default: FALSE seed Integer NULL. Random seed reproducibility. used .stoch = TRUE. Default: NULL do_chk Logical. Whether save model checkpoint simulation end. Default: FALSE chk_time_steps Integer vector NULL. Time steps save checkpoints. chk_file_names List character vectors NULL. File names checkpoints. element list corresponds time step chk_time_steps.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"Returns data.table following structure: step Integer time step index (0 nsteps) time Continuous simulation time (step × delta_t) disease_state Character vector compartment names population_id Character vector subpopulation identifiers value Numeric values representing population counts compartment Available disease states output: Core compartments: S, E, I_presymp, I_asymp, I_symp, H, R, D, V, P Derived outputs: I_all (total infectious), cum_V (cumulative vaccinations) Transition flows: n_SE, n_EI, n_HR, n_HD, etc. (new infections, hospitalizations, deaths) Debug outputs: p_SE, p_VE, I_eff (probabilities effective populations)","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"model implements metapopulation epidemiological framework following features: Compartmental Structure: S: Susceptible individuals E: Exposed (incubating) individuals I_presymp: Presymptomatic infectious individuals I_asymp: Asymptomatic infectious individuals I_symp: Symptomatic infectious individuals H: Hospitalized individuals R: Recovered individuals D: Deceased individuals V: Vaccinated individuals P: Total living population (excludes deaths) Disease Progression Pathways: S → E: Exposure contact infectious individuals E → I_asymp/I_presymp: Progression infectious states (proportion pea) I_presymp → I_symp: Development symptoms I_asymp → R: Direct recovery asymptomatic state I_symp → R/H: Recovery hospitalization (proportion psr) H → R/D: Hospital discharge death (proportion phr) R → S: Loss immunity S → V: Vaccination V → S/E: Vaccine waning breakthrough infection Mixing Patterns: Contact patterns vary : Day week: Weekday vs. weekend patterns Time day: Day (6 - 6 PM) vs. night (6 PM - 6 ) patterns pattern specified N_pop × N_pop contact matrix Force Infection: Transmission occurs contact susceptible/vaccinated individuals infectious compartments (I_presymp + I_asymp + I_symp), modified : Population-specific transmission rate, ts Time-varying contact patterns Vaccine effectiveness breakthrough infections Stochastic vs. Deterministic Mode: Deterministic: Uses exact differential equations Stochastic: Adds demographic stochasticity via binomial draws Vaccination Implementation: Vaccination implemented time-varying input : Scheduled vaccination counts per time step subpopulation Vaccine effectiveness reducing infection probability Waning immunity returning individuals susceptible state","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"parameter-scaling","dir":"Reference","previous_headings":"","what":"Parameter Scaling","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"duration parameters automatically converted rates (1/duration). Scalar parameters automatically expanded vectors length N_pop. allows flexible specification homogeneous heterogeneous parameters.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"checkpointing","dir":"Reference","previous_headings":"","what":"Checkpointing","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"do_chk = TRUE, function saves checkpoint file containing: Final compartment states simulation continuation model parameters reproducibility Vaccination schedule data Population structure information","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"ODIN package: https://mrc-ide.github.io/odin/ Fadikar, ., et al. \"Developing deploying use-inspired metapopulation modeling framework detailed tracking stratified health outcomes\"","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"Arindam Fadikar, Charles Macal, Ignacio Martinez-Moyano, Jonathan Ozik","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/meta_sim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Metapopulation Respiratory Virus Model Simulator — meta_sim","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) # Basic deterministic simulation N_pop <- 2 nsteps <- 400 # Initialize populations S0 <- rep(1000, N_pop) I0 <- rep(10, N_pop) P0 <- S0 + I0 R0 <- rep(0, N_pop) # Contact matrices (simplified - identity matrices) contact_matrix <- diag(N_pop) # Basic vaccination schedule (10% vaccination) vac_mat <- matrix(0, nrow = nsteps + 1, ncol = N_pop + 1) vac_mat[, 1] <- 0:nsteps vac_mat[1, 1 + (1:N_pop)] <- P0 * 0.1 # Run simulation results <- meta_sim( N_pop = N_pop, ts = 0.5, S0 = S0, I0 = I0, P0 = P0, R0 = R0, m_weekday_day = contact_matrix, m_weekday_night = contact_matrix, m_weekend_day = contact_matrix, m_weekend_night = contact_matrix, delta_t = 0.5, vac_mat = vac_mat, dv = 365, de = 3, pea = 0.3, dp = 2, da = 7, ds = 7, psr = 0.95, dh = 10, phr = 0.9, dr = 180, ve = 0.8, nsteps = nsteps, is.stoch = FALSE ) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse MetaRVM Configuration File — parse_config","title":"Parse MetaRVM Configuration File — parse_config","text":"Reads parses YAML configuration file MetaRVM simulations, extracting necessary parameters epidemic modeling including population data, disease parameters, mixing matrices, vaccination schedules, simulation settings.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse MetaRVM Configuration File — parse_config","text":"","code":"parse_config(config_file, return_object = FALSE)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse MetaRVM Configuration File — parse_config","text":"config_file Character string. Path YAML configuration file containing model parameters settings. return_object Logical. TRUE, returns MetaRVMConfig object method chaining enhanced functionality. FALSE (default), returns named list backward compatibility.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse MetaRVM Configuration File — parse_config","text":"return_object = FALSE (default), returns named list containing: N_pop Number population groups pop_map Data.table population_id user-defined demographic categories S_ini, E_ini, I_asymp_ini, I_presymp_ini, I_symp_ini, H_ini, D_ini, P_ini, V_ini, R_ini Initial compartment populations vac_time_id, vac_counts, vac_mat Vaccination schedule data m_wd_d, m_wd_n, m_we_d, m_we_n Contact mixing matrices ts, ve, dv, de, dp, da, ds, dh, dr, pea, psr, phr Disease parameter matrices (nsim × N_pop) start_date Simulation start date Date object sim_length Simulation length days nsim Number simulation instances nrep Number stochastic replicates per parameter set simulation_mode Simulation mode: \"deterministic\" \"stochastic\" random_seed Random seed used () delta_t Time step size (fixed 0.5) chk_file_names, chk_time_steps, do_chk Checkpointing configuration return_object = TRUE, returns MetaRVMConfig object methods parameter access validation.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Parse MetaRVM Configuration File — parse_config","text":"function processes YAML configuration file following main sections: Simulation Configuration: random_seed: Optional random seed reproducibility case stochastic simulations stochastic parameters nsim: Number simulation instances (default: 1) nrep: Number stochastic replicates per parameter set (default: 1) simulation_mode: Optional simulation mode. Must one \"deterministic\" \"stochastic\" (default: \"deterministic\"). start_date: Simulation start date MM/DD/YYYY format length: Simulation length days checkpoint_dir: Optional checkpoint directory saving intermediate results checkpoint_dates: Optional list dates save checkpoints. restore_from: Optional path restore simulation checkpoint Population Data: initialization: CSV file initial population states optional user-defined category columns. file must contain columns population_id, N, S0, I0, V0, R0. additional columns treated demographic categories. vaccination: CSV file vaccination schedule time. first column must dates MM/DD/YYYY format. rest columns must corresponds respective subpopulations numeric order population_id. Mixing Matrices: Contact matrices different time periods. CSV file must matrix order (N_pop x N_pop), , N_pop number subpopulations. assumed -th row j-th column correspond -th j-th subpopulations. weekday_day, weekday_night: Weekday contact patterns weekend_day, weekend_night: Weekend contact patterns Disease Parameters: Epidemiological parameters (can scalars distributions): ts: Transmission rate symptomatic individuals ve: Vaccine effectiveness de, dp, da, ds, dh, dr: Duration parameters different disease states pea, psr, phr: Probability parameters disease transitions Sub-population Parameters: sub_disease_params allows specification different parameter values specific demographic categories (e.g., age groups, races). function supports stochastic parameters distribution specifications dist, mu, sd, shape, rate, etc.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"parameter-distributions","dir":"Reference","previous_headings":"","what":"Parameter Distributions","title":"Parse MetaRVM Configuration File — parse_config","text":"Disease parameters can specified distributions stochastic modeling: lognormal: dist: \"lognormal\", mu: value, sd: value gamma: dist: \"gamma\", shape: value, rate: value uniform: dist: \"uniform\", min: value, max: value beta: dist: \"beta\", shape1: value, shape2: value gaussian: dist: \"gaussian\", mean: value, sd: value","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"file-requirements","dir":"Reference","previous_headings":"","what":"File Requirements","title":"Parse MetaRVM Configuration File — parse_config","text":"Population initialization file must contain columns: population_id: Unique identifier population group, natural numbers N: Total population size subpopulation S0, I0, V0, R0: Initial compartment counts Optional user-defined category columns (e.g., age, race, zone, income_level, occupation) Vaccination file must contain: date (MM/DD/YYYY format) vaccination counts population group","code":""},{"path":[]},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Parse MetaRVM Configuration File — parse_config","text":"Arindam Fadikar","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/parse_config.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Parse MetaRVM Configuration File — parse_config","text":"","code":"# \\donttest{ options(odin.verbose = FALSE) example_config <- system.file(\"extdata\", \"example_config.yaml\", package = \"MetaRVM\") # Parse configuration file and return list (backward compatible) config <- parse_config(example_config) # Parse and return MetaRVMConfig object for method chaining config_obj <- parse_config(example_config, return_object = TRUE) # Access parameters from config object config_obj$get(\"N_pop\") #> [1] 24 config_obj$list_parameters() #> [1] \"N_pop\" \"pop_map\" \"category_names\" \"S_ini\" #> [5] \"E_ini\" \"I_asymp_ini\" \"I_presymp_ini\" \"I_symp_ini\" #> [9] \"H_ini\" \"D_ini\" \"P_ini\" \"V_ini\" #> [13] \"R_ini\" \"vac_time_id\" \"vac_counts\" \"vac_mat\" #> [17] \"m_wd_d\" \"m_wd_n\" \"m_we_d\" \"m_we_n\" #> [21] \"ts\" \"ve\" \"dv\" \"de\" #> [25] \"dp\" \"da\" \"ds\" \"dh\" #> [29] \"dr\" \"pea\" \"psr\" \"phr\" #> [33] \"start_date\" \"sim_length\" \"nsim\" \"nrep\" #> [37] \"simulation_mode\" \"random_seed\" \"delta_t\" \"chk_file_names\" #> [41] \"chk_time_steps\" \"do_chk\" # Use with MetaRVM simulation results <- metaRVM(config_obj) # }"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Read and prepare vaccination data — process_vac_data","title":"Read and prepare vaccination data — process_vac_data","text":"function takes vaccination schedule given data.table prepares according required structure needed meta_sim() function","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read and prepare vaccination data — process_vac_data","text":"","code":"process_vac_data(vac_dt, sim_start_date, sim_length, delta_t)"},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read and prepare vaccination data — process_vac_data","text":"vac_dt data.table vaccination schedule sim_start_date calendar date format yyyy-mm-dd sim_length Number calendar days simulation runs delta_t Step size simulation","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/reference/process_vac_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read and prepare vaccination data — process_vac_data","text":"data.table","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/news/index.html","id":"metarvm-210","dir":"Changelog","previous_headings":"","what":"MetaRVM 2.1.0","title":"MetaRVM 2.1.0","text":"Added simulation_mode (deterministic/stochastic) nrep support configuration parsing run metadata. Improved stochastic reproducibility: provided random_seed honored, seed generated/stored missing. Updated stochastic transition splitting use binomial draws integer compartment flows (n_EIpresymp, n_IsympH, n_HR). Improved metapopulation infection-flow indexing consistency destination- specific force infection n_SE_eff n_VE_eff. Added bounded vaccination transition safeguards reduce overdraw risks (example, capping applied vaccination available susceptible count guarding zero effective population force--infection calculations). Added integer row allocation stochastic mixing flows (S V) using floor-plus-residual adjustment row totals conserved. Added regression tests stochastic seed behavior, nsim * nrep instance counts, row-allocation conservation checks S/V mixing. Enhanced results helper APIs: MetaRVMResults$plot() now provides direct trajectory plotting summarization. MetaRVMSummary$plot() now supports instance-trajectory plotting. summarize() uses efficient single-pass grouped aggregation.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/news/index.html","id":"metarvm-200","dir":"Changelog","previous_headings":"","what":"MetaRVM 2.0.0","title":"MetaRVM 2.0.0","text":"CRAN release: 2026-03-19 Subpopulation categories now user-defined population_data$initialization; non-reserved columns detected automatically. Improved checkpoint restore behavior parse_config(): restore_from provided, population_data$initialization can used mapping-metadata (without N, S0, I0, etc.). Improved validation messages category filters: invalid category names now list available categories, invalid category values now list valid values selected category. Improved format_metarvm_output() handling population_id dynamic column selection user-defined categories. Updated documentation vignettes reflect user-defined subpopulation categories checkpoint restore behavior.","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/news/index.html","id":"metarvm-101","dir":"Changelog","previous_headings":"","what":"MetaRVM 1.0.1","title":"MetaRVM 1.0.1","text":"CRAN release: 2026-01-09","code":""},{"path":"https://RESUME-Epi.github.io/MetaRVM/news/index.html","id":"metarvm-100","dir":"Changelog","previous_headings":"","what":"MetaRVM 1.0.0","title":"MetaRVM 1.0.0","text":"CRAN release: 2025-12-19 Initial CRAN submission.","code":""}]
diff --git a/inst/extdata/example_config.yaml b/inst/extdata/example_config.yaml
index 7117481..1ad7947 100644
--- a/inst/extdata/example_config.yaml
+++ b/inst/extdata/example_config.yaml
@@ -24,3 +24,4 @@ simulation_config:
start_date: 10/01/2023 # m/d/Y
length: 150
nsim: 1
+ simulation_mode: deterministic
diff --git a/inst/extdata/example_config_checkpoint.yaml b/inst/extdata/example_config_checkpoint.yaml
index c0d1f87..667e99d 100644
--- a/inst/extdata/example_config_checkpoint.yaml
+++ b/inst/extdata/example_config_checkpoint.yaml
@@ -24,4 +24,5 @@ simulation_config:
start_date: 10/01/2024 # m/d/Y
length: 90
nsim: 1
+ simulation_mode: deterministic
# The checkpoint_dir will be set dynamically in the vignette
diff --git a/inst/extdata/example_config_dist.yaml b/inst/extdata/example_config_dist.yaml
index d3de7d3..0e76626 100644
--- a/inst/extdata/example_config_dist.yaml
+++ b/inst/extdata/example_config_dist.yaml
@@ -36,3 +36,4 @@ simulation_config:
start_date: 01/01/2023 # m/d/Y
length: 150
nsim: 20 # Increased nsim for meaningful summary statistics
+ simulation_mode: deterministic
diff --git a/inst/extdata/example_config_stochastic.yaml b/inst/extdata/example_config_stochastic.yaml
new file mode 100644
index 0000000..f8cc2b4
--- /dev/null
+++ b/inst/extdata/example_config_stochastic.yaml
@@ -0,0 +1,29 @@
+run_id: ExampleRun_Stochastic_Static
+population_data:
+ initialization: population_init_n24.csv
+ vaccination: vaccination_n24.csv
+mixing_matrix:
+ weekday_day: m_weekday_day.csv
+ weekday_night: m_weekday_night.csv
+ weekend_day: m_weekend_day.csv
+ weekend_night: m_weekend_night.csv
+disease_params:
+ ts: 0.5
+ ve: 0.4
+ dv: 180
+ dp: 1
+ de: 3
+ da: 5
+ ds: 6
+ dh: 8
+ dr: 180
+ pea: 0.3
+ psr: 0.95
+ phr: 0.97
+simulation_config:
+ start_date: 01/01/2023 # m/d/Y
+ length: 150
+ nsim: 1
+ nrep: 5
+ simulation_mode: stochastic
+ random_seed: 42
diff --git a/inst/extdata/example_config_subgroup_dist.yaml b/inst/extdata/example_config_subgroup_dist.yaml
index 9f60cf3..1be0332 100644
--- a/inst/extdata/example_config_subgroup_dist.yaml
+++ b/inst/extdata/example_config_subgroup_dist.yaml
@@ -40,3 +40,4 @@ simulation_config:
start_date: 01/01/2023 # m/d/Y
length: 150
nsim: 20
+ simulation_mode: deterministic
diff --git a/man/MetaRVMResults.Rd b/man/MetaRVMResults.Rd
index 61b5086..4ec0510 100644
--- a/man/MetaRVMResults.Rd
+++ b/man/MetaRVMResults.Rd
@@ -58,6 +58,7 @@ Arindam Fadikar
\itemize{
\item \href{#method-MetaRVMResults-new}{\code{MetaRVMResults$new()}}
\item \href{#method-MetaRVMResults-print}{\code{MetaRVMResults$print()}}
+\item \href{#method-MetaRVMResults-plot}{\code{MetaRVMResults$plot()}}
\item \href{#method-MetaRVMResults-subset_data}{\code{MetaRVMResults$subset_data()}}
\item \href{#method-MetaRVMResults-summarize}{\code{MetaRVMResults$summarize()}}
\item \href{#method-MetaRVMResults-clone}{\code{MetaRVMResults$clone()}}
@@ -108,6 +109,55 @@ Self (invisible)
}
}
\if{html}{\out{
}}
+\if{html}{\out{}}
+\if{latex}{\out{\hypertarget{method-MetaRVMResults-plot}{}}}
+\subsection{Method \code{plot()}}{
+Plot simulation trajectories directly from results
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{MetaRVMResults$plot(
+ group_by = character(0),
+ disease_states = NULL,
+ date_range = NULL,
+ instances = NULL,
+ stats = NULL,
+ quantiles = c(0.25, 0.75),
+ exclude_p_columns = TRUE,
+ ci_level = 0.95,
+ theme = theme_minimal(),
+ title = NULL
+)}\if{html}{\out{}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{group_by}}{Vector of demographic category names to group/facet by}
+
+\item{\code{disease_states}}{Optional disease states to include}
+
+\item{\code{date_range}}{Optional date range for filtering}
+
+\item{\code{instances}}{Optional instance IDs to include}
+
+\item{\code{stats}}{Statistics for summary plotting. If NULL, plots raw trajectories.}
+
+\item{\code{quantiles}}{Quantiles for uncertainty bands when summary plotting}
+
+\item{\code{exclude_p_columns}}{Logical, whether to exclude p_ columns (default: TRUE)}
+
+\item{\code{ci_level}}{Confidence level label used in summary plot title}
+
+\item{\code{theme}}{ggplot2 theme function (default: theme_minimal())}
+
+\item{\code{title}}{Optional custom title}
+}
+\if{html}{\out{}}
+}
+\subsection{Returns}{
+ggplot object
+}
+}
+\if{html}{\out{
}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-MetaRVMResults-subset_data}{}}}
\subsection{Method \code{subset_data()}}{
diff --git a/man/figures/README-unnamed-chunk-3-1.png b/man/figures/README-unnamed-chunk-3-1.png
index eca5314..d64a957 100644
Binary files a/man/figures/README-unnamed-chunk-3-1.png and b/man/figures/README-unnamed-chunk-3-1.png differ
diff --git a/man/parse_config.Rd b/man/parse_config.Rd
index 58df26b..ac9e36a 100644
--- a/man/parse_config.Rd
+++ b/man/parse_config.Rd
@@ -26,6 +26,8 @@ If \code{return_object = FALSE} (default), returns a named list containing:
\item{start_date}{Simulation start date as Date object}
\item{sim_length}{Simulation length in days}
\item{nsim}{Number of simulation instances}
+\item{nrep}{Number of stochastic replicates per parameter set}
+\item{simulation_mode}{Simulation mode: \code{"deterministic"} or \code{"stochastic"}}
\item{random_seed}{Random seed used (if any)}
\item{delta_t}{Time step size (fixed at 0.5)}
\item{chk_file_names, chk_time_steps, do_chk}{Checkpointing configuration}
@@ -47,6 +49,9 @@ main sections:
\itemize{
\item \code{random_seed}: Optional random seed for reproducibility in case of stochastic simulations or stochastic parameters
\item \code{nsim}: Number of simulation instances (default: 1)
+\item \code{nrep}: Number of stochastic replicates per parameter set (default: 1)
+\item \code{simulation_mode}: Optional simulation mode. Must be one of
+\code{"deterministic"} or \code{"stochastic"} (default: \code{"deterministic"}).
\item \code{start_date}: Simulation start date in MM/DD/YYYY format
\item \code{length}: Simulation length in days
\item \code{checkpoint_dir}: Optional checkpoint directory for saving intermediate results
diff --git a/tests/testthat/test-metaRVM.R b/tests/testthat/test-metaRVM.R
index 912859a..26ced67 100644
--- a/tests/testthat/test-metaRVM.R
+++ b/tests/testthat/test-metaRVM.R
@@ -107,3 +107,164 @@ test_that("subset_data reports valid values when category value is invalid", {
regexp = "Invalid values for category 'age': NOT_A_VALID_AGE\\. Valid values are:"
)
})
+
+test_that("metaRVM uses provided random_seed for stochastic runs", {
+ ext <- function(x) system.file("extdata", x, package = "MetaRVM")
+ cfg_path <- tempfile(fileext = ".yaml")
+
+ cfg <- list(
+ run_id = "StochasticSeedProvided",
+ population_data = list(
+ initialization = ext("population_init_n24.csv"),
+ vaccination = ext("vaccination_n24.csv")
+ ),
+ mixing_matrix = list(
+ weekday_day = ext("m_weekday_day.csv"),
+ weekday_night = ext("m_weekday_night.csv"),
+ weekend_day = ext("m_weekend_day.csv"),
+ weekend_night = ext("m_weekend_night.csv")
+ ),
+ disease_params = list(
+ ts = 0.5, ve = 0.4, dv = 180, dp = 1, de = 3,
+ da = 5, ds = 6, dh = 8, dr = 180, pea = 0.3, psr = 0.95, phr = 0.97
+ ),
+ simulation_config = list(
+ start_date = "10/01/2023",
+ length = 20,
+ nsim = 1,
+ simulation_mode = "stochastic",
+ random_seed = 12345
+ )
+ )
+
+ yaml::write_yaml(cfg, cfg_path)
+
+ res1 <- metaRVM(cfg_path)
+ res2 <- metaRVM(cfg_path)
+
+ expect_equal(res1$config$get("random_seed"), 12345L)
+ expect_equal(res2$config$get("random_seed"), 12345L)
+ expect_equal(res1$results$value, res2$results$value)
+})
+
+test_that("metaRVM generates and stores random_seed for stochastic runs when missing", {
+ ext <- function(x) system.file("extdata", x, package = "MetaRVM")
+ cfg_path <- tempfile(fileext = ".yaml")
+
+ cfg <- list(
+ run_id = "StochasticSeedGenerated",
+ population_data = list(
+ initialization = ext("population_init_n24.csv"),
+ vaccination = ext("vaccination_n24.csv")
+ ),
+ mixing_matrix = list(
+ weekday_day = ext("m_weekday_day.csv"),
+ weekday_night = ext("m_weekday_night.csv"),
+ weekend_day = ext("m_weekend_day.csv"),
+ weekend_night = ext("m_weekend_night.csv")
+ ),
+ disease_params = list(
+ ts = 0.5, ve = 0.4, dv = 180, dp = 1, de = 3,
+ da = 5, ds = 6, dh = 8, dr = 180, pea = 0.3, psr = 0.95, phr = 0.97
+ ),
+ simulation_config = list(
+ start_date = "10/01/2023",
+ length = 20,
+ nsim = 1,
+ simulation_mode = "stochastic"
+ )
+ )
+
+ yaml::write_yaml(cfg, cfg_path)
+
+ res <- metaRVM(cfg_path)
+ generated_seed <- res$config$get("random_seed")
+
+ expect_true(!is.null(generated_seed))
+ expect_true(is.numeric(generated_seed))
+ expect_length(generated_seed, 1)
+})
+
+test_that("metaRVM runs nsim * nrep instances", {
+ ext <- function(x) system.file("extdata", x, package = "MetaRVM")
+ cfg_path <- tempfile(fileext = ".yaml")
+
+ cfg <- list(
+ run_id = "ReplicateCount",
+ population_data = list(
+ initialization = ext("population_init_n24.csv"),
+ vaccination = ext("vaccination_n24.csv")
+ ),
+ mixing_matrix = list(
+ weekday_day = ext("m_weekday_day.csv"),
+ weekday_night = ext("m_weekday_night.csv"),
+ weekend_day = ext("m_weekend_day.csv"),
+ weekend_night = ext("m_weekend_night.csv")
+ ),
+ disease_params = list(
+ ts = 0.5, ve = 0.4, dv = 180, dp = 1, de = 3,
+ da = 5, ds = 6, dh = 8, dr = 180, pea = 0.3, psr = 0.95, phr = 0.97
+ ),
+ simulation_config = list(
+ start_date = "10/01/2023",
+ length = 20,
+ nsim = 2,
+ nrep = 3,
+ simulation_mode = "deterministic"
+ )
+ )
+
+ yaml::write_yaml(cfg, cfg_path)
+
+ res <- metaRVM(cfg_path)
+ expect_equal(length(unique(res$results$instance)), 6L)
+})
+
+test_that("stochastic integer row allocation conserves S and V row totals", {
+ ext <- function(x) system.file("extdata", x, package = "MetaRVM")
+ cfg_path <- tempfile(fileext = ".yaml")
+
+ cfg <- list(
+ run_id = "RowAllocationConservation",
+ population_data = list(
+ initialization = ext("population_init_n24.csv"),
+ vaccination = ext("vaccination_n24.csv")
+ ),
+ mixing_matrix = list(
+ weekday_day = ext("m_weekday_day.csv"),
+ weekday_night = ext("m_weekday_night.csv"),
+ weekend_day = ext("m_weekend_day.csv"),
+ weekend_night = ext("m_weekend_night.csv")
+ ),
+ disease_params = list(
+ ts = 0.5, ve = 0.4, dv = 180, dp = 1, de = 3,
+ da = 5, ds = 6, dh = 8, dr = 180, pea = 0.3, psr = 0.95, phr = 0.97
+ ),
+ simulation_config = list(
+ start_date = "10/01/2023",
+ length = 10,
+ nsim = 1,
+ simulation_mode = "stochastic",
+ random_seed = 4242
+ )
+ )
+
+ yaml::write_yaml(cfg, cfg_path)
+ res <- metaRVM(cfg_path)
+ dt <- data.table::as.data.table(res$results)
+
+ id_cols <- setdiff(names(dt), c("date", "disease_state", "value", "instance"))
+ by_cols <- c("date", "instance", id_cols)
+
+ s_src <- dt[disease_state == "S_src_int", .(S_src_int = value), by = by_cols]
+ s_alloc <- dt[disease_state == "S_alloc", .(S_alloc_sum = sum(value, na.rm = TRUE)), by = by_cols]
+ s_chk <- merge(s_src, s_alloc, by = by_cols)
+ expect_gt(nrow(s_chk), 0)
+ expect_true(all(abs(s_chk$S_src_int - s_chk$S_alloc_sum) < 1e-8))
+
+ v_src <- dt[disease_state == "V_src_int", .(V_src_int = value), by = by_cols]
+ v_alloc <- dt[disease_state == "V_alloc", .(V_alloc_sum = sum(value, na.rm = TRUE)), by = by_cols]
+ v_chk <- merge(v_src, v_alloc, by = by_cols)
+ expect_gt(nrow(v_chk), 0)
+ expect_true(all(abs(v_chk$V_src_int - v_chk$V_alloc_sum) < 1e-8))
+})
diff --git a/tests/testthat/test-parse_config.R b/tests/testthat/test-parse_config.R
index 25c568f..9aaaea0 100644
--- a/tests/testthat/test-parse_config.R
+++ b/tests/testthat/test-parse_config.R
@@ -15,7 +15,7 @@ test_that("parse_config returns expected list structure for example config", {
"m_wd_d", "m_wd_n", "m_we_d", "m_we_n",
"ts", "ve", "dv", "de", "dp", "da", "ds", "dh", "dr",
"pea", "psr", "phr",
- "start_date", "sim_length", "nsim", "random_seed",
+ "start_date", "sim_length", "nsim", "nrep", "simulation_mode", "random_seed",
"delta_t", "chk_file_names", "chk_time_steps", "do_chk"
)
@@ -56,6 +56,8 @@ test_that("parse_config returns expected list structure for example config", {
expect_true(cfg$sim_length > 0)
expect_true(is.numeric(cfg$delta_t))
expect_equal(cfg$delta_t, 0.5)
+ expect_equal(cfg$nrep, 1L)
+ expect_true(cfg$simulation_mode %in% c("deterministic", "stochastic"))
})
test_that("parse_config expands disease parameters with correct dimensions and ranges", {
@@ -158,3 +160,91 @@ test_that("parse_config reports valid category values when sub_disease_params va
regexp = "Invalid values for category 'age' in sub_disease_params: INVALID_AGE_GROUP\\. Valid values are:"
)
})
+
+test_that("parse_config accepts simulation_mode and defaults to deterministic", {
+ ext <- function(x) system.file("extdata", x, package = "MetaRVM")
+
+ cfg_default_path <- tempfile(fileext = ".yaml")
+ cfg_stoch_path <- tempfile(fileext = ".yaml")
+ cfg_invalid_path <- tempfile(fileext = ".yaml")
+
+ base_cfg <- list(
+ run_id = "SimulationMode",
+ population_data = list(
+ initialization = ext("population_init_n24.csv"),
+ vaccination = ext("vaccination_n24.csv")
+ ),
+ mixing_matrix = list(
+ weekday_day = ext("m_weekday_day.csv"),
+ weekday_night = ext("m_weekday_night.csv"),
+ weekend_day = ext("m_weekend_day.csv"),
+ weekend_night = ext("m_weekend_night.csv")
+ ),
+ disease_params = list(
+ ts = 0.5, ve = 0.4, dv = 180, dp = 1, de = 3,
+ da = 5, ds = 6, dh = 8, dr = 180, pea = 0.3, psr = 0.95, phr = 0.97
+ ),
+ simulation_config = list(
+ start_date = "10/01/2023",
+ length = 30,
+ nsim = 1
+ )
+ )
+
+ yaml::write_yaml(base_cfg, cfg_default_path)
+ expect_equal(parse_config(cfg_default_path)$simulation_mode, "deterministic")
+
+ stoch_cfg <- base_cfg
+ stoch_cfg$simulation_config$simulation_mode <- "stochastic"
+ yaml::write_yaml(stoch_cfg, cfg_stoch_path)
+ expect_equal(parse_config(cfg_stoch_path)$simulation_mode, "stochastic")
+
+ invalid_cfg <- base_cfg
+ invalid_cfg$simulation_config$simulation_mode <- "invalid_mode"
+ yaml::write_yaml(invalid_cfg, cfg_invalid_path)
+ expect_error(
+ parse_config(cfg_invalid_path),
+ regexp = "simulation_mode must be either 'deterministic' or 'stochastic'"
+ )
+})
+
+test_that("parse_config accepts nrep and validates it", {
+ ext <- function(x) system.file("extdata", x, package = "MetaRVM")
+ cfg_ok_path <- tempfile(fileext = ".yaml")
+ cfg_bad_path <- tempfile(fileext = ".yaml")
+
+ base_cfg <- list(
+ run_id = "Replicates",
+ population_data = list(
+ initialization = ext("population_init_n24.csv"),
+ vaccination = ext("vaccination_n24.csv")
+ ),
+ mixing_matrix = list(
+ weekday_day = ext("m_weekday_day.csv"),
+ weekday_night = ext("m_weekday_night.csv"),
+ weekend_day = ext("m_weekend_day.csv"),
+ weekend_night = ext("m_weekend_night.csv")
+ ),
+ disease_params = list(
+ ts = 0.5, ve = 0.4, dv = 180, dp = 1, de = 3,
+ da = 5, ds = 6, dh = 8, dr = 180, pea = 0.3, psr = 0.95, phr = 0.97
+ ),
+ simulation_config = list(
+ start_date = "10/01/2023",
+ length = 30,
+ nsim = 2,
+ nrep = 3
+ )
+ )
+
+ yaml::write_yaml(base_cfg, cfg_ok_path)
+ expect_equal(parse_config(cfg_ok_path)$nrep, 3L)
+
+ bad_cfg <- base_cfg
+ bad_cfg$simulation_config$nrep <- 0
+ yaml::write_yaml(bad_cfg, cfg_bad_path)
+ expect_error(
+ parse_config(cfg_bad_path),
+ regexp = "nrep must be a positive integer"
+ )
+})
diff --git a/vignettes/checkpointing.Rmd b/vignettes/checkpointing.Rmd
index 4d592b6..131447c 100644
--- a/vignettes/checkpointing.Rmd
+++ b/vignettes/checkpointing.Rmd
@@ -48,7 +48,7 @@ example_config <- system.file("extdata", "example_config_checkpoint.yaml",
# Create a temporary directory for checkpoints
checkpoint_dir <- tempdir()
cat("Checkpoint directory:", checkpoint_dir, "\n")
-#> Checkpoint directory: /tmp/RtmpwQdGR9
+#> Checkpoint directory: /tmp/RtmpdtpnKS
```
### Create a Configuration with Checkpointing
@@ -109,12 +109,12 @@ print(head(results$results, 10))
#> date age race zone disease_state value instance
#>
#> 1: 2024-10-01 0-17 A 11 D 2.252583e-04 1
-#> 2: 2024-10-01 0-17 A 11 E 1.346375e+01 1
+#> 2: 2024-10-01 0-17 A 11 E 1.366242e+01 1
#> 3: 2024-10-01 0-17 A 11 H 2.304447e-01 1
-#> 4: 2024-10-01 0-17 A 11 I_all 2.739162e+01 1
-#> 5: 2024-10-01 0-17 A 11 I_asymp 3.452058e-01 1
-#> 6: 2024-10-01 0-17 A 11 I_eff 2.653406e+01 1
-#> 7: 2024-10-01 0-17 A 11 I_presymp 8.054801e-01 1
+#> 4: 2024-10-01 0-17 A 11 I_all 2.742766e+01 1
+#> 5: 2024-10-01 0-17 A 11 I_asymp 3.560183e-01 1
+#> 6: 2024-10-01 0-17 A 11 I_eff 2.656285e+01 1
+#> 7: 2024-10-01 0-17 A 11 I_presymp 8.307093e-01 1
#> 8: 2024-10-01 0-17 A 11 I_symp 2.624093e+01 1
#> 9: 2024-10-01 0-17 A 11 P 3.074200e+04 1
#> 10: 2024-10-01 0-17 A 11 R 1.148308e+01 1
@@ -157,7 +157,7 @@ if (length(checkpoint_files_full) > 0) {
} else {
cat("No checkpoint files found to resume from.\n")
}
-#> /tmp/RtmpwQdGR9/chk_2024-12-29_1.Rda
+#> /tmp/RtmpdtpnKS/chk_2024-12-29_1.Rda
#>
#> Number of instances: 1
#> Date range: 2024-12-30 to 2025-03-29
@@ -178,7 +178,8 @@ ggplot(rbind(run1_hosp_sum, run2_hosp_sum), aes(date, total)) +
```
-
+
+
plot of chunk plot
diff --git a/vignettes/getting-started.Rmd b/vignettes/getting-started.Rmd
index 4b75b7c..3cfbfed 100644
--- a/vignettes/getting-started.Rmd
+++ b/vignettes/getting-started.Rmd
@@ -18,11 +18,11 @@ knitr::opts_chunk$set(
## Introduction
-MetaRVM is a comprehensive R package for simulating respiratory virus epidemics using meta-population compartmental models. This vignette will guide you through the basic usage of the package.
+MetaRVM is a comprehensive R package for simulating respiratory virus epidemics using meta-population compartmental models. This vignette describes the basic usage of the package.
## Installation
-You can install the development version of MetaRVM from GitHub:
+The development version of MetaRVM can be installed from GitHub:
```{r eval=FALSE}
# install.packages("devtools")
@@ -41,7 +41,7 @@ options(odin.verbose = FALSE)
This example shows how to run a basic meta-population simulation.
-The `metaRVM` package includes a set of example files in its `extdata` directory. To run the example, we first need to locate these files. The `system.file()` function in R is the recommended way to do this, as it will find the files wherever the package is installed.
+The `metaRVM` package includes a set of example files in its `extdata` directory. To run the example, these files must first be located. The `system.file()` function in R is the recommended way to do this, as it finds the files wherever the package is installed.
```{r}
# Locate the example YAML configuration file
@@ -78,13 +78,16 @@ simulation_config:
start_date: 01/01/2023 # m/d/Y
length: 150
nsim: 1
+ nrep: 1
+ simulation_mode: deterministic
+ random_seed: 42
```
For a detailed explanation of all the configuration options, please see the `yaml-configuration.html` vignette.
## Running the Simulation
-Once we have the path to the configuration file, the simulation can be run using the `metaRVM()` function.
+Once the path to the configuration file is available, the simulation can be run using the `metaRVM()` function.
```{r, results='hide'}
# Load the metaRVM library
diff --git a/vignettes/plot-1.png b/vignettes/plot-1.png
index 244397d..383c613 100644
Binary files a/vignettes/plot-1.png and b/vignettes/plot-1.png differ
diff --git a/vignettes/running-a-simulation.Rmd b/vignettes/running-a-simulation.Rmd
index 8bd209e..76166a2 100644
--- a/vignettes/running-a-simulation.Rmd
+++ b/vignettes/running-a-simulation.Rmd
@@ -20,7 +20,7 @@ This vignette demonstrates how to run a `metaRVM` simulation using the example c
## Locating the Example Files
-The `metaRVM` package includes a set of example files in its `extdata` directory. To run the example, we first need to locate these files. The `system.file()` function in R is the recommended way to do this, as it will find the files wherever the package is installed.
+The `metaRVM` package includes a set of example files in its `extdata` directory. To run the example, these files must first be located. The `system.file()` function in R is the recommended way to do this, as it finds the files wherever the package is installed.
```{r}
# Locate the example YAML configuration file
@@ -57,11 +57,14 @@ simulation_config:
start_date: 01/01/2023 # m/d/Y
length: 150
nsim: 1
+ nrep: 1
+ simulation_mode: deterministic
+ random_seed: 42
```
## Running the Simulation
-Once we have the path to the configuration file, the simulation can be run using the `metaRVM()` function.
+Once the path to the configuration file is available, the simulation can be run using the `metaRVM()` function.
```{r, results='hide'}
# Load the metaRVM library
@@ -221,18 +224,22 @@ simulation_config:
start_date: 01/01/2023 # m/d/Y
length: 150
nsim: 20 # Increased nsim for meaningful summary statistics
+ nrep: 1
+ simulation_mode: deterministic
+ random_seed: 42
```
-To run a simulation with this configuration, we pass the file path to `metaRVM`.
+To run a simulation with this configuration, the file path is passed to `metaRVM`.
```{r, results='hide', message=FALSE, warning=FALSE}
# Run the simulation with the new configuration
sim_out_dist <- metaRVM(yaml_file_dist)
```
+
## Generating Summary Statistics across Demographics
-The `MetaRVMResults` class provides basic summarization functionality across multiple instances of the simulation, when one or more disease parameters are specified via distribution, and there are more than one simulations per configurations. The `summarize` method generates output of class `MetaRVMSummary` which has a `plot` method available to use. Now that we have run a simulation with parameter distributions, we can use the `summarize` method to see the variability in the results.
+The `MetaRVMResults` class provides basic summarization functionality across multiple instances of the simulation, when one or more disease parameters are specified via distribution, and there are more than one simulations per configurations. The `summarize` method generates output of class `MetaRVMSummary` which has a `plot` method available. After a simulation is run with parameter distributions, the `summarize` method can be used to inspect variability in the results.
```{r, fig.height = 4, fig.width = 8, fig.align = "center"}
library(ggplot2)
@@ -250,19 +257,51 @@ hospital_summary_dist$plot() + ggtitle("Daily Hospitalizations by Age Group (wit
```
-```{r, fig.height = 6, fig.width = 8, fig.align = "center"}
+# Running a Stochastic Simulation with Static Parameters
-# Summary of hospitalizations by two user-defined categories
-hospital_summary <- sim_out_dist$summarize(
- group_by = c("age", "zone"),
- disease_states = "n_IsympH",
- stats = c("median", "quantile"),
- quantiles = c(0.05, 0.95)
-)
-hospital_summary
+A stochastic simulation can also be run by setting `simulation_mode: stochastic`.
+
+An example YAML file with parameter distributions is included in the package, `example_config_stochastic.yaml`. Here is its content:
+
+```{r}
+# Locate the example YAML configuration file with distributions
+yaml_file_stoch <- system.file("extdata", "example_config_stochastic.yaml", package = "MetaRVM")
+```
+
+```yaml
+run_id: ExampleRun_Stochastic_Static
+population_data:
+ initialization: population_init_n24.csv
+ vaccination: vaccination_n24.csv
+mixing_matrix:
+ weekday_day: m_weekday_day.csv
+ weekday_night: m_weekday_night.csv
+ weekend_day: m_weekend_day.csv
+ weekend_night: m_weekend_night.csv
+disease_params:
+ ts: 0.5
+ ve: 0.4
+ dv: 180
+ dp: 1
+ de: 3
+ da: 5
+ ds: 6
+ dh: 8
+ dr: 180
+ pea: 0.3
+ psr: 0.95
+ phr: 0.97
+simulation_config:
+ start_date: 01/01/2023 # m/d/Y
+ length: 150
+ nsim: 1
+ nrep: 5
+ simulation_mode: stochastic
+ random_seed: 42
+```
-# visualize the summary
-hospital_summary$plot() + ggtitle("Daily Hospitalizations by Age and Zone") + theme_bw()
+```{r, results='hide', message=FALSE, warning=FALSE}
+sim_out_stoch <- metaRVM(yaml_file_stoch)
```
# Specifying Disease Parameters by Demographics
@@ -317,6 +356,9 @@ simulation_config:
start_date: 01/01/2023 # m/d/Y
length: 150
nsim: 20
+ nrep: 1
+ simulation_mode: deterministic
+ random_seed: 42
```
Now, let's run the simulation with this configuration.
@@ -326,7 +368,7 @@ Now, let's run the simulation with this configuration.
sim_out_subgroup <- metaRVM(yaml_file_subgroup)
```
-We can now plot the results to see the impact of the subgroup-specific parameters. For example, we can compare the number of hospitalizations in the "65+" age group, which has a `dh` of 10, to other age groups that use the global `dh` drawn from a lognormal distribution.
+The results can now be plotted to evaluate the impact of subgroup-specific parameters. For example, the number of hospitalizations in the "65+" age group, which has a `dh` of 10, can be compared to other age groups that use the global `dh` drawn from a lognormal distribution.
```{r, fig.height = 6, fig.width = 8, fig.align = "center"}
# Summarize hospitalizations by age group
diff --git a/vignettes/yaml-configuration.Rmd b/vignettes/yaml-configuration.Rmd
index 4a7ae93..8595171 100644
--- a/vignettes/yaml-configuration.Rmd
+++ b/vignettes/yaml-configuration.Rmd
@@ -49,12 +49,14 @@ simulation_config:
start_date: 01/01/2025 # m/d/Y
length: 90
nsim: 1
+ nrep: 1
+ simulation_mode: deterministic
random_seed: 42
```
### Configuration Sections
-- **`run_id`**: A unique name for your simulation.
+- **`run_id`**: A unique name for the simulation.
- **`population_data`**: Paths to CSV files for population demographics, initial state, and vaccination schedules.
- **`mixing_matrix`**: Paths to CSV files defining contact patterns for different times of the week.
- **`disease_params`**: Disease characteristics. In this example, all parameters are single, fixed values.
@@ -139,7 +141,7 @@ Below is a list of the disease parameters used in `metaRVM`:
## Defining Parameters with Distributions
-Instead of fixed values, you can define disease parameters using statistical distributions. This is useful for capturing uncertainty in the parameters. `metaRVM` supports `uniform` and `lognormal` distributions.
+Instead of fixed values, disease parameters can be defined using statistical distributions. This is useful for capturing uncertainty in the parameters. `metaRVM` supports `uniform` and `lognormal` distributions.
Here is an example of defining `ve`, `da`, `ds`, and `dh` with distributions:
@@ -171,14 +173,14 @@ disease_params:
phr: 0.97
```
-- For a `uniform` distribution, you must specify `min` and `max` values.
-- For a `lognormal` distribution, you must specify `mu` and `sd` (mean and standard deviation on the log scale).
+- For a `uniform` distribution, `min` and `max` values must be specified.
+- For a `lognormal` distribution, `mu` and `sd` (mean and standard deviation on the log scale) must be specified.
## Specifying Subgroup Parameters
-`metaRVM` allows you to specify different disease parameters for various demographic subgroups using the `sub_disease_params` section. These subgroup-specific parameters will override the global parameters defined in `disease_params`.
+`metaRVM` allows different disease parameters to be specified for demographic subgroups using the `sub_disease_params` section. These subgroup-specific parameters override the global parameters defined in `disease_params`.
-The demographic categories used in this section must match the user-defined category column names in the initialization CSV file specified under `population_data`. For example, if your initialization file has columns named `age`, `income_level`, and `occupation`, you can use any of these categories in `sub_disease_params`. The specific values (e.g., `"0-4"`, `"low"`, `"healthcare"`) must exactly match the values in those columns.
+The demographic categories used in this section must match the user-defined category column names in the initialization CSV file specified under `population_data`. For example, if the initialization file has columns named `age`, `income_level`, and `occupation`, any of these categories can be used in `sub_disease_params`. The specific values (e.g., `"0-4"`, `"low"`, `"healthcare"`) must exactly match the values in those columns.
The following example defines different parameters for different age groups:
@@ -204,13 +206,73 @@ sub_disease_params:
In this configuration, individuals in the "0-4" age group will have a `dh` (duration of hospitalization) of 4, overriding any global `dh` value. Similarly, the transmission rate `ts` for the "18-49" group is set to 0.01.
+## Stochastic Simulation with Distributional Parameters
+
+When both parameter uncertainty and stochastic disease transitions are represented,
+set `simulation_mode: stochastic` and define one or more disease
+parameters as distributions.
+
+- `nsim`: number of sampled parameter sets
+- `nrep`: number of stochastic replicates per parameter set
+- total runs = `nsim * nrep`
+
+Example:
+
+```yaml
+run_id: StochasticDistRun
+population_data:
+ initialization: data/population_init.csv
+ vaccination: data/vaccination.csv
+mixing_matrix:
+ weekday_day: data/m_weekday_day.csv
+ weekday_night: data/m_weekday_night.csv
+ weekend_day: data/m_weekend_day.csv
+ weekend_night: data/m_weekend_night.csv
+disease_params:
+ ts: 0.5
+ ve:
+ dist: uniform
+ min: 0.29
+ max: 0.53
+ dv: 158
+ dp: 1
+ de: 3
+ da:
+ dist: uniform
+ min: 3
+ max: 7
+ ds:
+ dist: uniform
+ min: 5
+ max: 7
+ dh:
+ dist: lognormal
+ mu: 2.0
+ sd: 0.5
+ dr: 187
+ pea: 0.333
+ psr: 0.95
+ phr: 0.97
+simulation_config:
+ start_date: 01/01/2025
+ length: 90
+ nsim: 20
+ nrep: 5
+ simulation_mode: stochastic
+ random_seed: 42
+```
+
+For reproducibility, provide `random_seed`. This seed is used to reproduce both
+the parameter draws (for distributional parameters) and the stochastic model
+replicates.
+
## Checkpointing and Restoring Simulations
-For long-running simulations, it is useful to save the state of the model at intermediate points. This is known as checkpointing. `metaRVM` allows you to save checkpoints and restore a simulation from a saved state.
+For long-running simulations, it is useful to save the state of the model at intermediate points. This is known as checkpointing. `metaRVM` allows checkpoints to be saved and simulations to be restored from a saved state.
### Enabling Checkpointing
-To enable checkpointing, you need to add the `checkpoint_dir` and optionally `checkpoint_dates` to the `simulation_config` section of your YAML file.
+To enable checkpointing, `checkpoint_dir` and optionally `checkpoint_dates` need to be added to the `simulation_config` section of the YAML file.
- `checkpoint_dir`: The directory where checkpoint files will be saved.
- `checkpoint_dates`: A list of dates (in `MM/DD/YYYY` format) on which to save a checkpoint. If this is not provided, a single checkpoint will be saved at the end of the simulation.
@@ -222,6 +284,8 @@ simulation_config:
start_date: 01/01/2025
length: 90
nsim: 10
+ nrep: 1
+ simulation_mode: deterministic
random_seed: 42
checkpoint_dir: "path/to/checkpoints"
checkpoint_dates: ["01/15/2025", "01/30/2025"]
@@ -229,13 +293,16 @@ simulation_config:
### Restoring from a Checkpoint
-To restore a simulation from a checkpoint file, use the `restore_from` parameter in the `simulation_config` section. This will initialize the model with the state saved in the specified checkpoint file.
+To restore a simulation from a checkpoint file, the `restore_from` parameter is used in the `simulation_config` section. The model is initialized with the state saved in the specified checkpoint file.
```yaml
simulation_config:
start_date: 01/30/2025 # Should be the next date of the checkpoint date
length: 60 # Remaining simulation length
nsim: 10
+ nrep: 1
+ simulation_mode: deterministic
+ random_seed: 42
restore_from: "path/to/checkpoints/checkpoint_2025-01-30_instance_1.Rda"
```