nlmixr2, rxode2 and NONMEM: interchangeable models using babelmixr2 and nonmem2rx
Matthew Fidler (1, 8), William S. Denney (2, 8), John Harrold (7, 8), Richard Hooijmakers (4, 8), Rik Schoemaker (3, 8), Max Taubert(1, 8), Mirjam Trame (5, 8), Theodoros Papathanasiou (6, 8), Justin Wilkins (3, 8)
(1) Novartis Pharmaceuticals, USA, (2) Human Predictions, USA, (3) Occams, The Netherlands, (4) LAP&P Consultants, The Netherlands, (5) Certara Strategic Consulting, USA, (6) GSK, Switzerland, (7) Seagen, (8) The nlmixr2 team
Introduction: nlmixr2 (www.nlmixr2.org) is an open-source R package, freely available on CRAN[1] and GitHub[2]. It builds on rxode2[3], an R package for simulation of nonlinear mixed effect models using ordinary differential equations (ODEs), providing an efficient and versatile way to specify pharmacometric models and dosing scenarios, with rapid execution due to compilation in C. NONMEM[4] is a commercial tool for non-linear mixed effects modeling and has been used in industry, academia and hospitals since 1989.
Since nlmixr2, rxode2 and NONMEM perform similar tasks, tools to convert between the different model specification formats can be helpful for pharmacometricians trying to implement NONMEM models in rxode2, or trying to run an nlmixr2 model in NONMEM.
Objectives:
Create tools to allow bidirectional interoperability with nlmixr2/rxode2 and NONMEM:
- Create a tool to run nlmixr2 models in NONMEM, and automatically ensure the translation is accurate
- Create a tool to import NONMEM models into rxode2/nlmixr2, and automatically ensure the translation is accurate
Methods:
The R package babelmixr2[5] takes R functions set up as rxode2/nlmixr2 models and uses the built-in R parser to navigate the function’s parsing tree. With this information, babelmixr2 generates a mu-referenced NONMEM block for $PK, or $PRED, and generates the remaining code for $DES and $ERROR. The data is also translated from rxode2/nlmixr2-compatible data to NONMEM compatible format. Once the code and data are generated, NONMEM is used to run the model . After NONMEM has completed its run, the corresponding parameter estimates are read in (including ETAs), and nlmixr2 calculates residuals and predictions itself. This allows the individual predictions and population predictions to be compared between NONMEM and nlmixr2 and generates a validated nlmixr2/rxode2 model to perform simulations.
The R package nonmem2rx[6] takes NONMEM output and creates an rxode2 model function that represents the NONMEM control stream. It reads the final parameter estimates and uses C-based parsing in dparser[7] to create an rxode2 model without nlmixr2-compatible residual error structure specified [PE1] or possibly even a nlmixr2-compatible model with a fully specified residual error structure specified. With the population and individual parameters present, nonmem2rx validates the population (PRED) and individual fits (IPRED) and captures all the information needed to simulate with uncertainty in rxode2.
We will demonstrate the utility of these tools with model case studies. For tool validation, we tried the nlmixr2 example models in NONMEM, some produced rounding errors and invalid covariance steps in NONMEM.
Results:
Since babelmixr2 and nlmixr2 could read these models, the babelmixr2 tool gave clues why NONMEM had been experiencing problems reaching convergence which were not readily available from NONMEM itself. While a surprising finding, this means that using babelmixr2 to develop NONMEM models can save valuable model debugging time.
All of the Perl-speaks-NONMEM[8] test suite models were successfully imported into rxode2 with the exception of generalized linear models or models missing key elements (like $PK blocks, or missing parameters in the output file). On all external models tested, the nonmem2rx model translation validated against the NONMEM outputs meaning the translated models successfully reproduced the NONMEM output.
Conclusions:
These results show that these tools can be used to speed up model development time while instantaneously knowing how well the translation tools are performing relative to one another. Additionally using rxode2 to generate simulations for VPCs and clinical trial simulations without another step, knowing if the translation works immediately is a great convenience for pharmacometricians.
References:
[1] https://cran.r-project.org/package=nlmixr2
[2] https://github.com/nlmixr2/nlmixr2
[3] https://github.com/nlmixr2/rxode2
[4] Beal SL et al. 1989-2011. NONMEM Users Guides. Icon Development Solutions, Ellicott City, Maryland, USA.
[5] https://github.com/nlmixr2/babelmixr2
[6] https://github.com/nlmixr2/nonmem2rx
[7] https://github.com/nlmixr2/dparser-R
[8] https://uupharmacometrics.github.io/PsN/