Learn R Programming

nlmixr2lib

This is a model library for nlmixr2. The package allows a few ways to interact with the model library:

# See all available models
modellib()
# Load the "PK_1cmt" model
modellib(name="PK_1cmt")
# Switch residual error to additive
modellib(name="PK_1cmt", reserr = "addSd")
# Add inter-individual variability on ka and v and switch residual error to
# additive and proportional
modellib(name="PK_1cmt", eta = c("lka", "lv"), reserr = c("addSd", "propSd"))

Modifying models by piping

You may also modify any model from the library (or your own models) with a piping interface. The code below adds inter-individual variability on ka and v and then switches residual error to additive and proportional.

modellib(name="PK_1cmt") |>
  addEta(c("lka", "lv") |>
  addResErr(c("addSd", "propSd"))

Possible extensions

The modellib function is set-up in way that it can be easily extended and used in other applications. A possible extension could be implementation in a shiny app. An app can be created to easily add new models to the model library database (curated?), and directly make these models available for other users. I believe there can be added value in having a base model library that can be easily extended by the community this way.

Copy Link

Version

Install

install.packages('nlmixr2lib')

Monthly Downloads

308

Version

0.3.2

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Bill Denney

Last Published

January 18th, 2026

Functions in nlmixr2lib (0.3.2)

addTransit

To add transit compartments to the model
readModelDb

Read a model from the nlmixr2 model database
modeldb

Model library for nlmixr2
fakeCc

Fake blank Cc for creating PD only models
removeTransit

To remove transit compartments from the model
convertMM

Convert models from linear elimination to Michaelis-Menten elimination
convertLogLin

Converts a linear effect to a log-linear effect
addWeibullAbs

Converts first order absorption model to Weibull absorption model
searchReplace

Search within a model to replace part of the model
reexports

Objects exported from other packages
modellib

Get the model from the model library
pkTrans

Change the transformation type for PK models
removeDepot

To convert from first order oral absorption to IV/Intravenous
removeLinesAndInis

Removes lines and inis from a model
defaultCombine

Default combine strings
setCombineType

Change the default combine type for the package
updateOncologyXenograftSimeoni2004

Update an oncology xenograft model based on Simeoni 2004
addBaselineConst

Add an estimated baseline constant
addEta

Add random effects to a model
addDirToModelDb

Add a directory to the modeldb
addBaseline1exp

Add baseline that decays exponential with time
addEffectCmtLin

Add effect compartment
addDepot

To convert from infusion/intravenous administration to first-order oral absorption
addCmtProp

Add a property to a compartment
addDirectLin

Add direct linear effect with baseline=0
addIndirectLin

Add linear indirect response model
addIndirect

Add an indirect response model to a PK model
addBaselineExp

Add baseline that decays exponential with time
addBaselineLin

Add an estimated baseline linear constant
addLogEstimates

Add log estimates to a model
addResErr

Add residual error to a model
convertKinR0

Convert a kin/kout indirect response model to R0 and kout
convertEmaxHill

Convert linear effect to Emax-Hill effect
convertQuad

Convert linear elimination to quadratic elimination
combinePaste2

Combine two strings using a naming convention
convertEmax

Convert linear effect to Emax effect