Skip to contents

Compares two or more simulations, as the app does for Model 1 and Model 2: profiles overlaid in one plot (Simulation and Variability pages), box plots of an exposure metric (the Variability page's "Exposure Box Plots"), or a table of exposure metrics. Use it to compare doses, regimens, populations or models.

Usage

mvp_compare(
  ...,
  var = NULL,
  type = c("profile", "exposure", "table"),
  metric = "AUC",
  start = NULL,
  end = NULL,
  interval = c(0.025, 0.975),
  log_y = FALSE,
  log_x = FALSE,
  window = NULL,
  target = NULL,
  target_time = NULL,
  observed = NULL,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  show_stats = TRUE
)

Arguments

...

Results of mvp_simulate() to compare, named as they should appear (e.g. "50 mg" = sim_50, "100 mg" = sim_100), or one named list.

var

Output to compare (default: each model's first output). Give a vector to use a different output for each simulation.

type

"profile" (default), "exposure" (box plots) or "table".

metric

Exposure metric for type = "exposure": "AUC", "Cmax", "Cmin", "Cavg", "Clast", "Tmax" or "Tmin".

start, end

Time window of the exposure metrics (model time units).

interval

Population profiles: quantiles of the prediction interval.

log_y, log_x

Log scale for the profile plot axes.

window

Profile plot: the part of the x axis shown, c(start, end).

target

Optional value drawn as a dashed horizontal line (e.g. a target concentration).

target_time

Optional time drawn as a dashed vertical line.

observed

Optional observed data overlaid on the profile plot: mvp_observed() (its color and median_by are not used here), or a data frame.

title, xlab, ylab

Plot title and axis labels.

show_stats

Exposure box plots: label the statistics, as in the app.

Value

A ggplot object, or for type = "table" a data frame with the median, mean, 5th and 95th percentiles of each metric per simulation.

Examples

# \donttest{
if (interactive()) {
  mod <- mvp_model("1cmt")
  tt  <- mvp_times(168)
  low  <- mvp_simulate(mod, dose = mvp_dose(50, ii = 24, n = 7), times = tt, population = 100)
  high <- mvp_simulate(mod, dose = mvp_dose(100, ii = 24, n = 7), times = tt, population = 100)
  mvp_compare("50 mg" = low, "100 mg" = high)
  mvp_compare("50 mg" = low, "100 mg" = high, type = "exposure", metric = "Cmin",
              start = 144, end = 168)
}
# }