Title: | Generic PK/PD Simulation Platform CAMPSIS |
---|---|
Description: | A generic, easy-to-use and intuitive pharmacokinetic/pharmacodynamic (PK/PD) simulation platform based on R packages 'rxode2' and 'mrgsolve'. CAMPSIS provides an abstraction layer over the underlying processes of writing a PK/PD model, assembling a custom dataset and running a simulation. CAMPSIS has a strong dependency to the R package 'campsismod', which allows to read/write a model from/to files and adapt it further on the fly in the R environment. Package 'campsis' allows the user to assemble a dataset in an intuitive manner. Once the user’s dataset is ready, the package is in charge of preparing the simulation, calling 'rxode2' or 'mrgsolve' (at the user's choice) and returning the results, for the given model, dataset and desired simulation settings. |
Authors: | Nicolas Luyckx [aut, cre] |
Maintainer: | Nicolas Luyckx <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.5.4 |
Built: | 2024-10-29 05:36:39 UTC |
Source: | https://github.com/calvagone/campsis |
Apply compartment characteristics from model. In practice, only compartment infusion duration needs to be applied.
applyCompartmentCharacteristics(table, properties)
applyCompartmentCharacteristics(table, properties)
table |
current dataset |
properties |
compartment properties from model |
updated dataset
Create a treatment arm.
Arm(id = as.integer(NA), subjects = 1, label = as.character(NA))
Arm(id = as.integer(NA), subjects = 1, label = as.character(NA))
id |
unique identifier for this arm (available trough dataset), integer. If NA (default), this identifier is auto-incremented. |
subjects |
number of subjects in arm, integer |
label |
arm label, single character string. If set, this label will be output in the ARM column of CAMPSIS instead of the identifier. |
an arm
Arm class.
id
arm unique ID, integer
subjects
number of subjects in arm, integer
label
arm label, single character string
protocol
protocol
covariates
covariates
bootstrap
covariates to be bootstrapped
Binomial distribution.
BinomialDistribution(trials, prob)
BinomialDistribution(trials, prob)
trials |
number of Bernoulli trials per observation (=subject), integer |
prob |
probability of success for each trial |
a binomial distribution
Create one or several bolus(es).
Bolus( time, amount, compartment = NA, f = NULL, lag = NULL, ii = NULL, addl = NULL )
Bolus( time, amount, compartment = NA, f = NULL, lag = NULL, ii = NULL, addl = NULL )
time |
treatment time(s), numeric value or vector. First treatment time if used together with ii and addl. |
amount |
amount to give as bolus, single numeric value |
compartment |
compartment index, single integer value |
f |
fraction of dose amount, distribution |
lag |
dose lag time, distribution |
ii |
interdose interval, requires argument 'time' to be a single numeric value |
addl |
number of additional doses, requires argument 'time' to be a single integer value |
a single bolus or a list of boluses
Create a bootstrap object.
Bootstrap( data, id = "BS_ID", replacement = FALSE, random = FALSE, export_id = FALSE )
Bootstrap( data, id = "BS_ID", replacement = FALSE, random = FALSE, export_id = FALSE )
data |
data frame to be bootstrapped. It must have a unique identifier column named according to the specified argument 'id' (default value is 'BS_ID'). Other columns are covariates to bootstrap. They must all be numeric. Whatever the configuration of the bootstrap, these covariates are always read row by row and belong to a same individual. |
id |
unique identifier column name in data |
replacement |
values can be reused or not when drawn, logical |
random |
values are drawn randomly, logical |
export_id |
tell CAMPSIS if the identifier 'BS_ID' must be output or not, logical |
a bootstrap object
Bootstrap distribution class.
data
values to draw, numeric vector
replacement
values can be reused or not, logical
random
values are drawn randomly, logical
Bootstrap class.
data
data frame to be bootstrapped. Column 'BS_ID' is mandatory and corresponds to the original row ID from the bootstrap. It must be numeric and unique. Other columns are covariates to be bootstrapped (row by row).
replacement
values can be reused or not, logical
random
values are drawn randomly, logical
export_id
tell CAMPSIS if 'BS_ID' must be exported into the dataset, logical
Create a bootstrap distribution. During function sampling, CAMPSIS will generate values depending on the given data and arguments.
BootstrapDistribution(data, replacement = FALSE, random = FALSE)
BootstrapDistribution(data, replacement = FALSE, random = FALSE)
data |
values to draw, numeric vector |
replacement |
values can be reused or not, logical |
random |
values are drawn randomly, logical |
a bootstrap distribution
Suggested Campsis handler for showing the progress bar.
campsis_handler()
campsis_handler()
a progressr handler list
Constant distribution class.
value
covariate value, single numeric value
Create a constant distribution. Its value will be constant across all generated samples.
ConstantDistribution(value)
ConstantDistribution(value)
value |
covariate value, single numeric value |
a constant distribution (same value for all samples)
Convert numeric time vector based on the provided units.
convertTime(x, from, to)
convertTime(x, from, to)
x |
numeric time vector |
from |
unit of x, single character value |
to |
destination unit, single character value |
numeric vector with the converted times
Create a non time-varying (fixed) covariate.
Covariate(name, distribution)
Covariate(name, distribution)
name |
covariate name, single character value |
distribution |
covariate distribution |
a fixed covariate
Covariate class.
name
covariate name, single character value
distribution
covariate distribution
Create a dataset.
Dataset(subjects = NULL, label = as.character(NA))
Dataset(subjects = NULL, label = as.character(NA))
subjects |
number of subjects in the default arm |
label |
label of the default arm, NA by default |
a dataset
Dataset configuration class.
def_depot_cmt
default depot compartment, integer
def_obs_cmt
default observation compartment, integer
export_tsld
export column TSLD, logical
export_tdos
export column TDOS, logical
time_unit_dataset
unit of time in dataset, character ('hour' by default)
time_unit_export
unit of time in export, character ('hour' by default)
Dataset class.
arms
a list of treatment arms
config
dataset configuration for export
iiv
data frame containing the inter-individual variability (all ETAS) for the export
Create a dataset configuration. This configuration allows CAMPSIS to know which are the default depot and observed compartments.
DatasetConfig( defDepotCmt = 1, defObsCmt = 1, exportTSLD = FALSE, exportTDOS = FALSE, timeUnitDataset = "hour", timeUnitExport = "hour" )
DatasetConfig( defDepotCmt = 1, defObsCmt = 1, exportTSLD = FALSE, exportTDOS = FALSE, timeUnitDataset = "hour", timeUnitExport = "hour" )
defDepotCmt |
default depot compartment, integer |
defObsCmt |
default observation compartment, integer |
exportTSLD |
export column TSLD (time since last dose), logical |
exportTDOS |
export column TDOS (time of last dose), logical |
timeUnitDataset |
unit of time in dataset, character ('hour' by default) |
timeUnitExport |
unit of time in export, character ('hour' by default) |
a dataset configuration
Convert days to hours.
days(x)
days(x)
x |
numeric vector in days |
numeric vector in hours
Create declare settings.
Declare(variables = character(0))
Declare(variables = character(0))
variables |
uninitialized variables to be declared, only needed with mrgsolve |
Declare settings
Declare settings class.
variables
uninitialized variables to be declared, only needed with mrgsolve
Discrete distribution.
DiscreteDistribution(x, prob, replace = TRUE)
DiscreteDistribution(x, prob, replace = TRUE)
x |
vector of one or more integers from which to choose |
prob |
a vector of probability weights for obtaining the elements of the vector being sampled |
replace |
should sampling be with replacement, default is TRUE |
a discrete distribution
Distribution class. See this class as an interface.
Dose adaptation class.
formula
formula to apply, single character string, e.g. "AMT*WT"
compartments
compartment numbers where the formula needs to be applied
Create a dose adaptation.
DoseAdaptation(formula, compartments = integer(0))
DoseAdaptation(formula, compartments = integer(0))
formula |
formula to apply, single character string, e.g. "AMT*WT" |
compartments |
compartment numbers where the formula needs to be applied, integer vector. Default is integer(0) (formula applied on all compartments) |
a fixed covariate
Filter CAMPSIS output on dosing rows.
dosingOnly(x)
dosingOnly(x)
x |
data frame, CAMPSIS output |
a data frame with the dosing rows
Create an ETA distribution. The resulting distribution is a normal distribution, with mean=0 and sd=sqrt(OMEGA).
EtaDistribution(model, omega)
EtaDistribution(model, omega)
model |
model |
omega |
corresponding THETA name, character |
an ETA distribution
Create an interruption event.
Event(name = NULL, times, fun, debug = FALSE)
Event(name = NULL, times, fun, debug = FALSE)
name |
event name, character value |
times |
interruption times, numeric vector |
fun |
event function to apply at each interruption |
debug |
output the variables that were changed through this event |
an event definition
Event class.
name
event name, character value
times
interruption times, numeric vector
fun
event function to apply at each interruption
debug
output the variables that were changed through this event
Create an event covariate. These covariates can be modified further in interruption events.
EventCovariate(name, distribution)
EventCovariate(name, distribution)
name |
covariate name, character |
distribution |
covariate distribution at time 0 |
a time-varying covariate
Create a list of interruption events.
Events()
Events()
a events object
Fixed distribution class.
values
covariate values, numeric vector (1 value per sample)
Create a fixed distribution. Each sample will be assigned a fixed value coming from vector 'values'.
FixedDistribution(values)
FixedDistribution(values)
values |
covariate values, numeric vector (1 value per sample) |
a fixed distribution (1 value per sample)
Function distribution class.
fun
function name, character (e.g. 'rnorm')
args
list of arguments (e.g list(mean=70, sd=10))
Create a function distribution. During distribution sampling, the provided function will be responsible for generating values for each sample. If first argument of this function is not the size (n), please tell which argument corresponds to the size 'n' (e.g. list(size="n")).
FunctionDistribution(fun, args)
FunctionDistribution(fun, args)
fun |
function name, character (e.g. 'rnorm') |
args |
list of arguments (e.g list(mean=70, sd=10)) |
a function distribution
Generate IIV matrix for the given Campsis model.
generateIIV(model, n, offset = 0)
generateIIV(model, n, offset = 0)
model |
Campsis model |
n |
number of subjects |
offset |
if specified, resulting ID will be ID + offset |
IIV data frame with ID column
Generate IIV matrix for the given OMEGA matrix.
generateIIV_(omega, n)
generateIIV_(omega, n)
omega |
omega matrix |
n |
number of subjects |
IIV data frame
Return the list of available time units.
getAvailableTimeUnits()
getAvailableTimeUnits()
character vector
Get all covariates (fixed / time-varying / event covariates).
getCovariates(object) ## S4 method for signature 'covariates' getCovariates(object) ## S4 method for signature 'arm' getCovariates(object) ## S4 method for signature 'arms' getCovariates(object) ## S4 method for signature 'dataset' getCovariates(object)
getCovariates(object) ## S4 method for signature 'covariates' getCovariates(object) ## S4 method for signature 'arm' getCovariates(object) ## S4 method for signature 'arms' getCovariates(object) ## S4 method for signature 'dataset' getCovariates(object)
object |
any object |
all covariates from object
Get all event-related covariates.
getEventCovariates(object) ## S4 method for signature 'covariates' getEventCovariates(object) ## S4 method for signature 'arm' getEventCovariates(object) ## S4 method for signature 'arms' getEventCovariates(object) ## S4 method for signature 'dataset' getEventCovariates(object)
getEventCovariates(object) ## S4 method for signature 'covariates' getEventCovariates(object) ## S4 method for signature 'arm' getEventCovariates(object) ## S4 method for signature 'arms' getEventCovariates(object) ## S4 method for signature 'dataset' getEventCovariates(object)
object |
any object |
all event-related covariates from object
Get all fixed covariates.
getFixedCovariates(object) ## S4 method for signature 'covariates' getFixedCovariates(object) ## S4 method for signature 'arm' getFixedCovariates(object) ## S4 method for signature 'arms' getFixedCovariates(object) ## S4 method for signature 'dataset' getFixedCovariates(object)
getFixedCovariates(object) ## S4 method for signature 'covariates' getFixedCovariates(object) ## S4 method for signature 'arm' getFixedCovariates(object) ## S4 method for signature 'arms' getFixedCovariates(object) ## S4 method for signature 'dataset' getFixedCovariates(object)
object |
any object |
all fixed covariates from object
Get all IOV objects.
getIOVs(object) ## S4 method for signature 'arm' getIOVs(object) ## S4 method for signature 'arms' getIOVs(object) ## S4 method for signature 'dataset' getIOVs(object)
getIOVs(object) ## S4 method for signature 'arm' getIOVs(object) ## S4 method for signature 'arms' getIOVs(object) ## S4 method for signature 'dataset' getIOVs(object)
object |
any object |
all IOV's from object
Get all occasions.
getOccasions(object) ## S4 method for signature 'arm' getOccasions(object) ## S4 method for signature 'arms' getOccasions(object) ## S4 method for signature 'dataset' getOccasions(object)
getOccasions(object) ## S4 method for signature 'arm' getOccasions(object) ## S4 method for signature 'arms' getOccasions(object) ## S4 method for signature 'dataset' getOccasions(object)
object |
any object |
all occasions from object
Get seed for dataset export.
getSeedForDatasetExport(seed, progress)
getSeedForDatasetExport(seed, progress)
seed |
original seed |
progress |
simulation progress |
the seed value used to export the dataset
Get seed for iteration.
getSeedForIteration(seed, progress)
getSeedForIteration(seed, progress)
seed |
original seed |
progress |
simulation progress |
the seed value to be used for the given replicate number and iteration
Get seed for parameter uncertainty sampling.
getSeedForParametersSampling(seed)
getSeedForParametersSampling(seed)
seed |
original seed |
the seed value used to sample parameter uncertainty
Get splitting configuration for parallel export.
getSplittingConfiguration(dataset, hardware)
getSplittingConfiguration(dataset, hardware)
dataset |
Campsis dataset to export |
hardware |
hardware configuration |
splitting configuration list (if 'parallel_dataset' is enabled) or NA (if 'parallel_dataset' disabled or if the length of the dataset is less than the dataset export slice size)
Get all distinct times for the specified object.
getTimes(object) ## S4 method for signature 'observations_set' getTimes(object) ## S4 method for signature 'arm' getTimes(object) ## S4 method for signature 'arms' getTimes(object) ## S4 method for signature 'events' getTimes(object) ## S4 method for signature 'dataset' getTimes(object)
getTimes(object) ## S4 method for signature 'observations_set' getTimes(object) ## S4 method for signature 'arm' getTimes(object) ## S4 method for signature 'arms' getTimes(object) ## S4 method for signature 'events' getTimes(object) ## S4 method for signature 'dataset' getTimes(object)
object |
any object |
numeric vector with all unique times, sorted
Get all time-varying covariates.
getTimeVaryingCovariates(object) ## S4 method for signature 'covariates' getTimeVaryingCovariates(object) ## S4 method for signature 'arm' getTimeVaryingCovariates(object) ## S4 method for signature 'arms' getTimeVaryingCovariates(object) ## S4 method for signature 'dataset' getTimeVaryingCovariates(object)
getTimeVaryingCovariates(object) ## S4 method for signature 'covariates' getTimeVaryingCovariates(object) ## S4 method for signature 'arm' getTimeVaryingCovariates(object) ## S4 method for signature 'arms' getTimeVaryingCovariates(object) ## S4 method for signature 'dataset' getTimeVaryingCovariates(object)
object |
any object |
all time-varying covariates from object
Create hardware settings.
Hardware( cpu = 1, replicate_parallel = FALSE, scenario_parallel = FALSE, slice_parallel = FALSE, slice_size = NULL, dataset_parallel = FALSE, dataset_slice_size = 500, auto_setup_plan = NULL )
Hardware( cpu = 1, replicate_parallel = FALSE, scenario_parallel = FALSE, slice_parallel = FALSE, slice_size = NULL, dataset_parallel = FALSE, dataset_slice_size = 500, auto_setup_plan = NULL )
cpu |
number of CPU cores to use, default is 1 |
replicate_parallel |
enable parallel computing for replicates, default is FALSE |
scenario_parallel |
enable parallel computing for scenarios, default is FALSE |
slice_parallel |
enable parallel computing for slices, default is FALSE |
slice_size |
number of subjects per simulated slice, default is NULL (auto-configured by Campsis depending on the specified engine) |
dataset_parallel |
enable parallelisation when exporting dataset into a table, default is FALSE |
dataset_slice_size |
dataset slice size when exporting subjects to a table, default is 500. Only applicable if 'dataset_parallel' is enabled. |
auto_setup_plan |
auto-setup plan with the library future, if not set (i.e. =NULL), plan will be setup automatically if the number of CPU's > 1. |
hardware settings
Hardware settings class.
cpu
number of CPU cores to use, default is 1
replicate_parallel
enable parallel computing for replicates, default is FALSE
scenario_parallel
enable parallel computing for scenarios, default is FALSE
slice_parallel
enable parallel computing for slices, default is FALSE
slice_size
number of subjects per simulated slice, default is NULL (auto-configured by Campsis depending on the specified engine)
dataset_parallel
enable parallelisation when exporting dataset into a table, default is FALSE
dataset_slice_size
dataset slice size when exporting subjects to a table, default is 500. Only applicable if 'dataset_parallel' is enabled.
auto_setup_plan
auto-setup plan with the library future, default is FALSE
Convert hours to hours (do nothing).
hours(x)
hours(x)
x |
numeric vector in hours |
numeric vector in hours
Create one or several infusion(s).
Infusion( time, amount, compartment = NA, f = NULL, lag = NULL, duration = NULL, rate = NULL, ii = NULL, addl = NULL )
Infusion( time, amount, compartment = NA, f = NULL, lag = NULL, duration = NULL, rate = NULL, ii = NULL, addl = NULL )
time |
treatment time(s), numeric value or vector. First treatment time if used together with ii and addl. |
amount |
total amount to infuse, numeric |
compartment |
compartment index, integer |
f |
fraction of infusion amount, distribution |
lag |
infusion lag time, distribution |
duration |
infusion duration, distribution |
rate |
infusion rate, distribution |
ii |
interdose interval, requires argument 'time' to be a single numeric value |
addl |
number of additional doses, requires argument 'time' to be a single integer value |
a single infusion or a list of infusions.
Infusion class.
duration
infusion duration, distribution
rate
infusion rate, distribution
Internal settings class (transient object from the simulation settings).
dataset_summary
dataset summary
progress
simulation progress
iterations
list of event iterations
Define inter-occasion variability (IOV) into the dataset. A new variable of name 'colname' will be output into the dataset and will vary at each dose number according to the given distribution.
IOV(colname, distribution, doseNumbers = NULL)
IOV(colname, distribution, doseNumbers = NULL)
colname |
name of the column that will be output in dataset |
distribution |
distribution |
doseNumbers |
dose numbers, if provided, IOV is generated at these doses only. By default, IOV is generated for all doses. |
an IOV object
Return the number of subjects contained in this arm.
## S4 method for signature 'arm' length(x)
## S4 method for signature 'arm' length(x)
x |
arm |
a number
Return the number of subjects contained in this dataset.
## S4 method for signature 'dataset' length(x)
## S4 method for signature 'dataset' length(x)
x |
dataset |
a number
Create a log normal distribution.
LogNormalDistribution(meanlog, sdlog)
LogNormalDistribution(meanlog, sdlog)
meanlog |
mean value of distribution in log domain |
sdlog |
standard deviation of distribution in log domain |
a log normal distribution
Convert minutes to hours.
minutes(x)
minutes(x)
x |
numeric vector in minutes |
numeric vector in hours
Convert pharma months (1 month = 4 weeks) to hours.
months(x)
months(x)
x |
numeric vector in months |
numeric vector in hours
NHANES database (demographics and body measure data combined, from 2017-2018).
nhanes
nhanes
data frame
Original identifier
Sex: 1 for males, 2 for females
Age in years
Body weight in kg
Body mass index
Height in cm
https://wwwn.cdc.gov/Nchs/Nhanes/2017-2018/DEMO_J.XPT
https://wwwn.cdc.gov/Nchs/Nhanes/2017-2018/BMX_J.XPT
Create NOCB settings.
NOCB(enable = NULL, variables = character(0))
NOCB(enable = NULL, variables = character(0))
enable |
enable/disable next-observation carried backward mode (NOCB), default value is TRUE for mrgsolve, FALSE for RxODE |
variables |
variable names subject to NOCB behavior (see vignette for more info) |
NOCB settings
NOCB settings class.
enable
enable/disable next-observation carried backward mode (NOCB), default value is TRUE for mrgsolve, FALSE for RxODE
variables
variable names subject to NOCB behavior (see vignette for more info)
Create a normal distribution.
NormalDistribution(mean, sd)
NormalDistribution(mean, sd)
mean |
mean value of distribution |
sd |
standard deviation of distribution |
a normal distribution
Create an observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
Observations(times, compartment = NA)
Observations(times, compartment = NA)
times |
observation times, numeric vector |
compartment |
compartment index, integer |
an observations list
Observations class.
times
observation times, numeric vector
compartment
compartment index, integer
dv
observed values, numeric vector (FOR EXTERNAL USE)
Filter CAMPSIS output on observation rows.
obsOnly(x)
obsOnly(x)
x |
data frame, CAMPSIS output |
a data frame with the observation rows
Define a new occasion. Occasions are defined by mapping occasion values to dose numbers. A new column will automatically be created in the exported dataset.
Occasion(colname, values, doseNumbers)
Occasion(colname, values, doseNumbers)
colname |
name of the column that will be output in dataset |
values |
the occasion numbers, any integer vector |
doseNumbers |
the related dose numbers, any integer vector of same length as 'values' |
occasion object
Occasion class.
colname
single character value representing the column name related to this occasion
values
occasion values, integer vector, same length as dose_numbers
dose_numbers
associated dose numbers, integer vector, same length as values
Create a new output function
Outfun( fun = function(x, ...) { x }, args = list(), packages = NULL, level = "scenario" )
Outfun( fun = function(x, ...) { x }, args = list(), packages = NULL, level = "scenario" )
fun |
function or purrr-style lambda formula, first argument 'x' must be the results |
args |
extra arguments, named list |
packages |
packages that must be loaded to execute the given function, character vector |
level |
either 'scenario' or 'replicate'. Default is 'scenario'. |
an output function
Output function class.
fun
function or purrr-style lambda formula, first argument 'x' must be the results
args
extra arguments, named list
packages
packages that must be loaded to execute the given function, character vector
level
either 'scenario' or 'replicate'. Default is 'scenario'.
Create a parameter distribution. The resulting distribution is a log-normal distribution, with meanlog=log(THETA) and sdlog=sqrt(OMEGA).
ParameterDistribution(model, theta, omega = NULL)
ParameterDistribution(model, theta, omega = NULL)
model |
model |
theta |
corresponding THETA name, character |
omega |
corresponding OMEGA name, character, NULL if not defined |
a parameter distribution
Compute the prediction interval summary over time.
PI(x, output, scenarios = NULL, level = 0.9, gather = TRUE)
PI(x, output, scenarios = NULL, level = 0.9, gather = TRUE)
x |
data frame |
output |
variable to show, character value |
scenarios |
scenarios, character vector, NULL is default |
level |
PI level, default is 0.9 (90% PI) |
gather |
FALSE: med, low & up columns, TRUE: metric column |
a summary table
Create progress settings.
Progress(tick_slice = TRUE)
Progress(tick_slice = TRUE)
tick_slice |
tick() is called after each simulated slice, default is TRUE. In some cases, when the number of subjects per slice is low, it may be useful disable this flag, to improve performance issues. |
progress settings
Progress settings class.
tick_slice
tick() is called after each simulated slice, default is TRUE. In some cases, when the number of subjects per slice is low, it may be useful disable this flag, to improve performance issues.
Retrieve the parameter value (standardized) for the specified parameter name.
retrieveParameterValue(model, paramName, default = NULL, mandatory = FALSE)
retrieveParameterValue(model, paramName, default = NULL, mandatory = FALSE)
model |
model |
paramName |
parameter name |
default |
default value if not found |
mandatory |
must be in model or not |
the standardized parameter value or the given default value if not found
RxODE/rxode2 engine class.
rxode2
logical field to indicate if CAMPSIS should use rxode2 (field set to TRUE) or RxODE (field set to FALSE). Default is TRUE.
Sample generic object.
sample(object, n, ...) ## S4 method for signature 'constant_distribution,integer' sample(object, n) ## S4 method for signature 'fixed_distribution,integer' sample(object, n) ## S4 method for signature 'function_distribution,integer' sample(object, n) ## S4 method for signature 'bootstrap_distribution,integer' sample(object, n) ## S4 method for signature 'bolus,integer' sample(object, n, ...) ## S4 method for signature 'infusion,integer' sample(object, n, ...) ## S4 method for signature 'observations,integer' sample(object, n, ...) ## S4 method for signature 'covariate,integer' sample(object, n) ## S4 method for signature 'bootstrap,integer' sample(object, n) ## S4 method for signature 'campsis_model,integer' sample(object, n)
sample(object, n, ...) ## S4 method for signature 'constant_distribution,integer' sample(object, n) ## S4 method for signature 'fixed_distribution,integer' sample(object, n) ## S4 method for signature 'function_distribution,integer' sample(object, n) ## S4 method for signature 'bootstrap_distribution,integer' sample(object, n) ## S4 method for signature 'bolus,integer' sample(object, n, ...) ## S4 method for signature 'infusion,integer' sample(object, n, ...) ## S4 method for signature 'observations,integer' sample(object, n, ...) ## S4 method for signature 'covariate,integer' sample(object, n) ## S4 method for signature 'bootstrap,integer' sample(object, n) ## S4 method for signature 'campsis_model,integer' sample(object, n)
object |
generic object |
n |
number of samples required |
... |
extra arguments |
sampling result
Scatter plot (or X vs Y plot).
scatterPlot(x, output, colour = NULL, time = NULL)
scatterPlot(x, output, colour = NULL, time = NULL)
x |
data frame |
output |
the 2 variables to show, character vector |
colour |
variable(s) to colour |
time |
the time to look at those 2 variables, if NULL, min time is used (usually 0) |
a ggplot object
Create an scenario.
Scenario(name = NULL, model = NULL, dataset = NULL)
Scenario(name = NULL, model = NULL, dataset = NULL)
name |
scenario name, single character string |
model |
either a CAMPSIS model, a function or lambda-style formula |
dataset |
either a CAMPSIS dataset, a function or lambda-style formula |
a new scenario
Scenario class.
name
scenario name, single character string
model
either a CAMPSIS model, a function or lambda-style formula
dataset
either a CAMPSIS dataset, a function or lambda-style formula
Create a list of scenarios.
Scenarios()
Scenarios()
a scenarios object
Convert seconds to hours.
seconds(x)
seconds(x)
x |
numeric vector in seconds |
numeric vector in hours
Set the label.
setLabel(object, x) ## S4 method for signature 'arm,character' setLabel(object, x)
setLabel(object, x) ## S4 method for signature 'arm,character' setLabel(object, x)
object |
any object that has a label |
x |
the new label |
the updated object
Set the number of subjects.
setSubjects(object, x) ## S4 method for signature 'arm,integer' setSubjects(object, x) ## S4 method for signature 'dataset,integer' setSubjects(object, x)
setSubjects(object, x) ## S4 method for signature 'arm,integer' setSubjects(object, x) ## S4 method for signature 'dataset,integer' setSubjects(object, x)
object |
any object |
x |
the new number of subjects |
the updated object
Create advanced simulation settings.
Settings(...)
Settings(...)
... |
any user-required settings: see ?Hardware, ?Solver, ?NOCB, ?Declare or ?Progress settings |
advanced simulation settings
Setup default plan for the given simulation or hardware settings. This plan will prioritise the distribution of workers in the following order: 1) Replicates (if 'replicate_parallel' is enabled) 2) Scenarios (if 'scenario_parallel' is enabled) 3) Dataset export / slices (if 'dataset_export' or 'slice_parallel' is enabled)
setupPlanDefault(object)
setupPlanDefault(object)
object |
simulation or hardware settings |
nothing
Setup plan as sequential (i.e. no parallelisation).
setupPlanSequential()
setupPlanSequential()
nothing
Shaded plot (or prediction interval plot).
shadedPlot( x, output, colour = NULL, strat_extra = NULL, level = 0.9, alpha = 0.25 )
shadedPlot( x, output, colour = NULL, strat_extra = NULL, level = 0.9, alpha = 0.25 )
x |
data frame |
output |
variable to show |
colour |
variable(s) to colour |
strat_extra |
variable(s) to stratify, but not to colour (useful for use with facet_wrap) |
level |
PI level, default is 0.9 (90% PI) |
alpha |
alpha parameter (transparency) given to geom_ribbon |
a ggplot object
Simulate function.
simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## dataset, ## character, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## tbl_df, ## character, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## data.frame, ## character, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## tbl_df, ## rxode_engine, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## tbl_df, ## mrgsolve_engine, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL )
simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## dataset, ## character, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## tbl_df, ## character, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## data.frame, ## character, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## tbl_df, ## rxode_engine, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL ) ## S4 method for signature ## 'campsis_model, ## tbl_df, ## mrgsolve_engine, ## events, ## scenarios, ## function, ## character, ## output_function, ## integer, ## integer, ## logical, ## simulation_settings' simulate( model, dataset, dest = NULL, events = NULL, scenarios = NULL, tablefun = NULL, outvars = NULL, outfun = NULL, seed = NULL, replicates = 1, dosing = FALSE, settings = NULL )
model |
generic CAMPSIS model |
dataset |
CAMPSIS dataset or 2-dimensional table |
dest |
destination simulation engine, default is 'RxODE' |
events |
interruption events |
scenarios |
list of scenarios to be simulated |
tablefun |
function or lambda formula to apply on exported 2-dimensional dataset |
outvars |
variables to output in resulting dataframe |
outfun |
an output function to apply on the simulation results. Type ?Outfun for more info. |
seed |
seed value |
replicates |
number of replicates, default is 1 |
dosing |
output dosing information, default is FALSE |
settings |
advanced simulation settings |
dataframe with all results
Simulation progress class.
replicates |
total number of replicates to simulate |
scenarios |
total number of scenarios to simulate |
iterations |
total number of iterations to simulate |
slices |
total number of slices to simulate |
replicate |
current replicate number being simulated |
scenario |
current scenario number being simulated |
iteration |
current iteration number being simulated |
slice |
current slice number being simulated |
progressor |
progressr progressor |
hardware |
hardware settings |
Simulation settings class.
hardware
hardware settings object
solver
solver settings object
nocb
NOCB settings object
declare
declare settings (mrgsolve only)
progress
progress settings
internal
internal settings
Create a simulation progress object.
SimulationProgress( replicates = 1, scenarios = 1, progressor = NULL, hardware = NULL )
SimulationProgress( replicates = 1, scenarios = 1, progressor = NULL, hardware = NULL )
replicates |
total number of replicates to simulate |
scenarios |
total number of scenarios to simulate |
progressor |
progressr progressor |
hardware |
hardware settings |
a progress bar
Create solver settings.
Solver( atol = 1e-08, rtol = 1e-08, hmax = NA, maxsteps = 70000L, method = "liblsoda" )
Solver( atol = 1e-08, rtol = 1e-08, hmax = NA, maxsteps = 70000L, method = "liblsoda" )
atol |
absolute solver tolerance, default is 1e-08 |
rtol |
relative solver tolerance, default is 1e-08 |
hmax |
limit how big a solver step can be, default is NA |
maxsteps |
max steps between 2 integration times (e.g. when observations records are far apart), default is 70000 |
method |
solver method, for RxODE/rxode2 only: 'liblsoda' (default), 'lsoda', 'dop853', 'indLin'. Mrgsolve's method is always 'lsoda'. |
solver settings
Solver settings class. See ?mrgsolve::update. See ?rxode2::rxSolve.
atol
absolute solver tolerance, default is 1e-08
rtol
relative solver tolerance, default is 1e-08
hmax
limit how big a solver step can be, default is NA
maxsteps
max steps between 2 integration times (e.g. when observations records are far apart), default is 70000
method
solver method, for RxODE/rxode2 only: 'liblsoda' (default), 'lsoda', 'dop853', 'indLin'. Mrgsolve's method is always 'lsoda'.
Spaghetti plot.
spaghettiPlot(x, output, colour = NULL)
spaghettiPlot(x, output, colour = NULL)
x |
data frame |
output |
variable to show |
colour |
variable(s) to colour |
plot
Standardise time to hours.
standardiseTime(x, unit)
standardiseTime(x, unit)
x |
numeric time vector |
unit |
unit of x, single character value |
numeric vector with the times converted to hours
Create a time-varying covariate. This covariate will be implemented using EVID=2 rows in the exported dataset and will not use interruption events.
TimeVaryingCovariate(name, table)
TimeVaryingCovariate(name, table)
name |
covariate name, character |
table |
data.frame, must contain the mandatory columns 'TIME' and 'VALUE'. An 'ID' column may also be specified. In that case, ID's between 1 and the max number of subjects in the dataset/arm can be used. All ID's must have a VALUE defined for TIME 0. |
a time-varying covariate
Treatment IOV class.
colname
name of the column that will be output in dataset
distribution
distribution
dose_numbers
associated dose numbers, integer vector, same length as values
Undefined distribution class. This type of object is automatically created in method toExplicitDistribution() when the user does not provide a concrete distribution. This is because S4 objects do not accept NULL values.
Create an uniform distribution.
UniformDistribution(min, max)
UniformDistribution(min, max)
min |
min value |
max |
max value |
an uniform distribution
Compute the VPC summary. Input data frame must contain the following columns: - replicate: replicate number - low: low percentile value in replicate (and in scenario if present) - med: median value in replicate (and in scenario if present) - up: up percentile value in replicate (and in scenario if present) - any scenario column
VPC(x, scenarios = NULL, level = 0.9)
VPC(x, scenarios = NULL, level = 0.9)
x |
data frame |
scenarios |
scenarios, character vector, NULL is default |
level |
PI level, default is 0.9 (90% PI) |
VPC summary with columns TIME, <scenarios> and all combinations of low, med, up (i.e. low_low, low_med, low_up, etc.)
VPC plot.
vpcPlot(x, scenarios = NULL, level = 0.9, alpha = 0.15)
vpcPlot(x, scenarios = NULL, level = 0.9, alpha = 0.15)
x |
data frame, output of CAMPSIS with replicates |
scenarios |
scenarios, character vector, NULL is default |
level |
PI level, default is 0.9 (90% PI) |
alpha |
alpha parameter (transparency) given to geom_ribbon |
a ggplot object
Convert weeks to hours.
weeks(x)
weeks(x)
x |
numeric vector in weeks |
numeric vector in hours
Convert pharma years (1 year = 12*4 weeks) to hours.
years(x)
years(x)
x |
numeric vector in years |
numeric vector in hours