Mlxtran: The Model Coding Language For - Monolix
Mlxtran: The Model Coding Language For - Monolix
- Monolix1
- MlxPlore
- simulix
March 2014 •
1
Mlxtran is the model coding language used by Monolix, MlxPlore and simulix. This document presents
Mlxtran features for Monolix.
CONTENTS
Contents
3.4 Mixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.7 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.9 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.4.2 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7 Miscallenous 38
7.1 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7.3 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
A model script for Monolix focuses on the structural model and the computation tasks
built on top of it. The structural model is a parametric model. It defines the computation of
the predictions. Predictions form a deterministic function of usual and random variables. They
are defined at the individual level.
Some keywords manage the complexity of the deterministic computations. An ODE initial
value problem can be defined. The function pkmodel and the block PK: can be included to
define pharmacokinetics with domain-specific keywords.
INPUT: The Mlxtran script can access variables from other scripts, data, or
graphical user interface.
PK: For PK models, the structural model can include a block PK: (optional).
The block INPUT: declares some variables that were defined outside of the current script,
and enables them. They come from the project or the data. This block also declares the types of
these variables. The keyword parameter declares the input individual parameters. regressor
declares the input regression values.
Example:
INPUT:
parameter = {ka, V, Cl}
regressor = {Weight, Age}
The block EQUATION: contains mathematical equations. Several keywords allow to describe
complex or domain-specific equations. Remember that the model description is a declarative
language, not an imperative language. Therefore these equations are mathematical definitions
rather than a series of instructions.
Example:
INPUT:
parameter = {a, b, c}
EQUATION:
d = -a^2 * (exp(b)+3)/c
A system of ODE (Ordinary Differential Equations) can be defined in the block EQUATION:.
The main independent variable t is the differentiation variable. The components of its
solution can be referenced as any other variable. The problem is defined by the equations of the
derivatives, the initial time point and the initial values of the components. The stiffness of the
problem can be defined. The problem accepts input source terms, which allows to bring some
discontinuity into the defined derivatives.
Derivatives The keywords prefixed with ddt_ in front of a variable name, as ddt_a and
ddt_b, define the derivatives of an ODE system. The variable names denote the components
of the solution. These variables are defined at the whole section level through their derivatives.
The derivatives themselves aren’t variables but keywords, and cannot be referenced by other
equations nor be defined under a conditional statement.
The structure of the ODE system is part of the structure of the whole model and cannot
be conditional. Adding conditional intermediate variables for the values of the derivatives easily
provides this flexibility.
The derivatives of the ODE system cannot be referenced by other equations, but they can
be extended with some domain-specific keywords into a custom dynamic system. Such keywords
are available for the pharmacokinetics, for example: in this case the ODE system includes a
derivative for the quantity whose dynamic is also ruled by a specific keyword, as a dose absorp-
tion. This results in a complete system where the final derivative of the ODE component is the
derivative provided as an equation within the initial ODE system augmented by the input deriva-
tive translating the dynamics from the domain-specific keyword. The example on the custom
elimination in section 5.5 illustrates this feature.
Initial values The keyword t0 defines the initial point of an ODE problem. More precisely,
the components are defined for t ≤ t0 as the equations provided for the initial values, and for
t > t0 they are defined as the solution of the ODE system with initial values fixed at t = t0. By
default, t0 is the first time point defined in the MlxPlore project.
The keyword t0 defines the initial time point of an ODE system, while the variable names
with suffix _0 define the initial values of the system, i.e. the values of its components for t ≤ t0.
Then, for t > t0, the components of the system are defined as the solution of the ODE system.
By default, an initial value is null.
Example:
t0 = 5
A_0 = r/k
B_0 = 0
ddt_A = r - c*A*B - k*A
ddt_B = c*A*B - d*B
Type of ODE system The keyword odeType defines the type of the ODE system. The
problem can be indicated as being stiff, non-stiff, or linear. By default, the problem is viewed as
non-stiff.
Example:
odeType = stiff
; Other possible values:
; odeType = nonStiff
; odeType = linear
Source terms An ODE problem accepts input source terms. They can be defined into the
project, within a data set, or using the keyword depot. Each input source term defines an
instantaneous shift of the value of its target ODE component by a given amount. A zero order,
first order, or transit process can also be defined with depot.
A system of DDE (Delayed Differential Equations) can be defined in the bloc EQUATION:.
A DDE system is defined as an ODE system, except that some derivatives rely on the value of
a component at a previous time. These delayed components are defined using a specific keyword.
Also, the initialization of the system relies on an history function to define the trajectory in the
past, instead of a vector of initial values.
Delayed components The keyword delay defines a delayed component. It takes two argu-
ments: the name of the component and the value of the delay. The delay must be constant on
occasions. It is available only directly within the equation of a derivative.
Example:
t0 = 5
A_0 = r/k
B_0 = 0
ddt_A = r - c*A*B - k*A
ddt_B = c*A*B - delay(A, d)
History function The components of the history function use the same syntax as the initial
values of an ODE system.
Example:
t0 = 5
A_0 = r/k
B_0 = 0
ddt_A = r - c*A*B - k*A
ddt_B = c*A*B - d*B
Type of DDE system The same method is used for all DDE systems. The keyword odeType
is only relevant for ODE systems.
Limitations An observation for repeated time to event cannot be combined with a DDE
system.
3.4 Mixtures
Example:
EQUATION:
f = bsmm(f1, p, f2, 1-p)
;f = wsmm(f1, p, f2, 1-p)
The following usual mathematical functions are available. They perform scalar operations,
either on integers or real numbers. These operations are performed using a double precision for
their floating-point implementation.
Function Syntax Remarks
Smallest value min(a, b)
Largest value max(a, b)
Absolute value abs(a)
Square root sqrt(a)
Exponential exp(a)
Natural logarithm log(a)
Common logarithm log10(a)
Logistic function logit(a)
Inverse of the logistic function invLogit(a)
Probit function probit(a) Aliases: norminv, qnorm.
Normal CDF normcdf(a) Alias: pnorm.
Sine sin(a)
Cosine cos(a)
Tangent tan(a)
Inverse sine asin(a)
Inverse cosine acos(a)
Inverse tangent atan(a)
Hyperbolic sine sinh(a)
Hyperbolic cosine cosh(a)
Hyperbolic tangent tanh(a)
Four quadrant inverse tangent atan2(a, b)
Logarithm of gamma function gammaln(a) Alias: lgamma.
Downward rounding floor(a)
Upward rounding ceil(a)
Factorial factorial(a)
Logarithm of factorial factln(a) Alias: lfactorial.
Remainder after division rem(a)
The probability density function (pdf) and cumulative distribution function (cdf) are avail-
able for continuous distributions.
(ln(x)−µ)2
Log-normal lognpdf logncdf µ[= 0], σ[= 1] [0; +∞[ xσ
1
√
2π
e− 2σ 2
(x−µ)2
Normal normpdf normcdf µ[= 0], σ[= 1] R √1 e− 2σ 2
σ 2π
x2
xe− 2σ2
Rayleigh raylpdf raylcdf σ[= 1] [0; +∞[
2
σ
Γ k+1
2 t2
− k+1
2
Student’s t tpdf tcdf k R √ 1+ k
kπ Γ k2
1
Uniform unifpdf unifcdf a[= 0], b[= 1] [a; b]
b−a
x k
k x k−1 −( λ )
Weibull wblpdf wblcdf k, λ[= 1] [0; +∞[ λ λ e
3.7 Operators
Arithmetic operators The arithmetic operators perform operations on real numbers. These
operations are performed using a double precision for their floating-point implementation. The
specific operations on integers have a function call syntax, e.g. factorial.
Logical operators The logical operators perform operations on boolean values. They appear
as conditions within conditional statements.
Operator Syntax Remarks
Negation ~a Another syntax is !a.
Or a | b Another syntax is a || b.
And a & b Another syntax is a && b .
Relational operators The relational operators perform operations on real numbers. These
operations are performed using a double precision for their floating-point implementation.
Operator Syntax Remarks
Equal to a == b
Not equal to a ~= b Another syntax is a != b.
Greater than a > b
Less than a < b
Greater than or equal to a >= b
Less than or equal to a <= b
A conditional statement can be built by combining the keywords if, elseif, else and
end. Several elseif keywords can be chained, and the conditions are exclusive in sequence. A
default value can be provided using the keyword else, but also as a simple definition preceding
the conditional structure. An unspecified conditional value is null. The enclosed variables are
not local variables, which means that a variable with remaining conditional definitions is still
incomplete and cannot be referenced into another definition, even under the same condition.
Only intermediate variables can be defined within conditional statements, the structure of
the model cannot depend on such conditions. The derivatives of an ODE, or the PK elements of
a prediction sub-model, cannot be defined within conditionals, for example. Adding conditional
intermediate variables for the values of the derivatives, or the parameters of the PK element,
easily provides this flexibility.
Example:
T0=5
if t<T0
f=A
else
f= A*exp(-k*(t-T0))
end
3.9 Examples
Conditional derivatives for an HCV Neumann model The prediction of interest is the
logarithm of the viral load for a Hepatitis C viral (HCV) model, with a start and stop of
treatment.
T C |t=0 = δc/βp
IC |t=0 = (s − d T C)/δ
V L |t=0 = p IC/c
INPUT:
parameter = {s, d, beta, delta, p, c, eta, epsilon}
regressor = T_end
EQUATION:
odeType = stiff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compute the initial values
t0 = 0
TC_0 = delta*c/(beta*p)
IC_0 = (s-d*TC_0)/delta
VL_0 = p*IC_0/c
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if t > T_end
coeff = 0
else
coeff = 1
end
eta_cond = coeff*eta
eps_cond = coeff*epsilon
LVL = max(log10(VL), 0)
OUTPUT:
output = LVL
A system of several ODE can be defined in the block EQUATION:. The ODE system is defined
as stiff using odeType. Here, ddt_TC, ddt_IC and ddt_VL are the derivatives with respect to
time t. TC_0, IC_0 and VL_0 are the initial values of the system, i.e. the values of TC, IC and
VL at time t0 (they are constant before t0). The conditional derivatives are handled by adding
the conditional statement for coeff. The component VL of the ODE system is used to define
the prediction of interest.
DDE for a SEIRS epidemic model The model solved is the SEIRS epidemic model of Genik
& van den Driessche, example 4.4.1 of [?] defined by:
N (t) = S(t) + E(t) + I(t) + R(t)
S(t)I(t)
Ṡ(t) = A(t) − S(t) − λ + γI(t − τ ) exp(−dτ ),
N (t)
S(t)I(t) λS(t − ω)I(t − ω) exp(−dω)
Ė(t) = λ − dE(t) − , (1)
N (t) N (t − ω)
˙ = −(γ + + d)I(t) + λS(t − ω)I(t − ω) exp(−dω) ,
I(t)
N (t − ω)
Ṙ(t) = γI(t) − dR(t) − γI(t − τ ) exp(−dτ ), t ∈ [0, 350].
INPUT:
parameter = {A,d,lambda,gamma,epsilon,omega,tau}
EQUATION:
t0 = 0
S_0 = 15
E_0 = 0
I_0 = 2
R_0 = 3
N = S + E + I + R
OUTPUT:
output = {S, E, I, R}
DDE for an Interleukin-2 model The model solved is the Interleukin-2 model studied by
Baker et al. in [?] and defined by:
16
14
E(t)
12
I(t)
10 R(t)
S(t)
8
−2
0 50 100 150 200 250 300 350
time (days)
Figure 1: The SEIRS epidemic model of Genik & van den Driessche, example 4.4.1 of [?]
I2 (t)
I˙2 (t) = −αI2 I2 (t) − nI2 bT I2 ∗ + 1 TA (t),
I (t)/I
2
2
I2 (t − τD )
ṪA (t) = ρbT I2 TA (t − τD )
I2 (t − τD )/I2∗ + 1
I2 (t − τS )
−bT I2 TA (t − τS ) − αAR TA (t),
I2 (t − τS )/I2∗ + 1 (2)
I2 (t − τS )
ṪD (t) = bT I2
TA (t − τS )
I2 (t − τS )/I2∗ + 1
I2 (t − τD )
−bT I2 ∗ TA (t − τD ),
I 2 − τD )/I2 + 1
(t
ṪR (t) = αAR TA (t) − αR TR (t), t ∈ [0, 100].
The model (2) is compared in [?] with an ODE model of the same phenomenon, defined as
follows:
I2 (t)
I˙2 (t) = −αI2 I2 (t) − nI2 bT I2 TA (t),
I2 (t)/I2∗ + 1
Ṫ (t) = ρb T (t) − b I2 (t)
A D D T I2 TA (t) − αAR TA (t),
I2 (t)/I2∗ + 1 (3)
I 2 (t)
ṪD (t) = bT I2 TA (t) − bD TD (t),
I2 (t)/I2∗ + 1
ṪR (t) = αAR TA (t) − αR TR (t), t ∈ [0, 100].
INPUT:
parameter = {alphaI2,alphaR,alphaAR,nI2,bTI2,starI2,tauD,tauS,rho}
EQUATION:
t0 = 0
I2_0 = 2e10
TA_0 = 3.8e5
TD_0 = 0
TR_0 = 1.2e5
TV = TA + TD + TR
OUTPUT:
output = TV
6
x 10
4
3.5
3
PHA−blast growth per ml
2.5
0.5
0
0 20 40 60 80 100 120
time (hrs)
DDE for a PKPD model of unperturbed and perturbed arthritis development The
model solved is the PKPD model for unperturbed and perturbed arthritis development of Koch
et al. [?] defined by:
k1
Ġ(t) = k3 − σ1 exp (−σ2 c(t)) + σ3 c(t)G(t) − 1 − exp (−k2 t) G(t),
k2
˙ = k4 G(t) − k4 G(t − τ ),
I(t)
Ḋ(t) = k4 G(t − τ ) − k5 D(t), t ∈ [0, 35].
The parameter c(t) is given by a PK data dose of a standard linear 2-compartment i.v.
model. The equation used in [?] is
c(t) = dose Aiv exp(−αt) + Biv exp(−βt) .
However, c(t) can be computed, knowing the volumes V1 , V2 of the compartments, the parameters
α, β, CL, the dose (amount in Mlxtran) and the administration times of the PK model.
INPUT:
EQUATION:
t0 = 0
I_0 = 2.52
D_0 = 0
G_0 = a*exp(b*t)
K12 = alpha*beta*V2/CL
K21 = alpha*beta*V1/CL
C = pkmodel(k12=K12,k21=K21,V=V1,Cl=CL)
OUTPUT:
output = {G, I, D}
D(t)
5
G(t)
I(t)
4
0
0 5 10 15 20 25 30 35
time (days)
Figure 3: The PKPD model for unperturbed and perturbed arthritis development of Koch et al.
[?], Experiment A with the dosing schedules: 10 mg/kg on day 1, 8, 15.
The block OBSERVATION: defines random variables modelling observations of the structural
model. Typically, they will be used as model outputs, under the block OUTPUT:. An observation
variable can be discrete or continuous. Its actual type and corresponding keywords and equations
are set as follows:
Example:
OBSERVATION:
Concentration = {type=continuous, prediction=Cc, errorModel=proportional}
In the following, most of the keywords and equations are mandatory, so the optional fields
are stated.
An observation variable for count data is defined using the type count. Its additional fields
are:
• P(Y=k): Probability of a given count value k, for the observation named Y. k is a natural
number. A transformed probability can be provided instead of a direct one. The transfor-
mation can be log, logit, or probit. The bounded variable k supersedes in this scope
any predefined variable k.
Example:
OBSERVATION:
Y = {
type = count
log(P(Y=k)) = -lambda + k*log(lambda) - factln(k)
}
An observation variable for ordered categorical data is defined using the type categorical.
Its additional fields are:
• categories: List of the available ordered categories. They are represented by increasing
successive integers.
• P(Y=i): Probability of a given category integer i, for the observation named Y. A trans-
formed probability can be provided instead of a direct one. The transformation can be log,
logit, or probit. The probabilities are defined following the order of their categories.
They can be provided for events where the category is a boundary, instead of an exact
match. All boundaries must be of the same kind. Such an event is denoted by using a
comparison operator. When the value of a probability can be deduced from others, its
definition can be spared.
Example:
OBSERVATION:
level = {
type = categorical
categories = {0, 1, 2, 3}
logit(P(level<=0)) = th1
An observation variable for ordered categorical data modelled as a Markov chain is defined
using the type categorical, along with the dependence definition Markov. Its additional
fields are:
• categories: List of the available ordered categories. They are represented by increasing
successive integers. It is defined right after type.
• P(Y_1=i): Initial probability of a given category integer i, for the observation named Y.
This probability belongs to the first observed value. A transformed probability can be
provided instead of a direct one. The transformation can be log, logit, or probit. The
probabilities are defined following the order of their categories. They can be provided for
events where the category is a boundary, instead of an exact match. All boundaries must
be of the same kind. Such an event is denoted by using a comparison operator. When the
value of a probability can be deduced from others, its definition can be spared. The initial
probabilities are optional as a whole, and the default initial law is uniform.
Example:
OBSERVATION:
State = {
type = categorical
categories = {1,2,3}
dependence = Markov
P(State_1=1) = a1
P(State_1=2) = a2
logit(P(State<=1|State_p=1)) = a11
logit(P(State<=2|State_p=1)) = a11+a12
logit(P(State<=1|State_p=2)) = a21
logit(P(State<=2|State_p=2)) = a21+a22
logit(P(State<=1|State_p=3)) = a31
logit(P(State<=2|State_p=3)) = a31+a32
}
An observation variable for ordered categorical data modelled as a continuous Markov chain
is also defined using the type categorical, along with the dependence definition Markov. But
here transition rates are defined instead of transition probabilities. Its additional fields are:
• categories: List of the available ordered categories. They are represented by increasing
successive integers. It is defined right after type.
• P(Y_1=i): Initial probability of a given category integer i, for the observation named Y.
This probability belongs to the first observed value. A transformed probability can be
provided instead of a direct one. The transformation can be log, logit, or probit. The
probabilities are defined following the order of their categories. They can be provided for
events where the category is a boundary, instead of an exact match. All boundaries must
be of the same kind. Such an event is denoted by using a comparison operator. When the
value of a probability can be deduced from others, its definition can be spared. The initial
probabilities are optional as a whole, and the default initial law is uniform.
Example:
OBSERVATION:
State = {
type = categorical
categories = {1,2}
dependence = Markov
P(State_1=1) = p1
transitionRate(1,2) = q12
transitionRate(2,1) = q21
}
An observation variable for time to event or repeated time to event data is defined using the
type event. Its additional fields are:
• eventType: Type of the events. The exact time of the events can be observed, or censored
per interval. The respective keywords are exact and intervalCensored. By default, an
exact time is assumed.
Example:
Seizure = {
type = event
eventType = intervalCensored
maxEventNumber = 1
rightCensoringTime = 120
intervalLength = 10
hazard = gamma*Cc
}
A continuous observation variable is defined using the type event. Its additional fields are:
• errorModel: Error model to apply on the predicted value. Available error models are:
constant, proportional, combined1, combined2, proportionalc, combined1c, combined2c,
exponential, logit, band(0,10) and band(0,100).
Example:
OBSERVATION:
Concentration = {
type = continuous
prediction = Cc
errorModel = proportional
autocorrelation = yes
}
The function pkmodel defines a standard PK model. The PK model is defined according to
the provided set of named arguments. Most of the arguments are optional, and the pkmodel
Example:
EQUATION:
Cc = pkmodel(V, Cl)
This simple set of named arguments for pkmodel defines a PK model with one central com-
partment of label 1, with the default IV Bolus absorption for doses of administration type 1
and a linear elimination with the clearance parametrization in Cl. The volume of the central
compartment is V. Its concentration is the output Cc of the function.
More complex pk models can easily be defined using the function pkmodel
Example:
EQUATION:
{Cc, Ce} = pkmodel(Tlag, ka, p, V, Vm, Km, k12, k21, k13, k31, ke0)
This more complex set of named arguments for pkmodel defines a PK model of one central
compartment, with a first order absorption of rate ka for doses of administration type 1, and a
Michaelis-Menten elimination of parameters Vm and Km. The volume of the central compartment
is V. Its concentration is the first output Cc of the function. An effect compartment is defined
with a rate ke0 and its concentration is the second output Ce. Two peripheral compartments
of labels 2 and 3 are linked to the central compartment of label 1. The respective couples of
exchange rates are (k12, k21) and (k13, k31). The first order absorption has a lag time of
Tlag and the absorbed amount is scaled with a proportion of p.
The complete set of named arguments and output for pkmodel follows. They belong to the
central compartment, the absorption process, the elimination process, the exchanges with the
peripheral compartments, or an effect compartment. Some arguments are mutually exclusive, or
require other ones to be also defined. Most of them are optional, so the mandatory arguments
are stated.
• Cc = pkmodel(...): The first output is the concentration within the central compart-
ment. Another name can be used. Mandatory.
• Tk0: Defines a zero order absorption of duration Tk0. Excludes ka, Ktr and Mtt.
• ka: Defines a first order absorption of rate ka. Excludes Tk0.
• Ktr: Along with ka and Mtt, defines an absorption with transit compartments of transit
rate Ktr. Excludes Tk0.
• Mtt: Along with ka and Ktr, defines an absorption with transit compartments of mean
transit time Mtt. Excludes Tk0.
• Tlag: Lag time before the absorption.
• p: Final proportion of the absorbed amount. Can affect the effective rate of the absorption,
not its duration.
• k12: Along with k21, defines a peripheral compartment 2 of input rate k12.
• k21: Along with k12, defines a peripheral compartment 2 of output rate k21.
• k13: Along with k31, defines a peripheral compartment 3 of input rate k13.
• k31: Along with k13, defines a peripheral compartment 3 of output rate k31.
• {Cc, Ce} = pkmodel(...): The second output is the concentration within the effect
compartment. Another name can be used.
• ke0: Defines an effect compartment with transfer rate ke0 from the central compartment.
Knowing the label of the central compartment and the administration type supported by the
function pkmodel, one can build up a custom PK model by adding other PK elements to a base
standard PK model. Referencing this label and administration type of value 1 allows to connect
the additional PK elements.
The block PK: defines PK elements for a compartmental model. As in the diagram of such
a model, those elements are linked to build up the complete model. An element can reference
another one using its label. The referenced element must be already defined. The base elements
are the compartments. These PK elements provide a greater flexibility for complex PK models
beyond the scope of the function pkmodel. They can also extend a custom ODE system.
In the following, most of the named arguments are optional, so the mandatory arguments
are stated.
Dose absorptions can be defined to fill it, and other special compartments can be linked. Its
amount and concentration are variables; it supports defining a prediction or an equation for
pharmacodynamics, for example.
• amount: Name of variable defined as the amount within the compartment. Its dynamics are
defined by dose absorptions, eliminations, and the transfer rates with other compartments.
These dynamics can extend an ODE system that defines a component with this name.
• volume: Name of predefined variable to use as the volume of the compartment. It enables
to define concentration. By default, concentration cannot be defined and the volume
is 1.
• concentration: Name of the variable defined as the concentration within the compart-
ment.
Example:
PK:
compartment(cmt=1, amount=Ac, volume=V, concentration=Cc)
If no dose absorption is involved for a compartment, and if the amount and all its dynamics
are defined as an ODE component with its derivative, then its macro definition can be spared.
• kij or k_i_j: Input rate from the compartment of label i. It also defines a label j for
the peripheral compartment. Here, both labels i and j must be integers. Mandatory.
• kji or k_j_i: Output rate to the compartment of label i. It also defines a label j for the
peripheral compartment. Here, both labels i and j must be integers. Mandatory.
Example:
peripheral(k12, k21, amount=Ap, volume=V2, concentration=Cp)
• concentration: Name of the variable defined as the concentration within the effect com-
partment. Mandatory.
Example:
effect(cmt=1, ke0, concentration=Ce)
Absorptions The design from the project or dataset defines the different administrations of
doses. These administrations are singled out using different types. Absorptions for doses are
defined by the model and reference the subject administration type. Several absorption processes
can be defined for a given administration, the final absorption being their sum. All macros
defining an absorption have the following named arguments:
• type: Administration type of doses subject to the absorption process. Its default value is
1. Alias: adm.
• p: Final proportion of the absorbed amount. Can affect the effective rate of the absorption,
not its duration. p can take any positive value (including > 1).
depot The macro depot defines an absorption targeting a depot. A component of an ODE
system is defined as the target depot for the doses. Each dose triggers as its absorption an input
source term for this system, shifting the depot variable by a proportion of the dose amount. A
zero order, first order, or transit process can also be defined, using the same argument sets as
the macro absorption, apart from cmt.
• target: Name of the component of an ODE system that is shifted by the absorption.
Mandatory.
• Tlag
• p
• Ktr, Mtt: Define transit components of transit rate Ktr and mean transit time Mtt for a
transit process.
Example:
PK:
depot(type=1, target=Ad, Tlag, p=F)
depot(type=2, target=Ac, Tk0)
EQUATION:
ddt_Ad = -ka*Ad
ddt_Ac = ka*Ad - k*Ac
Example:
PK:
depot(type=1, target=Ac, Tlag, p=F, ka)
depot(type=2, target=Ac, Tk0)
EQUATION:
ddt_Ac = - k*Ac
IV The macro iv defines an absorption for intravenous doses. Doses without an administration
rate or infusion time are instantaneously absorbed within the associated compartment, as an IV
bolus. Other doses are absorbed according to a zero order process, as an IV infusion.
• cmt: Label of the compartment filled in by the absorption process. Its default value is 1.
• type/adm
• Tlag
• p
Example:
PK:
iv(type=1, cmt=1, p)
Zero order absorption processes The macro absorption with an argument Tk0 defines a
zero order absorption process
As a common model for oral administrations, administration has the alias oral.
• cmt: Label of the compartment filled in by the absorption process. Its default value is 1.
• type/adm
• Tlag
• p
Example:
PK:
absorption(cmt=1, Tk0, Tlag)
First order absorption The macro absorption with an argument ka defines a first order
absorption process.
• cmt: Label of the compartment filled in by the absorption process. Its default value is 1.
• type/adm
• Tlag
• Ktr, Mtt: Define transit compartments of transit rate Ktr and mean transit time Mtt for
the absorption.
• p
Example:
PK:
absorption(cmt=1, ka, p=F)
Eliminations Different elimination processes can be defined for compartments. Several elim-
inations can even be defined for the same compartment, the final elimination flow being their
sum. All macros defining an elimination have the following named arguments:
• cmt: Label of the compartment emptied by the elimination process. Its default value is 1.
• V: Volume involved in the elimination process. Its default, and usual, value is the volume
of the emptied compartment.
Example:
elimination(cmt=1,k)
Arguments for macro elimination used for a non linear elimination are:
Example:
elimination(cmt=1,Vm,Km)
Transfers The macro transfer defines a transfer of amount from a first compartment to a
second one. Its named arguments are:
• from: Label of the source compartment for the transfer. Its default value is 1.
• to: Label of the target compartment for the transfer. Its default value is 1.
• kt: Rate of the transfer. Mandatory.
Example:
transfer(from=1, to=2, kt)
Doses from the design can also be referenced through several matching independent variables.
This allows for some direct calculation, especially for modelling custom single dose absorptions.
Doses aren’t discriminated according to their administration types here. These values are directly
related to the design, they are unaffected by the PK elements.
Time of the last administered dose The keyword tDose defines the time of the last ad-
ministered dose. This is a step function. Its value is unaffected by any lag time Tlag. Indeed, a
lag time targets the dose absorption. It is null before the first dose.
Amount of the last administered dose The keyword amtDose defines the amount of the
last administered dose. This is a step function. Its value is unaffected by any proportional factor
p, as this keyword targets the absorbed amount by the end of the whole absorption process. It
is null before the first dose.
Infusion time of the last administered dose The keyword inftDose defines the infusion
time of the last administered dose. This is a step function. Its value is unaffected by any propor-
tional factor p, as this keyword targets the absorbed amount by the end of the whole absorption
process. The rate of the final absorption can be different from the rate of the administration
process. It is null before the first dose.
In PK modelling some very common models have a known analytical solution, therefore not
requiring to call the ODE solver. Using analytical solutions allows to get exact results, instead
of approximations bu the ODE solver, and to save computation time.
INPUT:
parameter = {V, k}
EQUATION:
Cc = pkmodel(V, k, k12=0.2, k21=0.3)
OUTPUT:
output = Cc
describes a classical two compartments model whose solution is given in [Mathematical Expres-
sions of the Pharmacokinetic and Pharmacodynamic Models implemented in the Monolix soft-
ware, September 2008 ]
MLXTRAN automatically detects all the common models described in [Mathematical Expres-
sions of the Pharmacokinetic and Pharmacodynamic Models implemented in the Monolix soft-
ware, September 2008 ] and when such a model is used and its coefficients do not depend
on time, the ODE system is replaced by its corresponding analytical solution.
Note from the previous model that an analytical combination of analytical solutions is still
an analytical solution.
• As already stated there is no analytical solution when a coefficient of the ODE system (such
as a volume, a transfer coefficient between compartments or an absorption rate) depends
on time. However dose coefficients can depend on time, since their time-dependency is
only assessed once, when the dose is delivered. As a consequence the drug proportion, time
lag or drug amount can depend on time and the following model will create an analytical
solution
INPUT:
parameter = {V}
PK:
compartment(cmt=1, volume=V, concentration=Cc)
iv(cmt=1, p=amtDose/(amtDose+10), Tlag = t/(t + 10))
elimination(cmt=1, k=0.2)
peripheral(k12=0.6*V/(V + 0.1), k21=0.8, amount=Ap)
EQUATION:
out = 3*t + 2*Cc + sin(Ap)
OUTPUT:
output = out
• Note from above model that an analytical formula can be used in the definition of the
transfer rate (see k12 in model hereunder). However the transfer rate shall not depend on
time, otherwise the analytical solution is no longer valid.
Note that when there are several administrations the solution is computed as the sum of
the solutions for each administration (since the system is linear).
Cc = 3*t + sin(Ap)
OUTPUT:
output = Cc
• If pkmodel macros are replaced by their corresponding ODE system, the analytical solution
will not be generated. For instance the following script will not generate an analytical
solution:
INPUT:
parameter = {k}
EQUATION:
ddt_Ap = -k*Ap
OUTPUT:
output = Ap
• Analytical solutions will not be generated when Michaelis Menten eliminations are used
(Mtt coefficient), maximum elimination rate (Vm coefficient), transit compartments with
transit rate (see Ktr coefficient) or mean transit time (see Mtt coefficient). Indeed such
systems do not have an an analytical solution and amounts in the different compartments
can only be computed by solving the ODE system.
• When the input data file contains IOV, coefficients of the ODE can vary between occasions
and hence with time. Therefore there is no analytical solution generated in this case.
5.4.2 Miscellaneous
• How to set / unset analytical functions: In the configuration file, inside the [Plug-
InCodeGeneration] section, the parameter bUseAnalyticalFunctions can be set
to true / false to switch ON / OFF the use of analytical solutions. The configuration file
is located at: <UserHome>/lixoft/monolix/config/config.ini
• How to compare analytical and ODE results ? Users who wish to verify the con-
sistency of the results from the ODE and from the analytical solution can run the same
model twice as follows: first run with bUseAnalyticalFunctions set to true and
second time set to false. The configuration file is checked at software startup, therefore
the software needs to be restarted for the modification to be taken into acount.
- run the model twice with different settings as described above; if the results are slightly
different it means that an analytical solution is used when requested, since the ODE
solution is an approximation of the analytical solution.
- examine the plug-in source code and search for string analytical_setParameters
which means that plug-in calls an analytical solution.
5.5 Examples
[PREDICTION]
Cc input = {V, Cl}
V
PK:
Cc = pkmodel(V, Cl)
Cl (linear elimination)
The block PK: describes the PK model. The function pkmodel with arguments V and Cl
defines a linear elimination with a parameterization in clearance, in addition to its default output
concentration and IV absorption.
Combining three macros to define the central compartment, the IV absorption, and the linear
elimination builds up the same PK model. As there is only one compartment the label cmt can
be left with its default value for these macros. The concentration and the elimination are based
on the volume defined within the compartment macro. The absorption macro also keeps for its
subject doses the default administration type.
Example:
PK:
compartment(cmt=1,concentration=Cc, volume=V)
iv(cmt=1)
elimination(cmt=1,Cl)
This model can also be defined with an ODE system. The system describes the elimination
and the doses define input source terms of the system, with a depot macro.
Example:
PK:
depot(target=Ac)
EQUATION:
ddt_Ac = -Cl/V * Ac
Cc = Ac/V
Example:
Cc = pkmodel(Tlag, V, Cl)
Example:
Cc = pkmodel(p, V, Cl)
Example:
Cc = pkmodel(Tk0, V, Cl)
Example:
Cc = pkmodel(ka, V, Cl)
Example:
Cc = pkmodel(ka, Ktr, Mtt, V, Cl)
Analytical solution for a 1-compartment model with single dose The prediction of
interest is the concentration within the central compartment of a 1-compartment model with an
oral administration, first order absorption, and a linear elimination.
DOSE
Oral administration
k (linear elimination)
The analytical solution is defined here for a single dose problem and is based on tDose and
amtDose.
Sequential zero order-first order absorption processes The prediction of interest is the
concentration within the central compartment of a 1-compartment model with an oral adminis-
tration, a sequential zero order-first order absorption, and a linear elimination.
DOSE
Oral administration
; PK model, oral administration, sequential
; zero-order & first order absorptions,
; linear elimination
DEPOT
[PREDICTION]
T k0 , F r0 (zero order) input = {Fr0, Tk0, ka, V, k}
ka , (1 − F r0 ) (first order)
PK:
Cc compartment(concentration=Cc, volume=V)
V oral(Tk0, p=Fr0)
oral(ka, Tlag=Tk0, p=1-Fr0)
elimination(k)
k (linear elimination)
Two different absorptions are defined, for the same administration type and with the same
compartment to fill in. A linear elimination is defined for the same compartment. The adminis-
tration type is the default value, 1, as is the label of the subject compartment for the different
macros here. The two absorptions defined for the compartment are cumulated, each dose of this
type triggers both of them. The artificial lag time allows the first order absorption to come
after the zero order one, in a sequence. Each one concerns only a fraction of the administered
amount, respectively fractions F r0 and (1 − F r0).
DEPOT [PREDICTION]
input = {Tlag, Tk0, V, Vm, Km, k}
Tlag , T k0 (lagged zero order)
PK:
compartment(amount=Ac)
Ac oral(Tlag, Tk0)
EQUATION:
V , Vm , Km , k ddt_Ac = -Vm*Ac/(V*Km+Ac) - k*Ac
(custom elimination) Cc = Ac/V
The custom elimination is defined with an ODE system and is extended with an absorption
macro. It requires to define a name for the amount variable that will be an ODE component as
well as the quantity ruled by the absorption macro.
Complex PK model with a latent compartment The predictions of interest are the con-
centration within the central compartment of a 2-compartment model, and the amount within
the second, latent, compartment. There are three administration types, a transfer from the latent
compartment to the central one, and a linear elimination for each compartment. Each compart-
ment has a first order absorption with its bioavailability. In addition, the central compartment
has an IV absorption.
F1 (bioavailability) F2 (bioavailability)
DEPOT 1 DEPOT 2
1 kl (transfer) 2
Latent Central
Al Ac
[PREDICTION]
input = {F1, F2, ka1, ka2, kl, V, k1, k2}
PK:
compartment(cmt=1, amount=Al)
compartment(cmt=2, amount=Ac)
oral(type=1, cmt=1, ka=ka1, p=F1)
oral(type=2, cmt=2, ka=ka2, p=F2)
iv(type=3, cmt=2)
transfer(from=1, to=2, kt=kl)
elimination(cmt=1, k=k1)
elimination(cmt=2, k=k2)
Cc = Ac/V
Each administration is singled out by its type, and get an absorption defined for its doses.
Alike, each compartment is singled out by its cmt, and is referenced by other PK elements using
it. Two different absorptions contribute to fill in the central compartment directly, in addition
to the transfer coming from the latent compartment. The definition for a compartment precedes
the elements that refers to it. The concentration is defined by a calculus based on the amount of
interest, within the central compartment. Parameters volume and concentration could have
been set up for the central compartment, instead of this equation.
The block OUTPUT: declares variables whose values are exported for the various tasks. For
example, they can be processed by the algorithms, used in graphics, or registered in files. The
keyword output declares the main variables to output, whereas table declares the variables to
record in tables.
Example:
OUTPUT:
output = {Concentration, Effect}
table = {Ap, Rin}
6.1 Examples
INPUT:
parameter = {A,k}
EQUATION:
T0=5
(
if t<T0
A if t <= 5
f= f=A
A e−k (t−5) if t > 5 else
f= A*exp(-k*(t-T0))
end
OUTPUT:
output = f
Exponential decay model with an ODE This is the same model as before, but it is defined
by an ODE (Ordinary Differential Equations) initial value problem.
INPUT:
parameter = {A,k}
( EQUATION:
f =A if t <= 5 t0=5
0
f (t) = −k f (t) if t > 5 f_0=A
ddt_f= - k*f
OUTPUT:
output = f
An ODE (Ordinary differential equations) can be defined in the block EQUATION:. Here,
ddt_A is the derivative of A with respect to time t. A_0 is the initial value of the system, i.e.
the value of A at time t0 (A is constant before t0).
7 Miscallenous
7.1 Macros
The macros have a syntax that can be similar to the syntax of an usual function, as min, but
they define themselves elements of the model such as a compartment for example. Alike, they
can define variables as an output, but they cannot be included themselves into an arithmetic
expression, as an usual function. Defining the very structure of the model, they cannot be
enclosed within a conditional statement.
Most arguments of a macro are fully optional and provide a default value, or are part of
separated sets of arguments. Therefore the arguments of a macro are not identified according
to their ordering, but to their name. These named arguments follow a special lookup to define
their values.
Indeed, if a variable is already defined with the same name as the argument, listing this name
within the macro call is sufficient for the lookup to pick up the value of the argument from the
variable. This assumes that the value type is compatible with the argument, thus it is available
for equations, but not for labels or pure names.
The other option is simply to define the value of the argument inline within the macro call,
as an equality.
Example:
ka = 0.8*t
F = 0.3
oral(type=2, ka, p=1-F)
; Argument "ka" denotes the set of arguments for a first order absorption.
; Argument "type" gets an inline label of "2".
; Argument "ka" gets the equation "0.8*t" from the variable "ka".
; Argument "p" gets an inline equation of "1-F".
The output of a macro is a single variable, or a list of variables. Their equations are defined
by the macro itself, according to its input arguments, and their names are provided as an output
list. Therefore, contrary to input arguments, the ordering or output argument matters.
Example:
{out1, out2} = pkmodel(Tk0=2.5, V=10, k=0.3, ke0=0.7)
; Argument "ke0" enables an effect compartment.
; A variable "out1" is defined as the central compartment’s concentration.
; A variable "out2" is defined as the effect compartment’s concentration.
The keyword t defines the main independent variable. This is the variable itself, not its
last record from the design. This is also the differentiation variable for any ODE and the time
variable for the pharmacokinetics.
7.3 Annotations
A comment begins from the character ; to the end of the line. It is ignored by the parser.
Example:
V={distribution=lognormal, typical=V_pop, sd=omega_V} ; This is a comment.
; This is also a comment.
Some naming patterns and keywords are reserved, and cannot be used as new names.
The naming patterns for the ODE derivatives and initial values are reserved.
The names of the usual mathematical functions and distribution functions are reserved.