• 1 Introduction
  • 2 Authors and Acknowledgments
    • 2.1 Authors
    • 2.2 Contributors
    • 2.3 RxODE acknowledgments:
  • 3 Related R packages
    • 3.1 ODE solving
    • 3.2 PK Solved systems
      • 3.2.1 The following packages for solved PK systems are on CRAN
      • 3.2.2 Non-CRAN libraries:
  • 4 Installation
    • 4.0.1 Windows
    • 4.0.2 Mac OSX
    • 4.0.3 Linux
    • 4.0.4 R versions 4.0 and 4.1
    • 4.1 Development version
  • 5 Getting Started
    • 5.1 Specify Dosing and sampling in rxode2
    • 5.2 Solving ODEs
  • 6 rxode2 syntax
    • 6.1 Example
    • 6.2 Syntax
      • 6.2.1 Identifiers
    • 6.3 Logical Operators
    • 6.4 Supported functions
    • 6.5 Reserved keywords
    • 6.6 Residual functions when using rxode2 functions
      • 6.6.1 Transformations
      • 6.6.2 Normal and t-related distributions
      • 6.6.3 Notes on additive + proportional models
      • 6.6.4 Distributions of known likelihoods
      • 6.6.5 Ordinal likelihoods
      • 6.6.6 General table of supported residual distributions
    • 6.7 cmt() changing compartment numbers for states
      • 6.7.1 How rxode2 numbers compartments
      • 6.7.2 Changing compartments by pre-declaring with cmt()
      • 6.7.3 Appending compartments to the model with cmt()
  • 7 rxode2 events
    • 7.1 rxode2 event tables
    • 7.2 Bolus/Additive Doses
    • 7.3 Infusion Doses
      • 7.3.1 Constant Infusion (in terms of duration and rate)
      • 7.3.2 Modeled Rate and Duration of Infusion
    • 7.4 Steady State
      • 7.4.1 Steady state for complex dosing
      • 7.4.2 Steady state for constant infusion or zero order processes
    • 7.5 Reset Events
    • 7.6 Turning off compartments
    • 7.7 Classic rxode2 events
      • 7.7.1 Bolus Dose Examples
      • 7.7.2 Infusion Event Examples
      • 7.7.3 Steady State for classic RxODE EVID example
      • 7.7.4 Steady state with lagged dose for classic RxODE evid
      • 7.7.5 Turning off a compartment with classic RxODE EVID
    • 7.8 Datasets for rxode2 & nlmixr
    • 7.9 Columns Described by Type of Use
      • 7.9.1 Subject Identification Columns
      • 7.9.2 Observation Columns
      • 7.9.3 Dosing Columns
      • 7.9.4 Covariate Columns
    • 7.10 Details for Specific Dataset Columns
      • 7.10.1 AMT Column
      • 7.10.2 CENS/LIMIT Columns
      • 7.10.3 CMT Column
      • 7.10.4 DUR Column
      • 7.10.5 DV Column
      • 7.10.6 DVID Column
      • 7.10.7 EVID Column
      • 7.10.8 ID Column
      • 7.10.9 RATE Column
  • 8 Easily creating rxode2 events
    • 8.1 Adding doses to the event table
    • 8.2 Adding sampling to an event table
    • 8.3 Expand the event table to a multi-subject event table.
    • 8.4 Add doses and samples within a sampling window
    • 8.5 Combining event tables
    • 8.6 Sequencing event tables
    • 8.7 Repeating event tables
    • 8.8 Combining event tables with rbind
    • 8.9 Event tables in Rstudio Notebooks
  • 9 Solving and solving options
    • 9.1 General Solving Options
      • 9.1.1 object
      • 9.1.2 params
      • 9.1.3 events
      • 9.1.4 inits
      • 9.1.5 sigdig
      • 9.1.6 atol
      • 9.1.7 rtol
      • 9.1.8 atolSens
      • 9.1.9 rtolSens
      • 9.1.10 maxsteps
      • 9.1.11 hmin
      • 9.1.12 hmax
      • 9.1.13 hmaxSd
      • 9.1.14 hini
      • 9.1.15 maxordn
      • 9.1.16 maxords
      • 9.1.17 mxhnil
      • 9.1.18 hmxi
      • 9.1.19 istateReset
    • 9.2 Inductive Linerization Options
      • 9.2.1 indLinMatExpType
      • 9.2.2 indLinMatExpOrder
      • 9.2.3 indLinPhiTol
      • 9.2.4 indLinPhiM
    • 9.3 Steady State Solving Options
      • 9.3.1 minSS
      • 9.3.2 maxSS
      • 9.3.3 strictSS
      • 9.3.4 infSSstep
      • 9.3.5 ssAtol
      • 9.3.6 ssRtol
      • 9.3.7 ssAtolSens
      • 9.3.8 ssRtolSens
    • 9.4 rxode2 numeric stability options
      • 9.4.1 maxAtolRtolFactor
      • 9.4.2 stateTrim
      • 9.4.3 safeZero
      • 9.4.4 sumType
      • 9.4.5 prodType
      • 9.4.6 maxwhile
    • 9.5 Linear compartment model sensitivity options
      • 9.5.1 sensType
      • 9.5.2 linDiff
      • 9.5.3 linDiffCentral
    • 9.6 Covariate Solving Options
      • 9.6.1 iCov
      • 9.6.2 covsInterpolation
      • 9.6.3 addCov
    • 9.7 Simulation options
      • 9.7.1 seed
      • 9.7.2 nsim
      • 9.7.3 thetaMat
      • 9.7.4 thetaLower
      • 9.7.5 thetaUpper
      • 9.7.6 thetaDf
      • 9.7.7 thetaIsChol
      • 9.7.8 nStud
      • 9.7.9 omega
      • 9.7.10 omegaIsChol
      • 9.7.11 omegaSeparation
      • 9.7.12 omegaXform
      • 9.7.13 omegaLower
      • 9.7.14 omegaUpper
      • 9.7.15 omegaDf
      • 9.7.16 nSub
      • 9.7.17 dfSub
      • 9.7.18 sigma
      • 9.7.19 sigmaLower
      • 9.7.20 sigmaUpper
      • 9.7.21 sigmaXform
      • 9.7.22 sigmaDf
      • 9.7.23 sigmaIsChol
      • 9.7.24 sigmaSeparation
      • 9.7.25 dfObs
      • 9.7.26 resample
      • 9.7.27 resampleID
    • 9.8 rxode2 output options
      • 9.8.1 returnType
      • 9.8.2 addDosing
      • 9.8.3 keep
      • 9.8.4 drop
      • 9.8.5 idFactor
      • 9.8.6 subsetNonmem
      • 9.8.7 scale
      • 9.8.8 amountUnits
      • 9.8.9 timeUnits
      • 9.8.10 theta
      • 9.8.11 eta
      • 9.8.12 from
      • 9.8.13 to
      • 9.8.14 length.out
      • 9.8.15 by
      • 9.8.16 warnIdSort
      • 9.8.17 warnDrop
    • 9.9 Internal rxode2 options
      • 9.9.1 nDisplayProgress
      • 9.9.2 simVariability
      • 9.9.3 …
      • 9.9.4 a
      • 9.9.5 b
      • 9.9.6 updateObject
    • 9.10 Parallel/Threaded Solve
      • 9.10.1 cores
      • 9.10.2 nCoresRV
      • 9.10.3 nLlikAlloc
      • 9.10.4 useStdPow
      • 9.10.5 ss2cancelAllPending
      • 9.10.6 addlKeepsCov
      • 9.10.7 addlDropSs
      • 9.10.8 ssAtDoseTime
      • 9.10.9 naTimeHandle
  • 10 rxode2 output
    • 10.1 Using rxode2 data frames
      • 10.1.1 Creating an interactive data frame
      • 10.1.2 rxode2 solved object properties
      • 10.1.3 Using the solved object as a simple data frame
    • 10.2 Updating the data-set interactively
      • 10.2.1 Modifying observation times for rxode2
      • 10.2.2 Modifying simulation parameters
  • 11 Simulation
    • 11.1 Single Subject solving
      • 11.1.1 Summary of Single solve vs Multiple subject solving
    • 11.2 Population Simulations with rxode2
      • 11.2.1 Simulation of Variability with rxode2
    • 11.3 Simulation of Clinical Trials
      • 11.3.1 Simulation from inverse Wishart correlations
      • 11.3.2 Simulate using variance/standard deviation standard errors
      • 11.3.3 Simulate without uncertainty in omega or sigma parameters
    • 11.4 Using prior data for solving
  • 12 Examples
    • 12.1 Prediction only models
    • 12.2 Solved compartment models
    • 12.3 Mixing Solved Systems and ODEs
    • 12.4 Weight based dosing
      • 12.4.1 Creating a 2-compartment model in rxode2
      • 12.4.2 Simulating Covariates
      • 12.4.3 Creating weight based event table
      • 12.4.4 Solving Daptomycin simulation
      • 12.4.5 Daptomycin Reference
    • 12.5 Inter-occasion and other nesting examples
      • 12.5.1 Event table
      • 12.5.2 rxode2 model
      • 12.5.3 Uncertainty in Model parameters
      • 12.5.4 Nesting Variability
      • 12.5.5 Unexplained variability
      • 12.5.6 Solving the problem
    • 12.6 Transit compartment models
  • 13 Advanced & Miscellaneous Topics
    • 13.1 Covariates in rxode2
      • 13.1.1 Individual Covariates
      • 13.1.2 Time Varying Covariates
    • 13.2 Shiny and rxode2
      • 13.2.1 Facilities for generating R shiny applications
      • 13.2.2 Exploring parameter fits graphically using shiny
    • 13.3 Using rxode2 with a pipeline
      • 13.3.1 Setting up the rxode2 model for the pipeline
      • 13.3.2 Simulating one event table
      • 13.3.3 Simulating multiple subjects from a single event table
      • 13.3.4 Summarizing the simulation output
    • 13.4 Speeding up rxode2
      • 13.4.1 A note about the speed of the functional form for rxode2
      • 13.4.2 Increasing rxode2 speed by multi-subject parallel solving
      • 13.4.3 A real life example
    • 13.5 Integrating rxode2 models in your package
      • 13.5.1 Using Pre-compiled models in your packages
      • 13.5.2 Using Models in a already present package
    • 13.6 Stiff ODEs with Jacobian Specification

