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

322

Version

0.3.1

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Bill Denney

Last Published

October 22nd, 2025

Functions in nlmixr2lib (0.3.1)

reexports

Objects exported from other packages
readModelDb

Read a model from the nlmixr2 model database
removeTransit

To remove transit compartments from the model
searchReplace

Search within a model to replace part of the model
combinePaste2

Combine two strings using a naming convention
setCombineType

Change the default combine type for the package
fakeCc

Fake blank Cc for creating PD only models
modeldb

Model library for nlmixr2
convertEmax

Convert linear effect to Emax effect
updateOncologyXenograftSimeoni2004

Update an oncology xenograft model based on Simeoni 2004
pkTrans

Change the transformation type for PK models
convertEmaxHill

Convert linear effect to Emax-Hill effect
modellib

Get the model from the model library
defaultCombine

Default combine strings
convertQuad

Convert linear elimination to quadratic elimination
removeLinesAndInis

Removes lines and inis from a model
removeDepot

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

Converts a linear effect to a log-linear effect
convertMM

Convert models from linear elimination to Michaelis-Menten elimination
convertKinR0

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

Add baseline that decays exponential with time
addCmtProp

Add a property to a compartment
addBaselineLin

Add an estimated baseline linear constant
addDirectLin

Add direct linear effect with baseline=0
addEffectCmtLin

Add effect compartment
addDirToModelDb

Add a directory to the modeldb
addEta

Add random effects to a model
addBaseline1exp

Add baseline that decays exponential with time
addBaselineConst

Add an estimated baseline constant
addDepot

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

Add an indirect response model to a PK model
addTransit

To add transit compartments to the model
addResErr

Add residual error to a model
addIndirectLin

Add linear indirect response model
addLogEstimates

Add log estimates to a model
addWeibullAbs

Converts first order absorption model to Weibull absorption model