'nlme_ode' fits a mixed-effect model described using ordinary differential equation (ODEs). The ODE-definition follows RxODE syntax. Specification of fixed effects, random effects and initial values follows the standard nlme notations.

nlme_ode(
  dat.o,
  model,
  parModel,
  parTrans,
  response,
  responseScaler = NULL,
  transitAbs = FALSE,
  atol = 1e-08,
  rtol = 1e-08,
  maxsteps = 5000,
  hmin = 0,
  hmax = NA_real_,
  hini = 0,
  maxordn = 12,
  maxords = 5,
  debugODE = FALSE,
  mcCores = 1,
  ...
)

nlmeOde(
  dat.o,
  model,
  parModel,
  parTrans,
  response,
  responseScaler = NULL,
  transitAbs = FALSE,
  atol = 1e-08,
  rtol = 1e-08,
  maxsteps = 5000,
  hmin = 0,
  hmax = NA_real_,
  hini = 0,
  maxordn = 12,
  maxords = 5,
  debugODE = FALSE,
  mcCores = 1,
  ...
)

Arguments

dat.o

data to be fitted

model

a string containing the set of ordinary differential equations (ODE) and other expressions defining the changes in the dynamic system. For details, see the sections “Details” and “RxODE Syntax” below.

parModel

list: model for fixed effects, randoms effects and initial values.

parTrans

function: calculation of PK parameters

response

names of the response variable

responseScaler

optional response variable scaler. default is NULL

transitAbs

boolean indicating if this is a transit compartment absorption

atol

a numeric absolute tolerance (1e-8 by default) used by the ODE solver to determine if a good solution has been achieved; This is also used in the solved linear model to check if prior doses do not add anything to the solution.

rtol

a numeric relative tolerance (1e-6 by default) used by the ODE solver to determine if a good solution has been achieved. This is also used in the solved linear model to check if prior doses do not add anything to the solution.

maxsteps

maximum number of (internally defined) steps allowed during one call to the solver. (5000 by default)

hmin

The minimum absolute step size allowed. The default value is 0.

hmax

The maximum absolute step size allowed. When hmax=NA (default), uses the average difference + hmaxSd*sd in times and sampling events. The hmaxSd is a user specified parameter and which defaults to zero. When hmax=NULL RxODE uses the maximum difference in times in your sampling and events. The value 0 is equivalent to infinite maximum absolute step size.

hini

The step size to be attempted on the first step. The default value is determined by the solver (when hini = 0)

maxordn

The maximum order to be allowed for the nonstiff (Adams) method. The default is 12. It can be between 1 and 12.

maxords

The maximum order to be allowed for the stiff (BDF) method. The default value is 5. This can be between 1 and 5.

debugODE

a logical if debugging is enabled

mcCores

number of cores used in fitting (only for Linux)

...

additional nlme options

Value

nlmixr nlme fit

Details

The ODE-based model specification may be coded inside a character string or in a text file, see Section RxODE Syntax below for coding details. An internal RxODE compilation manager object translates the ODE system into C, compiles it, and dynamically loads the object code into the current R session. The call to RxODE produces an object of class RxODE which consists of a list-like structure (closure) with various member functions (see Section Value below).

RxODE Syntax

An RxODE model specification consists of one or more statements terminated by semi-colons, ‘;’, and optional comments (comments are delimited by # and an end-of-line marker). NB: Comments are not allowed inside statements.

A block of statements is a set of statements delimited by curly braces, ‘{ ... }’. Statements can be either assignments or conditional if statements. Assignment statements can be either “simple” assignments, where the left hand is an identifier (i.e., variable), or special “time-derivative” assignments, where the left hand specifies the change of that variable with respect to time e.g., d/dt(depot).

Expressions in assignment and ‘if’ statements can be numeric or logical (no character expressions are currently supported). Numeric expressions can include the following numeric operators (‘+’, ‘-’, ‘*’, ‘/’, ‘^’), and those mathematical functions defined in the C or the R math libraries (e.g., fabs, exp, log, sin). (Note that the modulo operator ‘%’ is currently not supported.)

Identifiers in an RxODE model specification can refer to:

  • state variables in the dynamic system (e.g., compartments in a pharmacokinetic/pharmacodynamic model);

  • implied input variable, t (time), podo (oral dose, for absorption models), and tlast (last time point);

  • model parameters, (ka rate of absorption, CL clearance, etc.);

  • others, as created by assignments as part of the model specification.

Identifiers consist of case-sensitive alphanumeric characters, plus the underscore ‘_’ character. NB: the dot ‘.’ character is not a valid character identifier.

The values of these variables at pre-specified time points are saved as part of the fitted/integrated/solved model (see eventTable, in particular its member function add.sampling that defines a set of time points at which to capture a snapshot of the system via the values of these variables).

The ODE specification mini-language is parsed with the help of the open source tool DParser, Plevyak (2015).

Author

Wenping Wang, Mathew Fidler

Examples

# \donttest{
library(nlmixr)
ode <- "
d/dt(depot) =-KA*depot;
d/dt(centr) = KA*depot - KE*centr;
"
mypar <- function(lKA, lKE, lCL)
{
    KA=exp(lKA)
    KE=exp(lKE)
    CL=exp(lCL)
    V = CL/KE
}

specs <- list(fixed=lKA+lKE+lCL~1,
     random = pdDiag(lKA+lCL~1),
     start=c(lKA=0.5, lKE=-2.5, lCL=-3.2))

fit <- nlme_ode(theo_md, model=ode, par_model=specs, par_trans=mypar,
     response="centr", response.scaler="V",control=nlmeControl(pnlsTol=0.9))
#>  
# }