Firas Hammami 1, Sieto Bosgra 1
1 Genmab (Utrecht, The Netherlands)
Objectives
Pharmacometric models implemented in mrgsolve [1] and rxode2 [2] are increasingly used for simulation and exploratory analyses in R [3]. However, transferring models between these engines typically requires manual recoding, which is time-consuming and may introduce unintended discrepancies. Existing tools primarily focus on one-way translation from legacy modeling languages into R-based simulation frameworks, providing limited support for direct and reversible exchange between modern simulation engines [4–6]. We developed a bidirectional converter to enable automated translation and cross-engine verification between mrgsolve and rxode2.
Methods
mrgsolve model components ($PARAM, $INIT, $CMT, $PK, $MAIN, $DES/$ODE, $CAPTURE) are parsed into an intermediate representation. Derived variables are normalized and reordered using dependency analysis, and C++-style expressions are translated into rxode2-compatible syntax. The reverse translation uses the same intermediate representation, allowing round-trip consistency checks. Simulations are compared across engines using predefined test models.
The converter was evaluated on 20 published models (10 mrgsolve and 10 rxode2) spanning multiple structural classes, including PBPK (full and minimal), one- and two-compartment, indirect response, and TMDD models (≥2 per class). In addition to structural diversity, evaluation included models with algebraic PK blocks, nonlinear clearance, target-mediated drug disposition, and time-varying dosing regimens defined via event tables. Solver tolerances and integration settings were harmonized across engines to ensure comparability. Numerical agreement was assessed by comparing simulated concentration–time profiles and derived outputs using relative differences at predefined time points. Round-trip translation (mrgsolve → rxode2 → mrgsolve and vice versa) was also performed to assess structural stability of the intermediate representation.
Results
Across the evaluated test cases, models were translated and executed without manual intervention. Simulated concentration–time profiles showed close agreement between engines in both translation directions, supporting numerical consistency across diverse pharmacometric model types. For all successfully translated models, discrepancies were within solver-level numerical precision. Round-trip evaluation confirmed preservation of parameter definitions, state variables, and model equations.
Conclusions
This bidirectional converter supports reproducible transfer and verification of pharmacometric models between mrgsolve and rxode2. By reducing manual recoding, it facilitates cross-engine model validation and flexible use of R-based simulation tools within pharmacometric workflows. Current limitations include partial support for highly customized C++ constructs and engine-specific features not directly mappable between frameworks. Ongoing development focuses on expanding coverage and automated regression testing to ensure robustness across an increasingly diverse set of pharmacometric models. Source code is available as open-source software at: https://gitlab.com/fiha1/rxode2-mrgsolve-bridge
References:
[ 1 ] Baron, K. T. (2024). mrgsolve: Simulate from ODE-Based Models. R package version 1.4.1. https://CRAN.R-project.org/package=mrgsolve
[ 2 ] Fidler, M. L., Hallow, M., Wilkins, J., & Wang, W. (2024). RxODE: Facilities for Simulating from ODE-Based Models. R package version 2.1.2. https://CRAN.R-project.org/package=RxODE
[ 3 ] R Core Team (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/
[ 4 ] Fidler, M., Delff, P., & Staples, G. (2023). nonmem2rx: Converts NONMEM Models to rxode2. R package version 0.1.3. https://CRAN.R-project.org/package=nonmem2rx
[ 5 ] Santulli, A. (2024). nonmem2mrgsolve: Automated NONMEM to mrgsolve Translation. R package version 1.2.0.
[ 6 ] Baron, K. T. (2023). Update: Validate translation from NONMEM. mrgsolve blog. https://mrgsolve.org/blog/posts/2023-update-validation.html
Reference: PAGE 34 (2026) Abstr 12003 [www.page-meeting.org/?abstract=12003]
Poster: Methodology - Other topics