nlmixr is an R package for fitting general dynamic models, pharmacokinetic (PK) models and pharmacokinetic-pharmacodynamic (PKPD) models in particular, with either individual data or population data. The nlme and SAEM estimation routines can be accessed using a universal user interface (UUI), that provides universal model and parameter definition syntax and results in a fit object that can be used as input into the Xpose package. Running nlmixr using the UUI is described in this vignette.

Under the hood nlmixr has five main modules:

1. dynmodel() and its mcmc cousin dynmodel.mcmc() for nonlinear dynamic models of individual data;
2. nlme_lin_cmpt()for one to three linear compartment models of population data with first order absorption, or i.v. bolus, or i.v. infusion using the nlme algorithm;
3. nlme_ode() for general dynamic models defined by ordinary differential equations (ODEs) of population data using the nlme algorithm;
4. saem_fit for general dynamic models defined by ordinary differential equations (ODEs) of population data by the Stochastic Approximation Expectation-Maximization (SAEM) algorithm;
5. gnlmm for generalized non-linear mixed-models (possibly defined by ordinary differential equations) of population data by the adaptive Gaussian quadrature algorithm.

A few utilities to facilitate population model building are also included in nlmixr.

Documentation can be found at https://nlmixrdevelopment.github.io/nlmixr/, and we maintain a comprehensive and ever-growing guide to using nlmixr at our bookdown site.

More examples and the associated data files are available at https://github.com/nlmixrdevelopment/nlmixr/tree/master/vignettes.

We recommend you have a look at RxODE, the engine upon which nlmixr depends, as well as xpose.nlmixr, which provides a link to the seminal nonlinear mixed-effects model diagnostics package xpose, and shinyMixR, which provides a means to build a project-centric workflow around nlmixr from the R command line and from a streamlined shiny front-end application. Members of the nlmixr team also contribute to the ggPMX, xgxr and pmxTools packages. For PKPD modeling (with ODE and dosing history) with Stan, check out Yuan Xiong’s package PMXStan.

## Installation

When on CRAN, you can install the released version of nlmixr from CRAN with:

install.packages("nlmixr")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("nlmixrdevelopment/nlmixr")