Title: | Create Visual Predictive Checks |
---|---|
Description: | Visual predictive checks are a commonly used diagnostic plot in pharmacometrics, showing how certain statistics (percentiles) for observed data compare to those same statistics for data simulated from a model. The package can generate VPCs for continuous, categorical, censored, and (repeated) time-to-event data. |
Authors: | Ron Keizer [aut, cre],
Bill Denney [aut] |
Maintainer: | Ron Keizer <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.2.3 |
Built: | 2025-03-10 02:48:28 UTC |
Source: | https://github.com/ronkeizer/vpc |
Add noise / residual error to data
add_noise(x, ruv = list(proportional = 0, additive = 0, exponential = 0))
add_noise(x, ruv = list(proportional = 0, additive = 0, exponential = 0))
x |
data |
ruv |
list describing the magnitude of errors. List arguments: "proportional", "additive", "exponential". |
library(dplyr) ipred <- c(10, 8, 6, 4, 2, 0) %>% add_noise(ruv = list(proportional = 0.1, additive = 0.2))
library(dplyr) ipred <- c(10, 8, 6, 4, 2, 0) %>% add_noise(ruv = list(proportional = 0.1, additive = 0.2))
Add simulation index number to simulation when not present
add_sim_index_number(sim, id = "id", sim_label = "sim")
add_sim_index_number(sim, id = "id", sim_label = "sim")
sim |
a data.frame containing the simulation data |
id |
character specifying the column name in the data.frame |
sim_label |
label to indicate simulation index (if available) |
Adds stratification to data set
add_stratification(dat, stratify, verbose = FALSE)
add_stratification(dat, stratify, verbose = FALSE)
dat |
An input data.frame or similar object |
stratify |
character vector of stratification variables. Only 1 or 2 stratification variables can be supplied. |
verbose |
verbosity ('TRUE' or 'FALSE') |
Create a vpcdb object, and standardize parameter checking
as_vpcdb(..., type = NULL, facet = NULL, scales = NULL, labeller = NULL)
as_vpcdb(..., type = NULL, facet = NULL, scales = NULL, labeller = NULL)
... |
Extra parameters (not checked) added to the object |
type |
The type of vpc (e.g. "continuous", "categorical", "censored", or "time-to-event") |
facet |
either "wrap", "columns", or "rows" |
scales |
Are scales shared across all facets (the default,
|
labeller |
ggplot2 labeller function to be passed to underlying ggplot object |
A vpcdb object which is simply a named list with some of the values checked for correctness
This function calculates bin separators either using R's native binning approaches available in the classInt library such as 'kmeans', 'jenks', 'pretty' etc. Alternatively, a custom approach is available which is based on finding the nadirs in the density functions for the independent variable. Default approach is k-means clustering.
auto_bin(dat, type = "kmeans", n_bins = 8, verbose = FALSE, ...) ## S3 method for class 'numeric' auto_bin(dat, type = "kmeans", n_bins = 8, verbose = FALSE, ...) ## S3 method for class 'data.frame' auto_bin(dat, type = "kmeans", n_bins = 8, verbose = FALSE, ...)
auto_bin(dat, type = "kmeans", n_bins = 8, verbose = FALSE, ...) ## S3 method for class 'numeric' auto_bin(dat, type = "kmeans", n_bins = 8, verbose = FALSE, ...) ## S3 method for class 'data.frame' auto_bin(dat, type = "kmeans", n_bins = 8, verbose = FALSE, ...)
dat |
data frame |
type |
auto-binning type: "density", "time", or "data" |
n_bins |
number of bins to use; either a positive integer or "auto". For "density" the function might not return a solution with the exact number of bins. |
verbose |
show debugging information (TRUE or FALSE) |
... |
arguments passed on to underlying binning functions |
A vector of bin separators
Function to bin data based on a vector of bin separators, e.g. for use in VPC
bin_data(x, bins = c(0, 3, 5, 7), idv = "time", labeled = F)
bin_data(x, bins = c(0, 3, 5, 7), idv = "time", labeled = F)
x |
data |
bins |
numeric vector specifying bin separators |
idv |
variable in the data specifies the independent variable (e.g. "time") |
labeled |
whether a labeled factor instead of integers should be returned |
Perform prediction-correction
calc_pred_corr_continuous( sim, obs, pred_corr, pred_corr_lower_bnd, cols, verbose )
calc_pred_corr_continuous( sim, obs, pred_corr, pred_corr_lower_bnd, cols, verbose )
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
pred_corr |
perform prediction-correction? |
pred_corr_lower_bnd |
lower bound for the prediction-correction |
cols |
A length 2, named list with one element named "obs" and the other named "sim", each containing a sub-list with elements for mapping columns names in the data to expected column names for use. |
verbose |
show debugging information (TRUE or FALSE) |
A list with "sim" and "obs" (with pred_corr
performed, if
requested)
Calculate aggregate statistics for simulated and observed VPC data
calc_vpc_continuous(sim, obs, loq, pi, ci, stratify, bins, bin_mid, verbose)
calc_vpc_continuous(sim, obs, loq, pi, ci, stratify, bins, bin_mid, verbose)
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
loq |
The list output from |
pi |
simulated prediction interval to plot. Default is c(0.05, 0.95), |
ci |
confidence interval to plot. Default is (0.05, 0.95) |
stratify |
character vector of stratification variables. |
bins |
either "density", "time", or "data", "none", or one of the approaches available in classInterval() such as "jenks" (default) or "pretty", or a numeric vector specifying the bin separators. |
bin_mid |
either "mean" for the mean of all timepoints (default) or "middle" to use the average of the bin boundaries. |
verbose |
show debugging information (TRUE or FALSE) |
A list with "vpc_dat" and "aggr_obs"
Check whether stratification columns are available
check_stratification_columns_available(data, stratify, type = "observation")
check_stratification_columns_available(data, stratify, type = "observation")
data |
'data.frame' with observation or simulation data (or |
stratify |
vector of stratification columns (or |
type |
either 'observation' or 'simulation' |
TRUE
or raise an error about the missing columns
Compute Kaplan-Meier statistics
compute_kaplan( dat, strat = "strat", reverse_prob = FALSE, rtte_conditional = TRUE, ci = NULL )
compute_kaplan( dat, strat = "strat", reverse_prob = FALSE, rtte_conditional = TRUE, ci = NULL )
dat |
data.frame with events |
strat |
vector of stratification variables |
reverse_prob |
reverse the probability (i.e. return '1-probability')? |
rtte_conditional |
'TRUE' (default) or 'FALSE'. Compute the probability for each event newly ('TRUE'), or calculate the absolute probability ('FALSE', i.e. the "probability of a 1st, 2nd, 3rd event etc" rather than the "probability of an event happening"). |
ci |
confidence interval to calculate, numeric vector of length 2 |
Kaplan-Meier Mean Covariate plots are a simulation-based diagnostic to study the influence of covariates and identify potential model misspecification.
compute_kmmc(dat, strat = NULL, reverse_prob = FALSE, kmmc = "DOSE")
compute_kmmc(dat, strat = NULL, reverse_prob = FALSE, kmmc = "DOSE")
dat |
data.frame with events |
strat |
vector of stratification variables |
reverse_prob |
reverse the probability (i.e. return '1-probability')? |
kmmc |
variable to create the KMMC plot for. |
Create new vpc theme
create_vpc_theme(...)
create_vpc_theme(...)
... |
pass arguments to 'new_vpc_theme' |
The vpc theme
Define bins for many types of data
define_bins(obs, sim, bins, n_bins, verbose = FALSE) define_bins_tte(obs, sim, bins, n_bins, kmmc, verbose = FALSE)
define_bins(obs, sim, bins, n_bins, verbose = FALSE) define_bins_tte(obs, sim, bins, n_bins, kmmc, verbose = FALSE)
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
bins |
either "density", "time", or "data", "none", or one of the approaches available in classInterval() such as "jenks" (default) or "pretty", or a numeric vector specifying the bin separators. |
n_bins |
when using the "auto" binning method, what number of bins to aim for |
verbose |
show debugging information (TRUE or FALSE) |
kmmc |
either NULL (for regular TTE vpc, default), or a variable name for a KMMC plot (e.g. "WT") |
A list with named elements: "bins", the bin separator values; "labeled", are the bins labeled?; "obs", binned observed data; "sim", binned simulated data. Additionally, "tmp_bins" is added for tte data.
define_bins_tte()
: Define bins for time-to-event data
Define data column defaults for various softwares
define_data_columns(sim, obs, sim_cols, obs_cols, software_type)
define_data_columns(sim, obs, sim_cols, obs_cols, software_type)
sim |
simulated data |
obs |
observed data |
sim_cols |
list for mapping simulation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
obs_cols |
list for mapping observation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
software_type |
software type, one of 'nonmem', 'phoenix', 'PKPDsim' |
Check and standardize limits of quantification
define_loq( lloq = NULL, uloq = NULL, pred_corr = FALSE, pred_corr_lower_bnd = 0, require_loq )
define_loq( lloq = NULL, uloq = NULL, pred_corr = FALSE, pred_corr_lower_bnd = 0, require_loq )
lloq |
Number or NULL indicating lower limit of quantification. Default is NULL. |
uloq |
Number or NULL indicating upper limit of quantification. Default is NULL. |
pred_corr |
perform prediction-correction? |
pred_corr_lower_bnd |
lower bound for the prediction-correction |
require_loq |
Is at least one of |
A list with elements "lloq", "uloq", "cens_limit", "pred_corr",
"pred_corr_lower_bnd", and "cens_type". "cens_limit" indicates the range
for censoring (c(lloq, uloq)
, NULL
if neither is given),
"cens_type" indicates whether the data are "left" censored (low values are
censored, only), "right" (high values are censored, only), "both" (low and
high values are censored), or "neither" (no values are censored).
Draw parameters from multivariate distribution
draw_params_mvr(ids, n_sim, theta, omega_mat, par_names = NULL)
draw_params_mvr(ids, n_sim, theta, omega_mat, par_names = NULL)
ids |
vector of id numbers |
n_sim |
number of simulations |
theta |
theta vector |
omega_mat |
omega matrix |
par_names |
parameter names vector |
Remove values that are not observed values from data
filter_dv(x, verbose = FALSE, ...)
filter_dv(x, verbose = FALSE, ...)
x |
A data.frame or similar object |
verbose |
show debugging information (TRUE or FALSE) |
... |
Passed to software-specific filtering function |
x
With non-observation rows removed
Prepare VPC data for future calculations by standardizing column names and modifying the input data based on the limits of quantification, stratification, and logarithmic values.
format_vpc_input_data( dat, cols, lloq, uloq, stratify, log_y, log_y_min, what = "observed", verbose = FALSE, pred_corr = FALSE ) format_vpc_input_data_tte( dat, cols, stratify, rtte, rtte_calc_diff, what = "observed", verbose = FALSE )
format_vpc_input_data( dat, cols, lloq, uloq, stratify, log_y, log_y_min, what = "observed", verbose = FALSE, pred_corr = FALSE ) format_vpc_input_data_tte( dat, cols, stratify, rtte, rtte_calc_diff, what = "observed", verbose = FALSE )
dat |
An input data.frame or similar object |
cols |
A list with an element for colname giving the name for colname in
|
lloq |
Number or NULL indicating lower limit of quantification. Default is NULL. |
uloq |
Number or NULL indicating upper limit of quantification. Default is NULL. |
stratify |
character vector of stratification variables. Only 1 or 2 stratification variables can be supplied. |
log_y |
Boolean indicting whether y-axis should be shown as logarithmic. Default is FALSE. |
log_y_min |
minimal value when using log_y argument. Default is 1e-3. |
what |
The description of the data (typically "observed" or "simulated") |
verbose |
show debugging information (TRUE or FALSE) |
pred_corr |
perform prediction-correction? |
rtte |
repeated time-to-event data? Default is FALSE (treat as single-event TTE) |
rtte_calc_diff |
recalculate time (T/F)? When simulating in NONMEM, you will probably need to set this to TRUE to recalculate the TIME to relative times between events (unless you output the time difference between events and specify that as independent variable to the vpc_tte() function. |
dat
modified based on other inputs.
A named list with "dat" modified, as required, and "stratify" with the stratification parameters
format_vpc_input_data_tte()
: Prepare VPC data for future calculations
for time-to-event data
These functions are not to be called directly by users; they are for internal
use. Users should call plot_vpc()
.
ggplot.vpcdb_continuous( data = NULL, mapping = NULL, ..., environment = parent.frame() ) ggplot.vpcdb_categorical( data = NULL, mapping = NULL, ..., environment = parent.frame() ) ggplot.vpcdb_censored( data = NULL, mapping = NULL, ..., environment = parent.frame() ) ggplot.vpcdb_time_to_event( data = NULL, mapping = NULL, ..., environment = parent.frame() )
ggplot.vpcdb_continuous( data = NULL, mapping = NULL, ..., environment = parent.frame() ) ggplot.vpcdb_categorical( data = NULL, mapping = NULL, ..., environment = parent.frame() ) ggplot.vpcdb_censored( data = NULL, mapping = NULL, ..., environment = parent.frame() ) ggplot.vpcdb_time_to_event( data = NULL, mapping = NULL, ..., environment = parent.frame() )
data |
Default dataset to use for plot. If not already a data.frame,
will be converted to one by |
mapping |
Default list of aesthetic mappings to use for plot. If not specified, must be supplied in each layer added to the plot. |
... |
Other arguments passed on to methods. Not currently used. |
environment |
Function copied from ggplot2:::label_variable, with addition of ' Copied here since CRAN does not like use of ':::'.
ggplot2_label_variable(labels, multi_line = TRUE)
ggplot2_label_variable(labels, multi_line = TRUE)
labels |
Data frame of labels. Usually contains only one element, but faceting over multiple factors entails multiple label variables. |
multi_line |
Whether to display the labels of multiple factors on separate lines. |
Slight rewrite of ggplot2::label_both, to make sure that labels for events are ordered appropriately when doing facet_wrap.
label_vpc_tte(labels, multi_line = TRUE, sep = ": ")
label_vpc_tte(labels, multi_line = TRUE, sep = ": ")
labels |
Data frame of labels. Usually contains only one element, but faceting over multiple factors entails multiple label variables. |
multi_line |
Whether to display the labels of multiple factors on separate lines. |
sep |
String separating variables and values. |
Calculate fraction of observations below lloq / above uloq
loq_frac(x, limit = 1, cens = c("left", "right", "neither", "both"))
loq_frac(x, limit = 1, cens = c("left", "right", "neither", "both"))
x |
A numeric vector |
limit |
censoring limit (ignored if |
cens |
censoring direction |
The fraction of observations (NA
is counted as below/above)
Create a customized VPC theme
new_vpc_theme(update = NULL)
new_vpc_theme(update = NULL)
update |
list containing the plot elements to be updated. Run 'new_vpc_theme()' with no arguments to show an overview of available plot elements. |
This function creates a theme that customizes how the VPC looks, i.e. colors, fills, transparencies, linetypes, sizes, etc. The following arguments can be specified in the input list:
obs_color: color for observations points
obs_size: size for observation points
obs_median_color: color for median observation line
obs_median_linetype: linetype for median observation line
obs_median_linewidth: linewidth for median observation line
obs_ci_fill: color for observation CI fill
obs_ci_color: color for observation CI lines
obs_ci_linetype: linetype for observation CI lines
obs_ci_linewidth: linewidth for observations CI lines
sim_pi_fill: fill color for simulated prediction interval areas
sim_pi_alpha: transparency for simulated prediction interval areas
sim_pi_color: color for simulated prediction interval lines
sim_pi_linetype: linetype for simulated prediction interval lines
sim_pi_linewidth: linewidth for simulated prediction interval lines
sim_median_fill: fill color for simulated median area
sim_median_alpha: transparency for simulated median area
sim_median_color: color for simulated median line
sim_median_linetype: linetype for simulated median line
sim_median_linewidth: linewidth for simulated median line
bin_separators_color: color for bin separator lines, NA for don't plot
bin_separators_location: where to plot bin separators ("t" for top, "b" for bottom)
loq_color: color of line showing limit of quantification
A list with vpc theme specifiers
theme1 <- new_vpc_theme(update = list( obs_color = "red", obs_ci_color = "#aa0000", obs_alpha = .3, sim_pi_fill = "#cc8833", sim_pi_linewidth = 2 )) vpc(simple_data$sim, simple_data$obs, vpc_theme = theme1)
theme1 <- new_vpc_theme(update = list( obs_color = "red", obs_ci_color = "#aa0000", obs_alpha = .3, sim_pi_fill = "#cc8833", sim_pi_linewidth = 2 )) vpc(simple_data$sim, simple_data$obs, vpc_theme = theme1)
Simulate PK data from a 1-compartment iv model
pk_iv_1cmt( t, t_inf = 1, tau = 24, dose = 120, CL = 0.345, Vc = 1.75, ruv = NULL )
pk_iv_1cmt( t, t_inf = 1, tau = 24, dose = 120, CL = 0.345, Vc = 1.75, ruv = NULL )
t |
Time after dose |
t_inf |
Infusion length |
tau |
Dosing interval |
dose |
Dose |
CL |
Clearance |
Vc |
Volume of distribution |
ruv |
Residual variability |
A vector of predicted values, with or without added residual variability
dat1 <- vpc:::pk_iv_1cmt(t = c(0:72), tau = 24, dose = 120, CL = 5, Vc = 50) dat2 <- vpc:::pk_iv_1cmt(t = c(0:72), tau = 24, dose = 120, CL = 5, Vc = 50, ruv = list(proportional = 0.1, additive = 0.1))
dat1 <- vpc:::pk_iv_1cmt(t = c(0:72), tau = 24, dose = 120, CL = 5, Vc = 50) dat2 <- vpc:::pk_iv_1cmt(t = c(0:72), tau = 24, dose = 120, CL = 5, Vc = 50, ruv = list(proportional = 0.1, additive = 0.1))
Simulate PK data from a 1-compartment oral model
pk_oral_1cmt(t, tau = 24, dose = 120, ka = 1, ke = 1, cl = 10, ruv = NULL)
pk_oral_1cmt(t, tau = 24, dose = 120, ka = 1, ke = 1, cl = 10, ruv = NULL)
t |
Time after dose |
tau |
Dosing interval |
dose |
Dose |
ka |
Absorption rate |
ke |
Elimination rate |
cl |
Clearance |
ruv |
Residual variability |
A vector of predicted values, with or without added residual variability
dat1 <- vpc:::pk_oral_1cmt(t = c(0:72), tau = 24, dose = 120, ka = 1, ke = 1, cl = 10) dat2 <- vpc:::pk_oral_1cmt(t = c(0:72), tau = 24, dose = 120, ka = 1, ke = 1, cl = 10, ruv = list(proportional = 0.1, additive = 0.1))
dat1 <- vpc:::pk_oral_1cmt(t = c(0:72), tau = 24, dose = 120, ka = 1, ke = 1, cl = 10) dat2 <- vpc:::pk_oral_1cmt(t = c(0:72), tau = 24, dose = 120, ka = 1, ke = 1, cl = 10, ruv = list(proportional = 0.1, additive = 0.1))
This function performs no parsing of data, it just plots the already calculated statistics generated using one of the 'vpc' functions.
plot_vpc( db, show = NULL, vpc_theme = NULL, smooth = TRUE, log_x = FALSE, log_y = FALSE, xlab = NULL, ylab = NULL, title = NULL, verbose = FALSE )
plot_vpc( db, show = NULL, vpc_theme = NULL, smooth = TRUE, log_x = FALSE, log_y = FALSE, xlab = NULL, ylab = NULL, title = NULL, verbose = FALSE )
db |
object created using the 'vpc' function |
show |
what to show in VPC (obs_dv, obs_ci, pi, pi_as_area, pi_ci, obs_median, sim_median, sim_median_ci) |
vpc_theme |
theme to be used in VPC. Expects list of class vpc_theme created with function vpc_theme() |
smooth |
"smooth" the VPC (connect bin midpoints) or show bins as rectangular boxes. Default is TRUE. |
log_x |
Boolean indicting whether x-axis should be shown as logarithmic. Default is FALSE. |
log_y |
Boolean indicting whether y-axis should be shown as logarithmic. Default is FALSE. |
xlab |
label for x axis |
ylab |
label for y axis |
title |
title |
verbose |
show debugging information (TRUE or FALSE) |
## See vpc.ronkeizer.com for more documentation and examples library(vpc) vpc_db <- vpc(sim = simple_data$sim, obs = simple_data$obs, vpcdb = TRUE) plot_vpc(vpc_db, title = "My new vpc", x = "Custom x label")
## See vpc.ronkeizer.com for more documentation and examples library(vpc) vpc_db <- vpc(sim = simple_data$sim, obs = simple_data$obs, vpcdb = TRUE) plot_vpc(vpc_db, title = "My new vpc", x = "Custom x label")
Perform pred-correction for predictions that were non-zero and were not missing observation. The latter can happen e.g. when censored data is set to NA in 'format_vpc_input_data()'.
pred_correction_core(data, pred_col, pred_corr_lower_bnd)
pred_correction_core(data, pred_col, pred_corr_lower_bnd)
data |
dataset, either 'sim' or 'obs' data.frame |
pred_col |
cols$obs$pred |
pred_corr_lower_bnd |
lower bound for the prediction-correction |
data.frame
Calculate quantiles respecting the censored data
quantile_cens( x, probs = 0.5, limit = 1, cens = c("left", "right", "neither", "both") )
quantile_cens( x, probs = 0.5, limit = 1, cens = c("left", "right", "neither", "both") )
x |
numeric vector whose sample quantiles are wanted, or an
object of a class for which a method has been defined (see also
‘details’). |
probs |
numeric vector of probabilities with values in
|
limit |
censoring limit (ignored if |
cens |
censoring direction |
The quantile of x
treating NA
values as censored
Quickly import NONMEM output tables into R.
Function taken from 'modelviz' package by Benjamin Guiastrennec.
When both skip
and header
are NULL
,
read_nmtab
will automatically detect the optimal
settings to import the tables. When more than one files are
provided for a same NONMEM run, they will be combined into
a single data.frame
.
read_table_nm( file = NULL, skip = NULL, header = NULL, rm_duplicates = FALSE, nonmem_tab = TRUE )
read_table_nm( file = NULL, skip = NULL, header = NULL, rm_duplicates = FALSE, nonmem_tab = TRUE )
file |
full file name |
skip |
number of lines to skip before reading data |
header |
logical value indicating whether the file contains the names of the variables as its first line |
rm_duplicates |
logical value indicating whether duplicated columns should be removed |
nonmem_tab |
logical value indicating to the function whether the file is a table or a nonmem additional output file. |
A data.frame
## Not run: data <- read_table_nm(file = '../models/pk/sdtab101') ## End(Not run)
## Not run: data <- read_table_nm(file = '../models/pk/sdtab101') ## End(Not run)
Read in VPC data
read_vpc(sim, obs, psn_folder, software, sim_cols, obs_cols, verbose = FALSE)
read_vpc(sim, obs, psn_folder, software, sim_cols, obs_cols, verbose = FALSE)
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
psn_folder |
instead of specifying "sim" and "obs", specify a PsN-generated VPC-folder |
software |
name of software platform using (e.g. nonmem, phoenix) |
sim_cols |
list for mapping simulation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
obs_cols |
list for mapping observation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
verbose |
show debugging information (TRUE or FALSE) |
A list with names of "sim", "obs", "software", and "cols"
Replace list elements by name
replace_list_elements(list, replacement)
replace_list_elements(list, replacement)
list |
original list |
replacement |
replacement list |
Finds and replaces list elements by name and throws an error if an element is not available in the original list. This is a local duplicate of the PKPDmisc copy for the VPC package to reduce dependency on PKPDmisc at this time.
## Not run: list <- list(ipred = "ipred", dv = "dv", idv = "idv", "pred" = "pred") replacement <- list(dv = "conc", idv = "time") list <- replace_list_elements(list, replacement) ## End(Not run)
## Not run: list <- list(ipred = "ipred", dv = "dv", idv = "idv", "pred" = "pred") replacement <- list(dv = "conc", idv = "time") list <- replace_list_elements(list, replacement) ## End(Not run)
An example dataset with simulated repeated time-to-event data
rtte_obs_nm
rtte_obs_nm
An object of class data.frame
with 573 rows and 6 columns.
An example dataset with simulated repeated time-to-event data (100 simulations)
rtte_sim_nm
rtte_sim_nm
An object of class data.frame
with 2000000 rows and 7 columns.
Defaults for show argument with various endpoint types
show_default
show_default
An object of class list
of length 4.
A small rich dataset
simple_data
simple_data
An object of class list
of length 2.
a list containing the obs and sim data for an example dataset to run a simple vpc.
## Not run: vpc(simple_data$sim, simple_data$obs) ## End(Not run)
## Not run: vpc(simple_data$sim, simple_data$obs) ## End(Not run)
Confirm that a column is in the data, and rename data to prepare that column for later use.
standardize_column(dat, cols, colname, coldesc, what, default)
standardize_column(dat, cols, colname, coldesc, what, default)
dat |
An input data.frame or similar object |
cols |
A list with an element for colname giving the name for colname in
|
colname |
The name of the column (character scalar) |
coldesc |
The description of the column (character scalar) |
what |
The description of the data (typically "observed" or "simulated") |
default |
A default value (scalar or vector) to use if the column is not found. |
If colname
is already named colname
in dat
,
dat
unchanged. If not, check if dat
has that column name
already, and if so, name the existing dat[[colname]]
to
dat[[paste0(colname, ".old")]]
and then rename
cols[[colname]]
to colname
.
Empty ggplot2 theme
theme_empty()
theme_empty()
vpc(simple_data$sim, simple_data$obs) + theme_empty()
vpc(simple_data$sim, simple_data$obs) + theme_empty()
A nicer default theme for ggplot2
theme_plain()
theme_plain()
vpc(simple_data$sim, simple_data$obs) + theme_plain()
vpc(simple_data$sim, simple_data$obs) + theme_plain()
Convert the lower triangle of a covariance matrix to a full matrix object
triangle_to_full(vect)
triangle_to_full(vect)
vect |
the lower triangle of a covariance matrix |
Creates a VPC plot from observed and simulation data
vpc(sim, ...) ## Default S3 method: vpc(sim, ...) vpc_vpc( sim = NULL, obs = NULL, psn_folder = NULL, bins = "jenks", n_bins = "auto", bin_mid = "mean", obs_cols = NULL, sim_cols = NULL, software = "auto", show = NULL, stratify = NULL, pred_corr = FALSE, pred_corr_lower_bnd = 0, pi = c(0.05, 0.95), ci = c(0.05, 0.95), uloq = NULL, lloq = NULL, log_y = FALSE, log_y_min = 0.001, xlab = NULL, ylab = NULL, title = NULL, smooth = TRUE, vpc_theme = NULL, facet = "wrap", scales = "fixed", labeller = NULL, vpcdb = FALSE, verbose = FALSE, ... )
vpc(sim, ...) ## Default S3 method: vpc(sim, ...) vpc_vpc( sim = NULL, obs = NULL, psn_folder = NULL, bins = "jenks", n_bins = "auto", bin_mid = "mean", obs_cols = NULL, sim_cols = NULL, software = "auto", show = NULL, stratify = NULL, pred_corr = FALSE, pred_corr_lower_bnd = 0, pi = c(0.05, 0.95), ci = c(0.05, 0.95), uloq = NULL, lloq = NULL, log_y = FALSE, log_y_min = 0.001, xlab = NULL, ylab = NULL, title = NULL, smooth = TRUE, vpc_theme = NULL, facet = "wrap", scales = "fixed", labeller = NULL, vpcdb = FALSE, verbose = FALSE, ... )
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
... |
Other arguments sent to other methods (like xpose or nlmixr); Note these arguments are not used in the default vpc and are ignored by the default method. |
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
psn_folder |
instead of specifying "sim" and "obs", specify a PsN-generated VPC-folder |
bins |
either "density", "time", or "data", "none", or one of the approaches available in classInterval() such as "jenks" (default) or "pretty", or a numeric vector specifying the bin separators. |
n_bins |
when using the "auto" binning method, what number of bins to aim for |
bin_mid |
either "mean" for the mean of all timepoints (default) or "middle" to use the average of the bin boundaries. |
obs_cols |
list for mapping observation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
sim_cols |
list for mapping simulation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
software |
name of software platform using (e.g. nonmem, phoenix) |
show |
what to show in VPC (obs_dv, obs_ci, pi, pi_as_area, pi_ci, obs_median, sim_median, sim_median_ci) |
stratify |
character vector of stratification variables. Only 1 or 2 stratification variables can be supplied. |
pred_corr |
perform prediction-correction? |
pred_corr_lower_bnd |
lower bound for the prediction-correction |
pi |
simulated prediction interval to plot. Default is c(0.05, 0.95), |
ci |
confidence interval to plot. Default is (0.05, 0.95) |
uloq |
Number or NULL indicating upper limit of quantification. Default is NULL. |
lloq |
Number or NULL indicating lower limit of quantification. Default is NULL. |
log_y |
Boolean indicting whether y-axis should be shown as logarithmic. Default is FALSE. |
log_y_min |
minimal value when using log_y argument. Default is 1e-3. |
xlab |
label for x axis |
ylab |
label for y axis |
title |
title |
smooth |
"smooth" the VPC (connect bin midpoints) or show bins as rectangular boxes. Default is TRUE. |
vpc_theme |
theme to be used in VPC. Expects list of class vpc_theme created with function vpc_theme() |
facet |
either "wrap", "columns", or "rows" |
scales |
Are scales shared across all facets (the default,
|
labeller |
ggplot2 labeller function to be passed to underlying ggplot object |
vpcdb |
Boolean whether to return the underlying vpcdb rather than the plot |
verbose |
show debugging information (TRUE or FALSE) |
a list containing calculated VPC information (when vpcdb=TRUE), or a ggplot2 object (default)
## See vpc.ronkeizer.com for more documentation and examples library(vpc) # Basic commands: vpc(sim = simple_data$sim, obs = simple_data$obs) vpc(sim = simple_data$sim, obs = simple_data$obs, lloq = 20)
## See vpc.ronkeizer.com for more documentation and examples library(vpc) # Basic commands: vpc(sim = simple_data$sim, obs = simple_data$obs) vpc(sim = simple_data$sim, obs = simple_data$obs, lloq = 20)
Creates a VPC plot from observed and simulation data for categorical variables.
vpc_cat( sim = NULL, obs = NULL, psn_folder = NULL, bins = "jenks", n_bins = "auto", bin_mid = "mean", obs_cols = NULL, sim_cols = NULL, software = "auto", show = NULL, ci = c(0.05, 0.95), uloq = NULL, lloq = NULL, xlab = NULL, ylab = NULL, title = NULL, smooth = TRUE, vpc_theme = NULL, facet = "wrap", labeller = NULL, vpcdb = FALSE, verbose = FALSE )
vpc_cat( sim = NULL, obs = NULL, psn_folder = NULL, bins = "jenks", n_bins = "auto", bin_mid = "mean", obs_cols = NULL, sim_cols = NULL, software = "auto", show = NULL, ci = c(0.05, 0.95), uloq = NULL, lloq = NULL, xlab = NULL, ylab = NULL, title = NULL, smooth = TRUE, vpc_theme = NULL, facet = "wrap", labeller = NULL, vpcdb = FALSE, verbose = FALSE )
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
psn_folder |
instead of specifying "sim" and "obs", specify a PsN-generated VPC-folder |
bins |
either "density", "time", or "data", "none", or one of the approaches available in classInterval() such as "jenks" (default) or "pretty", or a numeric vector specifying the bin separators. |
n_bins |
when using the "auto" binning method, what number of bins to aim for |
bin_mid |
either "mean" for the mean of all timepoints (default) or "middle" to use the average of the bin boundaries. |
obs_cols |
list for mapping observation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
sim_cols |
list for mapping simulation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
software |
name of software platform using (e.g. nonmem, phoenix) |
show |
what to show in VPC (obs_dv, obs_ci, pi, pi_as_area, pi_ci, obs_median, sim_median, sim_median_ci) |
ci |
confidence interval to plot. Default is (0.05, 0.95) |
uloq |
Number or NULL indicating upper limit of quantification. Default is NULL. |
lloq |
Number or NULL indicating lower limit of quantification. Default is NULL. |
xlab |
label for x axis |
ylab |
label for y axis |
title |
title |
smooth |
"smooth" the VPC (connect bin midpoints) or show bins as rectangular boxes. Default is TRUE. |
vpc_theme |
theme to be used in VPC. Expects list of class vpc_theme created with function vpc_theme() |
facet |
either "wrap", "columns", or "rows" |
labeller |
ggplot2 labeller function to be passed to underlying ggplot object |
vpcdb |
boolean whether to return the underlying vpcdb rather than the plot |
verbose |
show debugging information (TRUE or FALSE) |
a list containing calculated VPC information (when vpcdb=TRUE), or a ggplot2 object (default)
## See vpc.ronkeizer.com for more documentation and examples library(vpc) # simple function to simulate categorical data for single individual sim_id <- function(id = 1) { n <- 10 logit <- function(x) exp(x) / (1+exp(x)) data.frame(id = id, time = seq(1, n, length.out = n), dv = round(logit((1:n) - n/2 + rnorm(n, 0, 1.5))) ) } ## simple function to simulate categorical data for a trial sim_trial <- function(i = 1, n = 20) { # function to simulate categorical data for a trial data.frame(sim = i, do.call("rbind", lapply(1:n, sim_id))) } ## simulate single trial for 20 individuals obs <- sim_trial(n = 20) ## simulate 200 trials of 20 individuals sim <- do.call("rbind", lapply(1:200, sim_trial, n = 20)) ## Plot categorical VPC vpc_cat(sim = sim, obs = obs)
## See vpc.ronkeizer.com for more documentation and examples library(vpc) # simple function to simulate categorical data for single individual sim_id <- function(id = 1) { n <- 10 logit <- function(x) exp(x) / (1+exp(x)) data.frame(id = id, time = seq(1, n, length.out = n), dv = round(logit((1:n) - n/2 + rnorm(n, 0, 1.5))) ) } ## simple function to simulate categorical data for a trial sim_trial <- function(i = 1, n = 20) { # function to simulate categorical data for a trial data.frame(sim = i, do.call("rbind", lapply(1:n, sim_id))) } ## simulate single trial for 20 individuals obs <- sim_trial(n = 20) ## simulate 200 trials of 20 individuals sim <- do.call("rbind", lapply(1:200, sim_trial, n = 20)) ## Plot categorical VPC vpc_cat(sim = sim, obs = obs)
Creates a VPC plot from observed and simulation data for censored data. Function can handle both left- (below lower limit of quantification) and right-censored (above upper limit of quantification) data.
vpc_cens( sim = NULL, obs = NULL, psn_folder = NULL, bins = "jenks", n_bins = 8, bin_mid = "mean", obs_cols = NULL, sim_cols = NULL, software = "auto", show = NULL, stratify = NULL, stratify_color = NULL, ci = c(0.05, 0.95), uloq = NULL, lloq = NULL, xlab = "Time", ylab = "Probability of <LOQ", title = NULL, smooth = TRUE, vpc_theme = NULL, facet = "wrap", labeller = NULL, vpcdb = FALSE, verbose = FALSE )
vpc_cens( sim = NULL, obs = NULL, psn_folder = NULL, bins = "jenks", n_bins = 8, bin_mid = "mean", obs_cols = NULL, sim_cols = NULL, software = "auto", show = NULL, stratify = NULL, stratify_color = NULL, ci = c(0.05, 0.95), uloq = NULL, lloq = NULL, xlab = "Time", ylab = "Probability of <LOQ", title = NULL, smooth = TRUE, vpc_theme = NULL, facet = "wrap", labeller = NULL, vpcdb = FALSE, verbose = FALSE )
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
psn_folder |
instead of specifying "sim" and "obs", specify a PsN-generated VPC-folder |
bins |
either "density", "time", or "data", "none", or one of the approaches available in classInterval() such as "jenks" (default) or "pretty", or a numeric vector specifying the bin separators. |
n_bins |
when using the "auto" binning method, what number of bins to aim for |
bin_mid |
either "mean" for the mean of all timepoints (default) or "middle" to use the average of the bin boundaries. |
obs_cols |
list for mapping observation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
sim_cols |
list for mapping simulation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
software |
name of software platform using (e.g. nonmem, phoenix) |
show |
what to show in VPC (obs_dv, obs_ci, pi, pi_as_area, pi_ci, obs_median, sim_median, sim_median_ci) |
stratify |
character vector of stratification variables. Only 1 or 2 stratification variables can be supplied. |
stratify_color |
variable to stratify and color lines for observed data. Only 1 stratification variables can be supplied. |
ci |
confidence interval to plot. Default is (0.05, 0.95) |
uloq |
Number or NULL indicating upper limit of quantification. Default is NULL. |
lloq |
Number or NULL indicating lower limit of quantification. Default is NULL. |
xlab |
label for x axis |
ylab |
label for y axis |
title |
title |
smooth |
"smooth" the VPC (connect bin midpoints) or show bins as rectangular boxes. Default is TRUE. |
vpc_theme |
theme to be used in VPC. Expects list of class vpc_theme created with function vpc_theme() |
facet |
either "wrap", "columns", or "rows" |
labeller |
ggplot2 labeller function to be passed to underlying ggplot object |
vpcdb |
boolean whether to return the underlying vpcdb rather than the plot |
verbose |
show debugging information (TRUE or FALSE) |
a list containing calculated VPC information (when vpcdb=TRUE), or a ggplot2 object (default)
## See vpc.ronkeizer.com for more documentation and examples library(vpc) vpc_cens(sim = simple_data$sim, obs = simple_data$obs, lloq = 30) vpc_cens(sim = simple_data$sim, obs = simple_data$obs, uloq = 120)
## See vpc.ronkeizer.com for more documentation and examples library(vpc) vpc_cens(sim = simple_data$sim, obs = simple_data$obs, lloq = 30) vpc_cens(sim = simple_data$sim, obs = simple_data$obs, uloq = 120)
A collection of internal ggplot helpers for VPC plotting
geom_bin_sep(bins, show, vpc_theme) geom_hline_loq(data, vpc_theme) geom_obs_cens_dat_tte(data) geom_obs_ci_continuous(data, show, vpc_theme) geom_obs_ci_tte(data, show, vpc_theme) geom_obs_dv_continuous(data, show, vpc_theme) geom_obs_km(data) geom_obs_median_continuous(data, show, vpc_theme) geom_sim_km(data, show) geom_sim_median_continuous(data, show, vpc_theme) geom_sim_median_tte(data, show, smooth) geom_sim_median_ci_continuous(data, show, smooth, vpc_theme) geom_sim_pi_as_area_continuous(data, show, smooth, vpc_theme) geom_sim_pi_as_area_tte(data, show, smooth, vpc_theme) geom_sim_pi_continuous(data, show, vpc_theme) geom_sim_pi_ci_continuous(data, show, smooth, vpc_theme, what = c("q5", "q95")) facet_continuous(data) facet_tte(data) guides_stratify_color(data) scale_x_log10_vpc(data, show) scale_y_log10_vpc(show)
geom_bin_sep(bins, show, vpc_theme) geom_hline_loq(data, vpc_theme) geom_obs_cens_dat_tte(data) geom_obs_ci_continuous(data, show, vpc_theme) geom_obs_ci_tte(data, show, vpc_theme) geom_obs_dv_continuous(data, show, vpc_theme) geom_obs_km(data) geom_obs_median_continuous(data, show, vpc_theme) geom_sim_km(data, show) geom_sim_median_continuous(data, show, vpc_theme) geom_sim_median_tte(data, show, smooth) geom_sim_median_ci_continuous(data, show, smooth, vpc_theme) geom_sim_pi_as_area_continuous(data, show, smooth, vpc_theme) geom_sim_pi_as_area_tte(data, show, smooth, vpc_theme) geom_sim_pi_continuous(data, show, vpc_theme) geom_sim_pi_ci_continuous(data, show, smooth, vpc_theme, what = c("q5", "q95")) facet_continuous(data) facet_tte(data) guides_stratify_color(data) scale_x_log10_vpc(data, show) scale_y_log10_vpc(show)
bins |
Numeric vector of bin separators (if logical value, geom_blank is returned) |
show |
Should the geom be shown? (TRUE/FALSE) |
vpc_theme |
The theme to use |
data |
The vpcdb object |
smooth |
"smooth" the VPC (connect bin midpoints) or show bins as rectangular boxes. Default is TRUE. |
what |
Which interval should be shown (low = "q5" or high = "q95") |
geom_bin_sep()
: Show rug plot of bin separators
geom_hline_loq()
: Generate hlines for the lloq/uloq
geom_obs_cens_dat_tte()
: Show the cens_dat for time-to-events
geom_obs_ci_continuous()
: Show confidence interval for observed, continuous data
geom_obs_ci_tte()
: Show confidence interval for observed, time-to-event
data
geom_obs_dv_continuous()
: Show observed data points
geom_obs_km()
: Show observed Kaplan-Meier line
geom_obs_median_continuous()
: Show observed median line for continuous data
geom_sim_km()
: Show simulated Kaplan-Meier curves for time-to-event
data
geom_sim_median_continuous()
: Show simulated median line for continuous data
geom_sim_median_tte()
: Show simulated median line (or steps) for
time-to-event data
geom_sim_median_ci_continuous()
: Show simulated median confidence interval for
continuous data
geom_sim_pi_as_area_continuous()
: Show simulated prediction interval area for continuous
data
geom_sim_pi_as_area_tte()
: Show simulated prediction interval area for
time-to-event data
geom_sim_pi_continuous()
: Show simulated prediction interval lines for
continuous data
geom_sim_pi_ci_continuous()
: Show simulated prediction interval confidence interval
areas for continuous data
facet_continuous()
: Facet continuous data by stratification factors
facet_tte()
: Facet time-to-event data by stratification factors
guides_stratify_color()
: Generate guides for stratification fill and colour
scale_x_log10_vpc()
: Optionally show log-x scale
scale_y_log10_vpc()
: Optionally show log-y scale
This function can be used for either single time-to-event (TTE) or repeated time-to-event (RTTE) data.
vpc_tte( sim = NULL, obs = NULL, psn_folder = NULL, rtte = FALSE, rtte_calc_diff = TRUE, rtte_conditional = TRUE, events = NULL, bins = FALSE, n_bins = 10, software = "auto", obs_cols = NULL, sim_cols = NULL, kmmc = NULL, reverse_prob = FALSE, stratify = NULL, stratify_color = NULL, ci = c(0.05, 0.95), xlab = "Time", ylab = "Survival (%)", show = NULL, as_percentage = TRUE, title = NULL, smooth = FALSE, vpc_theme = NULL, facet = "wrap", labeller = NULL, verbose = FALSE, vpcdb = FALSE )
vpc_tte( sim = NULL, obs = NULL, psn_folder = NULL, rtte = FALSE, rtte_calc_diff = TRUE, rtte_conditional = TRUE, events = NULL, bins = FALSE, n_bins = 10, software = "auto", obs_cols = NULL, sim_cols = NULL, kmmc = NULL, reverse_prob = FALSE, stratify = NULL, stratify_color = NULL, ci = c(0.05, 0.95), xlab = "Time", ylab = "Survival (%)", show = NULL, as_percentage = TRUE, title = NULL, smooth = FALSE, vpc_theme = NULL, facet = "wrap", labeller = NULL, verbose = FALSE, vpcdb = FALSE )
sim |
this is usually a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm. However it can also be an object like a nlmixr or xpose object |
obs |
a data.frame with observed data, containing the independent and dependent variable, a column indicating the individual, and possibly covariates. E.g. load in from NONMEM using read_table_nm |
psn_folder |
instead of specifying "sim" and "obs", specify a PsN-generated VPC-folder |
rtte |
repeated time-to-event data? Default is FALSE (treat as single-event TTE) |
rtte_calc_diff |
recalculate time (T/F)? When simulating in NONMEM, you will probably need to set this to TRUE to recalculate the TIME to relative times between events (unless you output the time difference between events and specify that as independent variable to the vpc_tte() function. |
rtte_conditional |
'TRUE' (default) or 'FALSE'. Compute the probability for each event newly ('TRUE'), or calculate the absolute probability ('FALSE', i.e. the "probability of a 1st, 2nd, 3rd event etc" rather than the "probability of an event happening"). |
events |
numeric vector describing which events to show a VPC for when repeated TTE data, e.g. c(1:4). Default is NULL, which shows all events. |
bins |
either "density", "time", or "data", "none", or one of the approaches available in classInterval() such as "jenks" (default) or "pretty", or a numeric vector specifying the bin separators. |
n_bins |
when using the "auto" binning method, what number of bins to aim for |
software |
name of software platform using (e.g. nonmem, phoenix) |
obs_cols |
list for mapping observation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
sim_cols |
list for mapping simulation data columns, e.g. 'list(dv = "DV", id = "ID", idv = "TIME", pred="PRED")' |
kmmc |
either NULL (for regular TTE vpc, default), or a variable name for a KMMC plot (e.g. "WT") |
reverse_prob |
reverse the probability scale (i.e. plot 1-probability) |
stratify |
character vector of stratification variables. Only 1 or 2 stratification variables can be supplied. |
stratify_color |
character vector of stratification variables. Only 1 stratification variable can be supplied, cannot be used in conjunction with 'stratify'. |
ci |
confidence interval to plot. Default is (0.05, 0.95) |
xlab |
label for x axis |
ylab |
label for y axis |
show |
what to show in VPC (obs_dv, obs_ci, pi, pi_as_area, pi_ci, obs_median, sim_median, sim_median_ci) |
as_percentage |
Show y-scale from 0-100 percent? TRUE by default, if FALSE then scale from 0-1. |
title |
title |
smooth |
"smooth" the VPC (connect bin midpoints) or show bins as rectangular boxes. Default is TRUE. |
vpc_theme |
theme to be used in VPC. Expects list of class vpc_theme created with function vpc_theme() |
facet |
either "wrap", "columns", or "rows" |
labeller |
ggplot2 labeller function to be passed to underlying ggplot object |
verbose |
show debugging information (TRUE or FALSE) |
vpcdb |
Boolean whether to return the underlying vpcdb rather than the plot |
Creates a VPC plot from observed and simulation survival data
a list containing calculated VPC information (when vpcdb=TRUE), or a ggplot2 object (default)
## See vpc-docs.ronkeizer.com for more documentation and examples. ## Example for repeated) time-to-event data ## with NONMEM-like data (e.g. simulated using a dense grid) data(rtte_obs_nm) data(rtte_sim_nm) # treat RTTE as TTE, no stratification vpc_tte(sim = rtte_sim_nm[rtte_sim_nm$sim <= 20,], obs = rtte_obs_nm, rtte = FALSE, sim_cols=list(dv = "dv", idv = "t"), obs_cols=list(idv = "t"))
## See vpc-docs.ronkeizer.com for more documentation and examples. ## Example for repeated) time-to-event data ## with NONMEM-like data (e.g. simulated using a dense grid) data(rtte_obs_nm) data(rtte_sim_nm) # treat RTTE as TTE, no stratification vpc_tte(sim = rtte_sim_nm[rtte_sim_nm$sim <= 20,], obs = rtte_obs_nm, rtte = FALSE, sim_cols=list(dv = "dv", idv = "t"), obs_cols=list(idv = "t"))