Population PK/PD modelling, in R, regulatory-grade.
nlmixr2
is the open-source R stack for fitting nonlinear mixed-effects models — the workhorse of population pharmacokinetics. Same model language as
rxode2
, same fit object as a pharmacometrician expects, four estimation engines, and a deliberate path toward NONMEM / Monolix parity.
Help build the nlmixr2lib model library
Bill Denney
(Human Predictions,
nlmixr2
co-author and
nlmixr2lib
maintainer) is on a public push to re-implement every published population PK and PK/PD model that has used
nlmixr2
— about
100 of a planned 10,000+
— in a freely-available, standardised, parameter-validated form inside
nlmixr2lib
.
If you've co-authored a manuscript with a popPK or PK/PD model in
nlmixr2
— or know of regulatory drug-review documents containing one — Bill is asking you to send the paper, supplements, and (if you're allowed to share it) the model code.
Email: bdenney@humanpredictions.com · LinkedIn: billdenney · Repo: github.com/nlmixr2/nlmixr2lib . (Surfaced here April 2026 — verify the call is still active before sending, and never share material you don't have rights to redistribute.)
What it is
Pharmacometrics has been a NONMEM-shaped world for thirty years. The model file format, the QA processes, the FDA reviewer expectations — all built around it. nlmixr2 is the credible open-source alternative that keeps the modeller's mental model intact:
- A single R function defines the ini (parameters + bounds + ETA structure) and the model (ODE / linear-CMT system + residual error).
-
Differential equations
are compiled to C by
rxode2and solved with LSODA / dopri5 / Liblsoda — fast enough for SAEM with thousands of subjects. - Four estimation engines in one interface: SAEM, FOCEi, FO, and nlme — switch with a string.
- Standard popPK objects : parameter table, OFV, condition number, EBE / IPRED, NPDE, CWRES, GOF plots, VPC.
-
Bridges out
:
babelmixr2runs the same model through NONMEM or Monolix;xpose.nlmixr2feeds the fit into Xpose for diagnostics;nonmem2rx/monolix2rximport existing legacy models.
Project home: nlmixr2.org . Code: github.com/nlmixr2 . Lead author: Matthew Fidler (Novartis), with Bill Denney, Wenping Wang, Rik Schoemaker, John Harrold, and others.
A complete fit, end to end
The classic Theophylline example: one-compartment first-order absorption, between-subject variability on Ka / Cl / V, additive residual error, fit by SAEM. Lifted from
?nlmixr2est::addNpde
— runs unchanged against the version we mirror.
library(nlmixr2)
# A one-compartment, first-order absorption model.
# Parameters are population means (theta, log scale) and between-subject
# random effects (eta) on each. Residual additive error on the linear-CMT
# concentration prediction.
one.cmt <- function() {
ini({
tka <- 0.45 # log Ka
tcl <- log(c(0, 2.7, 100)) # log Cl, with bounds
tv <- 3.45; label('log V')
eta.ka ~ 0.6
eta.cl ~ 0.3
eta.v ~ 0.1
add.sd <- 0.7
})
model({
ka <- exp(tka + eta.ka)
cl <- exp(tcl + eta.cl)
v <- exp(tv + eta.v)
linCmt() ~ add(add.sd)
})
}
# Fit it. theo_sd is bundled in nlmixr2data — Theophylline single-dose, 12 subjects.
fit <- nlmixr2(one.cmt, theo_sd, est = 'saem')
# Diagnostics
fit # parameter table, OFV, condition number
plot(fit) # GOF panels via nlmixr2plot
fit <- addNpde(fit) # normalised prediction-distribution errors
fit <- addCwres(fit) # conditional weighted residuals
Install from our mirror:
install.packages("nlmixr2", repos = "https://repo.ndexr.io/cran", dependencies = TRUE)
. Compilers required (RTools on Windows, Xcode + gfortran on macOS) —
rxode2
compiles the ODE system at fit time.
Packages we mirror
Live mirror state →Umbrella package — attaches the whole stack and resolves conflicts.
Estimation engines: SAEM, FOCEi, FO, nlme, nlm wrappers, fit-object machinery.
Bootstrap, profile likelihood, covariate selection, model averaging.
GOF panels, VPCs, residual plots — the diagnostics expected on a popPK report.
Reference datasets: theo_sd / theo_md, warfarin, mavoglurant, pheno_sd, oral / bolus / infusion 1- and 2-CPT.
Library of pre-built model templates — PK, PK/PD, target-mediated, Emax.
Automated covariate selection (SCM-style stepwise).
Automated initial-estimate generation from naive-pooled fits.
PowerPoint / Word reporting — drop a fit object in, get a regulatory-style deck.
Adapter from a fit object into the Xpose diagnostic framework.
ODE solver + model language. Compiles your model to C, dosing record machinery, simulation.
Block-diagonal random-effects matrices written as
a + b ~ c(.,.,.)
.
Run the same nlmixr2 model through NONMEM or Monolix; bridge to PKNCA and PopED.
Numerically stable summation primitives used by the SAEM kernel.
Quasi-Newton optimiser used as a FOCEi fallback.
Symbolic differentiation backend for analytic gradients.
Optimal experimental design — companion package, same fit-object idiom.
Estimation engines
Switch between methods by changing one string. All are documented in
?nlmixr2AllEst
; SAEM is the default for new fits because it converges reliably on stiff popPK problems.
Robust to bad initial estimates, handles many ETAs, the workhorse for popPK. Default tuning works for most one- and two-compartment models.
NONMEM's classic — fastest on well-conditioned problems, requires reasonable inits. Same OFV as NONMEM to within numerical tolerance.
Closed-form when residual error is independent of inter-individual variability.
The original NONMEM method. Kept for compatibility with legacy submissions.
Calls
nlme::nlme
under the hood — useful when you want the closed-form Laplace approximation and reproducibility against legacy R workflows.
For non-mixed (single-subject) models or quick sanity checks. Wraps base R optimisers in the nlmixr2 fit-object idiom.
Bundled datasets
Shipped in
nlmixr2data
and used as reference examples across the documentation. Every model in
nlmixr2lib
is exercised against one of these so you can run the whole library locally.
Theophylline, single- and multiple-dose, 12 subjects. The Hello-World of popPK.
PK/PD, S-warfarin concentrations and prothrombin-complex activity. PD with effect compartment.
Mavoglurant clinical PK — irregular sampling, many subjects, real-world messy.
Phenobarbital in neonates — body weight as a covariate on clearance.
Simulated oral PK, one- and two-compartment. Linear and Michaelis-Menten variants.
Simulated IV bolus PK — clean reference cases for comparing estimators.
Simulated IV infusion PK — for testing rate / dur encoding.
Classic NLME teaching datasets — survival / failure-time, non-PK.
PD-only and parent-metabolite simulations for testing more elaborate models.
Where it lives in our mirror
Every package above is in our CRAN mirror at
s3://ndexr/cran/src/contrib/
. Verified at write time:
s3://ndexr/cran/src/contrib/nlmixr2_5.0.0.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2est_5.0.2.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2extra_5.0.0.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2plot_5.0.1.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2data_2.0.9.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2lib_0.3.2.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2auto_1.0.0.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2autoinit_1.0.0.tar.gz
s3://ndexr/cran/src/contrib/nlmixr2rpt_0.2.2.tar.gz
s3://ndexr/cran/src/contrib/xpose.nlmixr2_0.4.1.tar.gz
s3://ndexr/cran/src/contrib/rxode2_5.0.2.tar.gz
s3://ndexr/cran/src/contrib/lotri_1.0.3.tar.gz
s3://ndexr/cran/src/contrib/babelmixr2_0.1.11.tar.gz
s3://ndexr/cran/src/contrib/PopED_0.7.0.tar.gz
s3://ndexr/cran/src/contrib/PreciseSums_0.7.tar.gz
s3://ndexr/cran/src/contrib/n1qn1_6.0.1-14.tar.gz
s3://ndexr/cran/src/contrib/symengine_0.2.11.tar.gz
Live coverage at
repo.ndexr.io
(filter
nlmixr2
,
rxode2
,
babelmixr2
in the package column).