nlmixr2 verse 4.0+

By Matthew Fidler in nlmixr2

August 28, 2025

nlmixr2 4.0 verse

As promised, I am discussing some other change that are breaking and makes nlmixr2 a major release.

First is a very visible change as you load nlmixr2:

library(nlmixr2)
## ── Attaching packages ───────────────────────────────────────────────────────── nlmixr2 4.0.1 ──
## ✔ lotri         1.0.2     ✔ monolix2rx    0.0.6
## ✔ nlmixr2data   2.0.9     ✔ nlmixr2lib    0.3.0
## ✔ nlmixr2est    4.1.0     ✔ nlmixr2rpt    0.2.1
## ✔ nlmixr2extra  3.0.3     ✔ nonmem2rx     0.1.8
## ✔ nlmixr2plot   3.0.3     ✔ posologyr     1.2.8
## ✔ rxode2        4.1.0     ✔ shinyMixR     0.5.2
## ✔ babelmixr2    0.1.9     ✔ xpose.nlmixr2 0.4.1
## ✔ ggPMX         1.3.1
## ── Optional Packages Loaded/Ignored ─────────────────────────────────────────── nlmixr2 4.0.1 ──
## ✔ babelmixr2        ✔ nonmem2rx    
## ✔ ggPMX             ✔ posologyr    
## ✔ monolix2rx        ✔ shinyMixR    
## ✔ nlmixr2lib        ✔ xpose.nlmixr2
## ✔ nlmixr2rpt
## ── Conflicts ───────────────────────────────────────────────────────────── nlmixr2conflicts() ──
## ✖ rxode2::boxCox()     masks nlmixr2est::boxCox()
## ✖ rxode2::yeoJohnson() masks nlmixr2est::yeoJohnson()

This is looks like the tidyverse with an additional section for optional packages loaded (if available, based loosely on pkgverse)

In this release, the nlmixr2 has become a complete umbrella package like tidyverse. The estimation routines are still found in nlmixr2est and the nlmixr2/rxode2 language and ode solving are in rxode2. In the past you could call estimation procedures by prefixing nlmixr2, for example nlmixr2::nlmixr2() would run the nlmixr2 estimation routine. With this new release, this is no longer possible. Instead you have to call the corresponding package where the routine is defined nlmixr2est::nlmixr2().

Also with this release, as long as you have babelmixr2 installed, you can use the estimation routines there like "nonmem", "monolix" and "poped" by simply using nlmixr2(..., "poped"), no need to manually load babelmixr2. It also loads other utility functions like nonmem2rx and monolix2rx.

This also means, nlmixr2 itself will no longer need to be updated as frequently, the major updates will occur in either nlmixr2est, rxode2 or babelmixr2.

nlmixr2 – trying to import old models with nlmixr2fix()

Since nlmixr2 4.0 is a breaking change with a new language definition, a new function nlmixr2fix() has been introduced. This function tries to import an old saved model in the current nlmixr2 ecosystem. Often this can be done by re-parsing the original model in the current environment. This is what needed to be done to convert a nlmixr2 3.0 model to a nlmixr2 4.0 model.

# In the nlmixr2est package we have an old nlmixr2 fit from the
# nlmixr2 3.0 package

fit <- readRDS(system.file("testfit_nlmixr3.rds",
                           package="nlmixr2est"))

fit <- nlmixr2fix(fit)
## # This function is meant to load nlmixr2 fits from other versions
## # To reproduce the fit, you need to use the same version of nlmixr2
## ## ==============================
## ## nlmixr2est Session Information
## ## ==============================
## # OS: Debian GNU/Linux 12 (bookworm)
## # LAPACK: /cosbi/home/boaretti/miniconda3/envs/r_env3/lib/libopenblasp-r0.3.29.so
## # LAPACK Version: 3.12.0
## # R Version: R version 4.3.3 (2024-02-29)
## 
## 
## # Install Package version 1.3.1-13 of 'dparser'
## remotes::install_version("dparser", version = "1.3.1-13") 
## 
## # Install Package version 1.0.0 of 'lotri'
## remotes::install_version("lotri", version = "1.0.0") 
## 
## # Install Package version 0.7 of 'PreciseSums'
## remotes::install_version("PreciseSums", version = "0.7") 
## 
## # Install Package version 2.0.11 of 'rxode2ll'
## remotes::install_version("rxode2ll", version = "2.0.11") 
## 
## # Install Package version 3.0.4 of 'rxode2'
## remotes::install_version("rxode2", version = "3.0.4") 
## 
## # Install Package version 2024-3.5 of 'lbfgsb3c'
## remotes::install_version("lbfgsb3c", version = "2024-3.5") 
## 
## # Install Package version 6.0.1-12 of 'n1qn1'
## remotes::install_version("n1qn1", version = "6.0.1-12") 
## 
## # Install Package version 3.0.4 of 'nlmixr2est'
## remotes::install_version("nlmixr2est", version = "3.0.4") 
## 
## # Install Package version 3.0.0 of 'nlmixr2extra'
## remotes::install_version("nlmixr2extra", version = "3.0.0") 
## 
## # Package 'nlmixr2lib' is not installed, but known to enhance nlmixr2/babelmixr2
## 
## # Install Package version 3.0.1 of 'nlmixr2'
## remotes::install_version("nlmixr2", version = "3.0.1") 
## 
## # Package 'nonemem2rx' is not installed, but known to enhance nlmixr2/babelmixr2
## 
## # Package 'monolix2rx' is not installed, but known to enhance nlmixr2/babelmixr2
## 
## # Package 'babelmixr2' is not installed, but known to enhance nlmixr2/babelmixr2
## 
## # Package 'PopED' is not installed, but known to enhance nlmixr2/babelmixr2
## 
## # Install Package version 0.11.0 of 'PKNCA'
## remotes::install_version("PKNCA", version = "0.11.0")
## 
## # If all else fails you can try to install the version of nlmixr2 used to create the fit

This not only tries to fix the fit, it also prints out a mini session information for the fit in case you need to reproduce it (and maybe the fix doesn’t work). This was reported here, and I appreciate such reports as they make nlmixr2 more useful.

Note on Rstudio

For the newest Rstudio, nlmixr2 had some issues when completing objects. This is fixed with another release of nlmixr2/rxode2 that was released today. These also have some features that I will explore in later posts.

Posted on:
August 28, 2025
Length:
4 minute read, 790 words
Categories:
nlmixr2
See Also: