Learn R Programming

campsis

Requirements

  • R package campsismod must be installed beforehand
  • Simulation engine must be installed too (rxode2 or mrgsolve)

Installation

Install the latest stable release using devtools:

devtools::install_github("Calvagone/campsis")

Basic example

Import the campsis package:

library(campsis)

Create your dataset:

ds <- Dataset(50) %>%
  add(Bolus(time=0, amount=1000, ii=12, addl=2)) %>%
  add(Observations(times=seq(0, 36, by=0.5)))

Load your own model or use a built-in model from the library:

model <- model_suite$pk$`2cpt_fo`

Simulate your results with your preferred simulation engine (rxode2 or mrgsolve):

results <- model %>% simulate(dataset=ds, dest="rxode2", seed=1)

Plot your results:

shadedPlot(results, "CONC")

Copy Link

Version

Install

install.packages('campsis')

Monthly Downloads

324

Version

1.8.1

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Luyckx

Last Published

January 28th, 2026

Functions in campsis (1.8.1)

FixedDistribution

Create a fixed distribution. Each sample will be assigned a fixed value coming from vector 'values'.
FunctionDistribution

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")).
EventRelatedObservations

Create an event-related observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
Events

Create a list of interruption events.
Declare

Create declare settings.
Hardware

Create hardware settings.
NormalDistribution

Create a normal distribution.
NOCB

Create NOCB settings.
IOV

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.
DatasetSummary

Create a dataset summary (internal method).
ParameterDistribution

Create a parameter distribution. The resulting distribution is a log-normal distribution, with meanlog=log(THETA) and sdlog=sqrt(OMEGA).
Scenario

Create an scenario.
Scenarios

Create a list of scenarios.
Progress

Create progress settings.
Solver

Create solver settings.
TimeSequence

Instantiate a new time sequence.
TimeVaryingCovariate

Create a time-varying covariate. This covariate will be implemented using EVID=2 rows in the exported dataset and will not use interruption events.
RepeatAtSchedule

'Repeat at' schedule constructor. Note that the time 0 for the base pattern will be added by default if not provided.
TimeVector

Instantiate a new time vector
applyCompartmentCharacteristics

Apply compartment characteristics from model. In practice, only compartment infusion duration needs to be applied.
applyAction

Apply some action on the given object.
ReplaceAction

Create a replace action.
as.numeric,time_vector-method

Time vector to numeric vector.
arms-class

Arms class.
bolus_wrapper-class

Bolus wrapper class.
Observations

Create an observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
assignDoseNumber

Assign dose number to each treatment entry.
UniformDistribution

Create an uniform distribution.
bolus-class

Bolus class.
Occasion

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.
VPC

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
bootstrap-class

Bootstrap class.
binomial_distribution-class

Binomial distribution class.
Infusion

Create one or several infusion(s).
checkIIandADDL

Check ii and addl arguments in addition to time.
as.numeric,time_sequence-method

Time sequence to numeric vector.
bootstrap_distribution-class

Bootstrap distribution class.
campsis_handler

Suggested Campsis handler for showing the progress bar.
LogNormalDistribution

Create a log normal distribution.
counterBalanceLocfMode

Counter-balance LOCF mode for occasions & IOV. This function will simply shift all the related occasion & IOV columns to the left (by one).
computeIncrementalProgress

Compute incremental progress.
counterBalanceNocbMode

Counter-balance NOCB mode for occasions & IOV. This function will simply shift all the related occasion & IOV columns to the right (by one).
PI

Compute the prediction interval summary over time.
Outfun

Create a new output function
constant_distribution-class

Constant distribution class.
cyclic_schedule-class

Cyclic schedule class.
cutTableForEvent

Cut table according to given iteration.
dataset-class

Dataset class.
convertTime

Convert numeric time vector based on the provided units.
exportTableDelegate

Export table delegate.
distribution-class

Distribution class. See this class as an interface.
dose_adaptation-class

Dose adaptation class.
dosing_schedule-class

Dosing schedule class.
default_settings-class

Default settings class.
dataset_config-class

Dataset configuration class.
event_covariate-class

Event covariate class.
event-class

Event class.
fixed_distribution-class

Fixed distribution class.
getAvailableTimeUnits

Return the list of available time units.
getCampsisOption

Get Campsis option logic.
discrete_distribution-class

Discrete distribution class.
dosingOnly

Filter CAMPSIS output on dosing rows.
fixed_covariate-class

Fixed covariate class.
fillIOVOccColumns

Fill IOV/Occasion columns.
dose_adaptations-class

Dose adaptations class.
function_distribution-class

Function distribution class.
getIOVs

Get all IOV objects.
dropOthers

