
Plot a visual predictive check (VPC) with exact time bins
Source:R/plot_vpc_exactbins.R
plot_vpc_exactbins.Rdplot_vpc_exactbins() is a wrapper function for vpc::vpc()
that returns a ggplot2 object.
Usage
plot_vpc_exactbins(
sim,
pcvpc = FALSE,
time_vars = c(TIME = "TIME", NTIME = "NTIME"),
output_vars = c(PRED = "PRED", IPRED = "IPRED", SIMDV = "SIMDV", OBSDV = "OBSDV"),
loq = NULL,
strat_var = NULL,
irep_name = "SIM",
min_bin_count = 1,
show_rep = TRUE,
lower_bound = 0,
shown = NULL,
theme = NULL,
timeu = "hours",
n_breaks = 8,
...
)Arguments
- sim
Input dataset. Must contain the following variables:
"ID","TIME"- pcvpc
logical for prediction correction. Default is
FALSE.- time_vars
Names of actual and nominal time variables. Must be named character vector. Defaults is: c(
TIME="TIME",NTIME="NTIME").- output_vars
Names of model outputs from
model. Must be named character vector. Defaults is: c(PRED="PRED",IPRED="IPRED",DV="DV").- loq
Numeric value of the lower limit of quantification (LLOQ) for the assay. Passed to
lloqargument ofvpc::vpc(). Specifying this argument implies thatOBSDVis missing insimwhere < LLOQ.- strat_var
Character string of stratification variable passed to
stratifyargument ofvpc::vpc(). Currently, only a single stratifying variable is supported.- irep_name
Name of replicate variable in
data. Must be a string. Default is"SIM".- min_bin_count
Minimum number of quantifiable observations in exact bin for inclusion in binned plot layers. This argument drops small bins from summary statistic calculation but retains these observations in the observed data points.
- show_rep
Display number of replicates as a plot caption. Default is
TRUE.- lower_bound
Lower bound of the dependent variable for prediction correction. Default is
0.- shown
Named list of logicals specifying which layers to include on the plot. Passed to
showargument ofvpc::vpc().Defaults are:
Observed points:
obs_dv= TRUE.Observed quantiles:
obs_ci= TRUESimulated inter-quantile range:
pi= FALSESimulated inter-quantile area:
pi_as_area= FALSESimulated Quantile CI:
pi_ci= TRUEObserved Median:
obs_median= TRUESimulated Median:
sim_median= FALSESimulated Median CI:
sim_median_ci= TRUE
- theme
Named list of aesthetic parameters for the plot.Passed to
vpc_themearumgent ofvpc::vpc(). Defaults can be obtained by runningvpc::new_vpc_theme()with no arguments.- timeu
Character string specifying units for the time variable. Passed to
breaks_timeand assigned to default x-axis label. Options include:"hours" (default)
"days"
"weeks"
"months"
- n_breaks
Number of breaks requested for x-axis. Default is 5.
- ...
Other arguments passed to
vpc::vpc().
Examples
model <- model_mread_load(model = "model")
#> Loading model from cache.
simout <- df_mrgsim_replicate(data = data_sad, model = model, replicates = 100,
dv_var = "ODV",
num_vars = c("CMT", "EVID", "MDV", "NTIME", "LLOQ", "WTBL", "FOOD"),
char_vars = c("USUBJID", "PART"),
irep_name = "SIM")
vpc_plot <- plot_vpc_exactbins(
sim = simout,
pcvpc = TRUE,
pi = c(0.05, 0.95),
ci = c(0.05, 0.95),
loq = 1)
#> Joining with `by = join_by(NTIME, CMT)`
#> Joining with `by = join_by(NTIME, CMT)`
#> Prediction-correction cannot be used together with censored data (<LLOQ or >ULOQ). VPC plot will be shown for non-censored data only!
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` instead.
#> ℹ The deprecated feature was likely used in the vpc package.
#> Please report the issue to the authors.