Features

ferx implements the same statistical methodology as NONMEM, Monolix, and Pumas, in an open-source Rust engine with exact analytic gradients. This page summarizes what the engine can do. For full detail see the ferx-core book (engine, CLI, DSL) and the ferx-r book (R workflow).

Maturity labels — stable, beta, experimental — follow the ferx-core feature maturity page.


Estimation methods

Method Notes Maturity
FOCE / FOCEI First-Order Conditional Estimation, with or without interaction — the PopPK gold standard stable
SAEM Stochastic Approximation EM — robust on complex / poorly-identified models stable
Variational Inference (VI) Gradient-based ELBO maximization with full_rank / mean_field posteriors — fast approximate fit; chain into imp/laplace for a marginal likelihood beta
Gauss-Newton (BHHH) Fast outer optimizer with Levenberg–Marquardt damping; gn and a gn_hybrid GN+FOCEI polish beta
Importance Sampling (IMP) Exact marginal likelihood by Monte-Carlo integration beta
IMPMAP MAP-anchored importance sampling beta
SIR Sampling Importance Resampling — posterior parameter uncertainty beta
Bayesian (MCMC) Full Markov-chain posterior sampling experimental

Methods can be chained (e.g. method = [saem, focei]) — a robust global pass followed by a FOCEI polish.

Outer optimizers

bobyqa (default, derivative-free trust-region) · slsqp · built-in bfgs · lbfgs / nlopt_lbfgs · mma · Newton trust_region · Gauss-Newton (BHHH). Optional CRS2-LM gradient-free global pre-search (global_search) for poorly-identified models.

Gradients

  • Analytic Dual2 sensitivities — fast, exact closed-form gradients for in-scope models (FOCE/FOCEI, SAEM/Bayes HMC)
  • Finite differences — used for ODE/SDE, LTBS, expression scaling, and time-varying covariates
  • Covariance via inverse Hessian (R⁻¹), score cross-product (S⁻¹), or Huber–White sandwich (R⁻¹SR⁻¹), mirroring NONMEM $COVARIANCE

Structural models

  • Analytical PK — one-, two-, three-compartment (IV bolus, infusion, oral), with numerical-stability guarantees
  • ODE models — Dormand–Prince RK45 adaptive integrator for custom kinetics (e.g. Michaelis–Menten), with configurable tolerances
  • Built-in absorption — first-order, transit-compartment chains
  • SDE / diffusion — Extended Kalman Filter path via the [diffusion] block (experimental)
  • Neural networks — MLP covariate mapper (DCM) and neural-ODE components (experimental)

Random effects & error

  • IIVomega random effects, diagonal or block (correlated ETAs)
  • IOV — inter-occasion variability via kappa / block_kappa (FOCE/FOCEI and SAEM)
  • Error models — additive, proportional, combined, log-transform-both-sides (LTBS)
  • Multi-endpoint — per-compartment error for joint PK/PD

Covariates

  • Time-constant and time-varying, with automatic detection
  • Continuous and categorical, conditional (if/else) covariate effects
  • Mu-referencing (automatic) for SAEM compatibility and faster FOCE convergence

Data & dosing

  • Reads standard NONMEM-format CSV directly
  • Multiple dosing, ADDL, steady-state doses (SS=1), infusions, mid-record resets
  • BLOQ — Beal M3 likelihood for below-LLOQ observations
  • Data selection and derived columns in the model file

Model search & automatic model development

Pharmpy’s amd tool chain, in the engine and callable from R.

Tool Decides Maturity
modelsearch structural model — absorption, peripherals, transits, lag time beta
iivsearch which parameters carry an eta, and which etas are correlated beta
iovsearch which parameters carry inter-occasion variability beta
ruvsearch residual-error model, by likelihood-ratio test beta
covsearch covariate effects, by SCM forward / forward-backward beta
allometry allometric scaling on body size beta
globalsearch structure and covariates together, as one grid — exhaustive or genetic algorithm beta
amd the stepwise pipeline, each step starting from what the last one selected beta
  • Search spaces are written in MFL (Pharmpy’s Model Feature Language), so a space is portable between the two tools
  • A strictness gate applies to every candidate, and the termination status and the gate verdict are columns of every table with one row per fitted model — a model that did not converge or came back ill-conditioned cannot win a step silently
  • Runs are resumable, parallel across candidates, and written to disk as CSV, so a run driven from the CLI reads back in R and vice versa
  • Ranking on OFV, AIC, the four BIC variants, or pyDarwin-style penalized fitness

See Example: Model search and automatic model development.

Initialization & diagnostics

  • NCA-based starting values (inits_from_nca) — AUC, terminal-slope, Wagner–Nelson Ka, biexponential peeling
  • CWRES and NPDE simulation-based diagnostics.
  • Simulations for VPC, with propensity-score matching for adaptive treatments
  • Multi-start fitting, optimizer trace output

Performance

  • Per-subject computations parallelized across cores (Rayon)
  • Parameters internally transformed for unconstrained optimization (log θ/σ, Cholesky Ω) to guarantee positive-definiteness
  • Engine usable three ways with identical results: the ferx CLI, the ferx-r package, or as a Rust library
  • Benchmarks versus NONMEM and nlmixr2 coming soon