Skip to contents

Generates VPC plots to assess model performance by comparing observed data with prediction intervals derived from simulated data.

Usage

sg_vpc_vis(
  ds_sim,
  data_i,
  output_names,
  time_col = "TIME",
  dv_col = "DV",
  log_y = FALSE,
  piLow = 0.1,
  piUp = 0.9,
  ciLow = 0.025,
  ciUp = 0.975,
  pred.corr = FALSE,
  lab_y = "DV",
  lab_x = "Time, h",
  theor_perc = TRUE,
  theor_percCI = TRUE,
  emp_perc = TRUE,
  dt_obs_fl = FALSE,
  legend_fl = FALSE,
  n_bins = 10,
  method = "kmeans",
  interpolation = TRUE,
  strat_by_dose = NULL
)

Arguments

ds_sim

GSO. Data frame with simulated data containing columns:

  • ID: simulation replicate identifier

  • TIME: time points

  • VAR: output variable name

  • VALUE: simulated values

data_i

A data frame with observed data containing columns:

  • ID: patient identifier

  • TIME: time points

  • DV: observed dependent variable values

  • DVID: dependent variable identifier

output_names

A data frame mapping VAR values (from ds_sim) to DVID values (from data_i). Must contain columns:

  • output: character, VAR values (e.g., "Cc", "Cp")

  • dvid: numeric, corresponding DVIDs (e.g., 1, 2)

time_col

String. The column to use as a time column. Currently, can be only TIME. Default is TIME.

dv_col

Character. Name of DV column in data_i. Default is DV

log_y

Logical. If TRUE, a logarithmic scale is applied to y-axis. Default is FALSE.

piLow

Numeric. Lower prediction interval bound. Default is 0.10.

piUp

Numeric. Upper prediction interval bound Default is 0.90.

ciLow

Numeric. Lower confidence interval bound. Default is 0.025

ciUp

Numeric. Upper confidence interval bound. Default is 0.975

pred.corr

Logical. Apply prediction correction. Default is FALSE.

lab_y

String. Y-axis label. Default is "DV".

lab_x

String. X-axis label. Default is "TIME, h".

theor_perc

Logical. Show theoretical percentiles. Default is TRUE.

theor_percCI

Logical. Show CI around theoretical percentiles. Default is TRUE.

emp_perc

Logical. Show empirical percentiles. Default is TRUE

dt_obs_fl

Logical. Show observed data points. Default is FALSE

legend_fl

Logical. Show legend. Default is FALSE.

n_bins

Integer. Number of bins to use in the histogram. Default is 10.

method

Character. Binning method: "kmeans", "equal", "quantile" (default: "kmeans").

interpolation

Logical. Use line interpolation vs rectangles (default: FALSE).

strat_by_dose

Character. Variable name for dose stratification (default: NULL).

Value

List of ggplot objects, one for each output variable

Details

For now, the model in the example is NOT a GMO, as the parameters in generalized fit object are backtransformed, and, therefore, not transformed in the model. This issue will be fixed in the next versions of SimuRg package

Examples

# \donttest{
library(rxode2)
fpath_i <- system.file("extdata", "simurg_object", "Warfarin_PK.RData", package = "SimuRg")
#> Warning: cannot open compressed file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/DESCRIPTION', probable reason 'No such file or directory'
mod <- rxode2::rxode2({
  ka_pop = 0.1;
  Vd_pop = 10;
  Cl_pop = 0.5;

  omega_ka = 0;
  omega_Vd = 0;
  omega_Cl = 0;

  Cc_b = 0;
  ka_tv = exp(log(ka_pop));
  Vd_tv = exp(log(Vd_pop));
  Cl_tv = exp(log(Cl_pop));

  ka = ka_tv * exp(omega_ka);
  Vd = Vd_tv * exp(omega_Vd);
  Cl = Cl_tv * exp(omega_Cl);

  Cc = Ac / Vd;

  Ad(0) = 0;
  Ac(0) = 0;

  d/dt(Ad) = -ka * Ad;
  d/dt(Ac) = ka * Ad - Cl * Cc;

  Cc_ResErr = Cc * (1 + Cc_b);
})
#>  
#>  

sim_data <- sg_vpc_sim(fpath_i, model=mod, outputs = "Cc_ResErr")
#> Warning: restarting interrupted promise evaluation
#> Error: cannot open file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/R/SimuRg.rdb': No such file or directory
outp_nms <- data.frame(dvid = 1, output = "Cc")
vpc_plots <- sg_vpc_vis(
  ds_sim = sim_data,
  data_i = warfarin,
  output_names = outp_nms,
  lab_x = "Time (hours)",
  lab_y = "Concentration (ng/mL)",
  n_bins = 8,
  pred.corr = TRUE
)
#> Error: cannot open file '/tmp/RtmpLedq7K/temp_libpath8b6abff614d/SimuRg/R/SimuRg.rdb': No such file or directory
vpc_plots[[1]]
#> Error: object 'vpc_plots' not found
# }