Return the 'DROP_OTHERS' string that may be used in the 'outvars' vector for RxODE/mrgsolve to drop all others variables that are usually output in the resulting data frame.
getCompartmentMapping

Get a mapping table with all possibilities of compartment names and their indexes knowing that compartment names can be provided as character or as integer.
getCovariates

Get all covariates (fixed / time-varying / event covariates).
events-class

Events class.
getEventCovariates

Get all event-related covariates.
exportDelegate

Export delegate method. This method is common to RxODE and mrgsolve.
getInitialConditions

Get initial conditions at simulation start-up.
factorScenarios

Factor scenarios columns if not done yet.
getColumn

Get data of given column unless if does not exist (return NULL in that case).
getCampsisOptions

Get the Campsis options (R options).
getDatasetMaxTime

Get dataset max time.
declare_settings-class

Declare settings class.
generateIIV_

Generate IIV matrix for the given OMEGA matrix.
generateIIV

Generate IIV matrix for the given Campsis model.
days

Convert days to hours.
covariates-class

Covariates class.
SimulationProgress

Create a simulation progress object.
covariate-class

Covariate class.
Settings

Create advanced simulation settings.
applyScenario

Apply scenario to the given model or dataset.
arm-class

Arm class.
getSeedForDatasetExport

Get seed for dataset export.
getOccasions

Get all occasions.
getSeed

Get seed value.
hardware_settings-class

Hardware settings class.
getTimeVaryingCovariates

Get all time-varying covariates.
getTimes

Get all distinct times for the specified object.
getRandomSeedValue

Get random seed value.
getEventIterations

Get list of event iterations.
getTimeVaryingVariables

Get all time-varying variables. These variables are likely to be influenced by the NOCB mode chosen and by the 'nocbvars' vector.
getFixedCovariates

Get all fixed covariates.
getSplittingConfiguration

Get splitting configuration for parallel export.
getSimulationEngineType

Get simulation engine type.
leftJoinIIV

Left-join IIV matrix.
getSeedForParametersSampling

Get seed for parameter uncertainty sampling.
getSeedForIteration

Get seed for iteration.
nhanes

NHANES database (demographics and body measure data combined, from 2017-2018).
mergeTimeVaryingCovariates

Merge time-varying covariates into a single data frame. This last data frame will be merged afterwards with all treatment and observation rows.
internal_settings-class

Internal settings class (transient object from the simulation settings).
nocb_settings-class

NOCB settings class.
isEmptyBootstrap

Is the given bootstrap empty.
infusion-class

Infusion class.
infusion_wrapper-class

Infusion wrapper class.
length,cyclic_schedule-method

Return the number of repetition cycles.
minutes

Convert minutes to hours.
jsonToCampsisSettings

JSON to Campsis dataset.
mrgsolve_engine-class

mrgsolve engine class.
jsonToCampsisDataset

JSON to Campsis dataset.
output_function-class

Output function class.
months

Convert pharma months (1 month = 4 weeks) to hours.
preprocessIds

Preprocess subjects ID's.
preprocessNocbvars

Preprocess 'nocbvars' argument.
openJSON

Open JSON file.
occasion-class

Occasion class.
occasions-class

Occasions class.
observations-class

Observations class.
observations_set-class

Observations set class.
length,arm-method

Return the number of subjects contained in this arm.
preprocessTSLDAndTDOSColumn

Preprocess TSLD and TDOS columns according to given dataset configuration.
preprocessArmColumn

Preprocess ARM column. Add ARM equation in model automatically.
preprocessDest

Pre-process destination engine. Throw an error message if the destination engine is not installed.
progress_settings-class

Progress settings class.
protocol-class

Protocol class.
length,dataset-method

Return the number of subjects contained in this dataset.
normal_distribution-class

Normal distribution class.
obsOnly

Filter CAMPSIS output on observation rows.
sample

Sample generic object.
preprocessDosing

Preprocess 'dosing' argument.
preprocessEvents

Pre-process events.
removeInitialConditions

Remove initial conditions.
reorderColumns

Reorder output columns.
sampleCovariatesList

Sample covariates list.
scenarios-class

Scenarios class.
seconds

Convert seconds to hours.
repeated_schedule-class

Repeated schedule class. See this class as an interface.
replace_action-class

Replace action class.
processAllTimeColumns

Process time-related columns according to given dataset configuration.
processArmLabels

Process arm labels. Arm identifiers in ARM column are replaced by arm labels as soon as one arm label is provided.
preprocessTablefun

Pre-process tablefun argument.
scenario-class

Scenario class.
scatterPlot

Scatter plot (or X vs Y plot).
setLabel

Set the label.
retrieveParameterValue

Retrieve the parameter value (standardized) for the specified parameter name.
setSeed

