Skip to contents

plot_vpc_cont() generates a VPC plot using exact time bins and returns a ggplot2 object. Thin wrapper that delegates to df_vpcstats() for computation and an internal builder for plot construction.

Usage

plot_vpc_cont(
  data,
  time_var = "TIME",
  ntime_var = "NTIME",
  pred_var = "PRED",
  sim_dv_var = "SIMDV",
  obs_dv_var = "OBSDV",
  strat_var = NULL,
  pcvpc = FALSE,
  loq = NULL,
  irep_name = "SIM",
  min_bin_count = 0,
  show_rep = TRUE,
  lower_bound = 0,
  mode = c("auto", "rank", "drop"),
  shown = NULL,
  style = NULL,
  pi = c(0.05, 0.95),
  ci = 0.9
)

Arguments

data

Simulated replicate data (e.g. from df_mrgsim_replicate()), or a vpc_stats object from df_vpcstats().

time_var

Column containing the actual time variable in data. Accepts bare names or strings. Default is TIME.

ntime_var

Column containing the nominal time variable in data. Accepts bare names or strings. Default is NTIME.

pred_var

Column containing population predictions in data. Accepts bare names or strings. Default is PRED.

sim_dv_var

Column containing simulated DV in data. Accepts bare names or strings. Default is SIMDV.

obs_dv_var

Column containing observed DV in data. Accepts bare names or strings. Default is OBSDV.

strat_var

Stratification variable. Accepts bare names or strings. Currently, only a single stratifying variable is supported. Facet layout is taken from the style: facet_scales, facet_nrow, and facet_ncol.

pcvpc

logical for prediction correction. Default is FALSE.

loq

Numeric LLOQ, or NULL (default) to use a per-row LLOQ column when data has one. Observations with MDV == 1, missing, or below the LOQ are treated as BLQ; they are not dropped, even with no LOQ source. + Standard VPC (pcvpc = FALSE): BLQ observations rank below all quantifiable values in the observed quantiles; simulated values are not censored. + pcVPC (pcvpc = TRUE): observed and simulated BLQ values are set to missing before prediction correction, so both are censored alike.

The LLOQ line (loq_line role) is drawn at each unique LLOQ on standard VPCs only, since the LLOQ has no meaning on the prediction-corrected scale; hide it with shown = plot_vpc_shown(loq_line = FALSE). The observed points show MDV == 0 rows only.

irep_name

Name of replicate variable in data. Accepts bare names or strings. Default is SIM.

min_bin_count

Minimum number of quantifiable observations (obs_n - obs_n_blq in the summary statistics frame) per exact bin required for inclusion in binned plot layers. BLQ-encoded records (obs_n_blq) do not count toward this threshold. This argument drops small bins from summary statistic plotting but retains the underlying observations as data points.

show_rep

Display number of replicates as a plot caption. Default is TRUE. A caption set in the style is drawn instead, whatever this value.

lower_bound

Lower bound for prediction correction formula.

mode

One of "auto" (default), "rank", or "drop". Controls how BLQ-encoded values are carried through quantile aggregation. In "rank" mode, BLQ rows ranks low at stats::quantile; fully-censored quantiles return -Inf and are masked to NA before plotting. In "drop" mode, BLQ rows are excluded from quantile computation. "auto" resolves to "rank" for std VPC and "drop" for pcVPC, matching the package's historical behavior.

shown

Layer visibility settings created by plot_vpc_shown(). Defaults can be viewed by running plot_vpc_shown() with no arguments.

style

A ggstylekit::style_spec() controlling plot aesthetics. Defaults to style_vpc(); view the defaults by running style_vpc() with no arguments. Customize by passing style = style_vpc(...). Pass the same style to plot_vpc_legend() so the legend matches.

pi

Numeric vector of length 2 specifying prediction interval quantiles. Default is c(0.05, 0.95).

ci

Numeric scalar in (0, 1) for simulation interval (e.g., 0.90 for 90% CI). Default is 0.90.

Value

A pmx_vpc_plot object (a ggplot2 subclass). To access the underlying VPC summary statistics data.frame directly, use df_vpcstats(). Adding facet_wrap() or facet_grid() to the result directly will warn, as stratification must be specified via strat_var at call time.

Examples

model <- model_mread_load(model = "pkmodel")
#> Loading model from cache.
data_sad_pk <- dplyr::filter(data_sad, CMT %in% c(1,2))
simout <- df_mrgsim_replicate(data = data_sad_pk, model = model, replicates = 100,
dv_var = ODV,
carry_out = c("LLOQ", "WTBL", "FOOD"),
recover  = c("USUBJID", "PART"),
irep_name = SIM)

vpc_plot <- plot_vpc_cont(
data = simout,
pcvpc = TRUE,
loq = 1,
pi = c(0.05, 0.95),
ci = 0.90)