Chapter 3 Related R packages
3.1 ODE solving
This is a brief comparison of pharmacometric ODE solving R packages to
RxODE
.
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 RxODE 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,
RxODE
has a R-like mini-language that is parsed into C code that solves the ODE system.Unlike
RxODE
,mrgsolve
does not currently support symbolic manipulation of ODE systems, like automatic Jacobian calculation or forward sensitivity calculation (RxODE
currently supports this and this is the basis of nlmixr’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
RxODE
defines ODE systems at a lower level.RxODE
’s parsing of the mini-language comes from C, whereasdMod
’s parsing comes from R.Like
RxODE
,dMod
supports symbolic manipulation of ODE systems and calculates forward sensitivities and adjoint sensitivities of systems.Unlike
RxODE
,dMod
is not thread-safe sincedeSolve
is not yet thread-safe.
And there is one package that is not released on CRAN:
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 RxODE maintainers has had positive interactions with all of the ODE-solving pharmacometric projects listed.
3.2 PK Solved systems
RxODE
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.
RxODE
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.
- 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.