Set the seed. The goal of this method is to centralize all calls to the R method 'set.seed'.
preprocessSlices

Preprocess 'slices' argument.
preprocessSettings

Preprocess the simulation settings.
preprocessOutfun

Pre-process outfun argument.
preprocessOutvars

Preprocess 'outvars' argument. 'Outvars' is a character vector which tells CAMPSIS the mandatory columns to keep in the output dataframe.
hours

Convert hours to hours (do nothing).
length,repeat_at_schedule-method

Return the number of repetition cycles.
lognormal_distribution-class

Log normal distribution class.
sampleTimeVaryingCovariates

Sample time-varying covariates.
importCampsismodToNamespace

Import the whole campsismod package into NAMESPACE when parsed by 'roxygen'.
preprocessReplicates

Preprocess 'replicates' argument.
onCI

Check if the current session is on CI (e.g. GitHub actions).
onCran

Check if the current session is on CRAN. The objective is to potentially suppress long tasks to be run on CRAN (long tests or vignettes).
sampleDistributionAsTibble

Sample a distribution and return a tibble.
preprocessScenarios

Pre-process scenarios.
simulation_engine-class

Simulation engine class.
simulation_progress-class

Simulation progress class.
spaghettiPlot

Spaghetti plot.
rxode_engine-class

RxODE/rxode2 engine class.
simulateDelegateCore

Simulation delegate core (single replicate).
toExplicitDistribution

Convert user-given distribution to an explicit CAMPSIS distribution. Passed distribution can be: - a NULL value. In that case, it will be converted into an 'UndefinedDistribution'. - a single numeric value. In that case, it will be converted into a 'ConstantDistribution'. - a numeric vector. In that case, it will be converted into a 'FixedDistribution'. - all available types of distribution. In this case, no conversion is applied.
simulateScenarios

Simulation scenarios.
toDatasetSummary

Convert dataset to dataset summary (internal method).
scenario_action-class

Scenario action class.
scenario_actions-class

Scenario actions class.
splitDataset

Split dataset according to config.
setupPlanSequential

Setup plan as sequential (i.e. no parallelisation).
shadedPlot

Shaded plot (or prediction interval plot).
standardiseTime

Standardise time to hours.
processDropOthers

Process 'DROP_OTHERS'.
repeatSchedule

Repeat schedule.
simulate

Simulate function.
simulation_settings-class

Simulation settings class.
setupPlanDefault

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)
time_vector-class

Time vector class.
setSubjects

Set the number of subjects.
time_varying_covariate-class

Time-varying covariate class.
repeat_at_schedule-class

'Repeat at' schedule class.
undefined_schedule-class

Undefined schedule class.
processSimulateArguments

Preprocess arguments of the simulate method.
unwrapTreatment

Unwrap treatment.
updateAmount

Update amount.
updateADDL

Update the number of additional doses (ADDL).
uniteColumns

Unite the given column names.
updateRepeat

Update the repeat field (argument 'rep' in Bolus and Infusion constructors).
updateII

Update the inter-dose interval (II).
vpcPlot

VPC plot.
treatment-class

Treatment class.
treatment_iov-class

Treatment IOV class.
solver_settings-class

Solver settings class. See ?mrgsolve::update. See ?rxode2::rxSolve.
simulateDelegate

Simulation delegate (several replicates).
uniform_distribution-class

Uniform distribution class.
weeks

Convert weeks to hours.
treatment_iovs-class

Treatment IOV's class.
time_sequence-class

Time sequence class.
undefined_distribution-class

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.
years

Convert pharma years (1 year = 12*4 weeks) to hours.
Arm

Create a treatment arm.
BinomialDistribution

Binomial distribution.
DoseAdaptation

Create a dose adaptation.
DosingSchedule

Dosing schedule constructor.
Bolus

Create one or several bolus(es).
Covariate

Create a non time-varying (fixed) covariate.
EtaDistribution

Create an ETA distribution. The resulting distribution is a normal distribution, with mean=0 and sd=sqrt(OMEGA).
CyclicSchedule

Cyclic schedule constructor.
Bootstrap

Create a bootstrap object.
EventCovariate

Create an event covariate. These covariates can be modified further in interruption events.
EventIteration

Create an event iteration object.
Event

Create an interruption event.
Dataset

Create a dataset.
DatasetConfig

Create a dataset configuration. This configuration allows CAMPSIS to know which are the default depot and observed compartments.
ConstantDistribution

Create a constant distribution. Its value will be constant across all generated samples.
BootstrapDistribution

Create a bootstrap distribution. During function sampling, CAMPSIS will generate values depending on the given data and arguments.
DefaultSettings

Create default settings.
DiscreteDistribution

Discrete distribution.