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,
rxode2has a R-like mini-language that is parsed into C code that solves the ODE system.Unlike
rxode2,mrgsolvedoes not currently support symbolic manipulation of ODE systems, like automatic Jacobian calculation or forward sensitivity calculation (rxode2currently 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
rxode2defines ODE systems at a lower level.rxode2’s parsing of the mini-language comes from C, whereasdMod’s parsing comes from R.Like
rxode2,dModsupports symbolic manipulation of ODE systems and calculates forward sensitivities and adjoint sensitivities of systems.Unlike
rxode2,dModis not thread-safe sincedeSolveis not yet thread-safe.PKPDsim which defines models in an R-like syntax and converts the system to compiled code.
Like
mrgsolve,PKPDsimdoes not currently support symbolic manipulation of ODE systems.PKPDsimis 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.