rxode2 user manual

Chapter 3 Related R packages

3.1 ODE solving

This is a brief comparison of pharmacometric ODE solving R packages to rxode2.

There are several R packages for differential equations. The most popular is deSolve.

However for pharmacometrics-specific ODE solving, there are only 2 packages other than rxode2 released on CRAN. Each uses compiled code to have faster ODE solving.

  • mrgsolve, which uses C++ lsoda solver to solve ODE systems. The user is required to write hybrid R/C++ code to create a mrgsolve model which is translated to C++ for solving.

    In contrast, rxode2 has a R-like mini-language that is parsed into C code that solves the ODE system.

    Unlike rxode2, mrgsolve does not currently support symbolic manipulation of ODE systems, like automatic Jacobian calculation or forward sensitivity calculation (rxode2 currently supports this and this is the basis of nlmixr2’s FOCEi algorithm)

  • dMod, which uses a unique syntax to create “reactions”. These reactions create the underlying ODEs and then created c code for a compiled deSolve model.

    In contrast rxode2 defines ODE systems at a lower level. rxode2’s parsing of the mini-language comes from C, whereas dMod’s parsing comes from R.

    Like rxode2, dMod supports symbolic manipulation of ODE systems and calculates forward sensitivities and adjoint sensitivities of systems.

    Unlike rxode2, dMod is not thread-safe since deSolve is not yet thread-safe.

  • PKPDsim which defines models in an R-like syntax and converts the system to compiled code.

    Like mrgsolve, PKPDsim does not currently support symbolic manipulation of ODE systems.

    PKPDsim is not thread-safe.

The open pharmacometrics open source community is fairly friendly, and the rxode2 maintainers has had positive interactions with all of the ODE-solving pharmacometric projects listed.

3.2 PK Solved systems

rxode2 supports 1-3 compartment models with gradients (using stan math’s auto-differentiation). This currently uses the same equations as PKADVAN to allow time-varying covariates.

rxode2 can mix ODEs and solved systems.

3.2.1 The following packages for solved PK systems are on CRAN

  • mrgsolve currently has 1-2 compartment (poly-exponential models) models built-in. The solved systems and ODEs cannot currently be mixed.

  • pmxTools currently have 1-3 compartment (super-positioning) models built-in. This is a R-only implementation.

  • PKPDsim uses 1-3 “ADVAN” solutions using non-superpositioning.

  • PKPDmodels has a one-compartment model with gradients.

3.2.2 Non-CRAN libraries:

  • PKADVAN Provides 1-3 compartment models using non-superpositioning. This allows time-varying covariates.