Analytical Solutions and Differential Equations
The dynamical problem types specify the dynamical models that are the nonlinear transformation of the NLME model. There are two major types of dynamical models: analytical models and DEProblems. An analytical model is a small differential equation with an analytical solution. This analytical solution is used by the solvers to greatly enhance the performance. On the other hand, DEProblem is a specification of a differential equation for numerical solution by DifferentialEquations. This is used for specifying dynamical equations which do not have an analytical solution, such as many nonlinear ordinary differential equations (ODEs), or the myriad of differential equation types supported by DifferentialEquations, such as delay differential equations (DDEs) and stochastic differential equations (SDEs).
Analytical Solutions
Analytical problems are a predefined ODE with an analytical solution. While limited in flexibility, the analytical solutions can be much faster for simulation and estimation. In the @model DSL, an analytical solution is declared by name. For example:
@dynamics Central1declares the use of Central1 dynamics. Analytical solutions have preset names which are used in the internal model. These parameters must be given values in the @pre block.
Central1
Pumas.Central1 — TypeCentral1An analytical model for a one compartment model with dosing into Central. Equivalent to
Central' = -CL/Vc*Centralwhere clearance, CL, and volume, Vc, are required to be defined in the model through @param, @covariates, or @pre.
Central1Periph1
Pumas.Central1Periph1 — TypeCentral1Periph1An analytical model for a two-compartment model with a central compartment, Central and a peripheral compartment, Peripheral. Equivalent to
Central' = -(CL+Q)/Vc*Central + Q/Vp*Peripheral
Peripheral' = Q/Vc*Central - Q/Vp*Peripheralwhere clearance, CL, and volumes, Vc and Vp, and distribution clearance, Q, are required to be defined in the model through @param, @covariates, or @pre.
Central1Periph2
Pumas.Central1Periph2 — TypeCentral1Periph2An analytical model for a two-compartment model with a central compartment, Central and a peripheral compartment, Peripheral. Equivalent to
Central' = -(CL+Q1+Q2)/Vc*Central + Q1/Vp1*Peripheral1 + Q2/Vp2*Peripheral2
Peripheral1' = Q1 /Vc*Central - Q1/Vp1*Peripheral1
Peripheral2' = Q2 /Vc*Central - Q2/Vp2*Peripheral2where clearance, CL, and volumes, Vc and Vp, and distribution clearance, Q, are required to be defined in the model through @param, @covariates, or @pre.
Central1Meta1
Pumas.Central1Meta1 — TypeCentral1Meta1An analytical model for a model with a central compartment, Central, and a metabolite, Metabolite. Equivalent to
Central' = -(CL+CLfm)/Vc*Central
Metabolite' = CLfm/Vc*Central - CLm/Vm*Metabolitewhere clearances (CL and CLm) and volumes (Vc and Vm) and formation clearance of metabolite CLfm are required to be defined in the model through @param, @covariates, or @pre.
Central1Periph1Meta1
Pumas.Central1Periph1Meta1 — TypeCentral1Periph1Meta1An analytical model for a two compartment model with a central compartment, Central, with a peripheral compartment, Peripheral, and a metabolite compartment, Metabolite. Equivalent to
Central' = -(CL+Q+CLfm)/Vc*Central + Q/Vp*CPeripheral
CPeripheral' = Q/Vc*Central - Q/Vp*CPeripheral
Metabolite' = -CLm/Vm*Metabolite + CLfm/Vc*Centralwhere clearances (CL and CLm) and volumes (Vc, Vp and Vm), distribution clearance (Q), and formation clearance of metabolite CLfm are required to be defined in the model through @param, @covariates, or @pre.
Central1Periph1Meta1Periph1
Pumas.Central1Periph1Meta1Periph1 — TypeCentral1Periph1Meta1Periph1An analytical model for a two compartment model with a central compartment, Central, with a peripheral compartment, Peripheral, and a metabolite compartment, Metabolite, with a peripheral compartment, MPeripheral. Equivalent to
Central' = -(CL+Q+CLfm)/Vc*Central + Q/Vp*CPeripheral
CPeripheral' = Q/Vc*Central - Q/Vp*CPeripheral
Metabolite' = -(CLm+Qm)/Vm*Metabolite + Qm/Vmp*MPeripheral + CLfm/Vc*Central
MPeripheral' = Qm/Vm*Metabolite - Qm/Vmp*MPeripheralwhere clearances (CL and CLm) and volumes (Vc, Vp, Vm and Vmp), distribution clearances (Q and Qm) and formation clearance of metabolite CLfm are required to be defined in the model through @param, @covariates, or @pre.
Depots1Central1
Pumas.Depots1Central1 — TypeDepots1Central1An analytical model for a one compartment model with a central compartment, Central, and a depot, Depot. Equivalent to
Depot' = -Ka*Depot
Central' = Ka*Depot - CL/Vc*Centralwhere absoption rate, Ka, clearance, CL, and volume, Vc, are required to be defined in the model through @param, @covariates, or @pre.
Depots1Central1Periph1
Pumas.Depots1Central1Periph1 — TypeDepots1Central1Periph1An analytical model for a two-compartment model with a central compartment, Central, a peripheral compartment, Peripheral, and a depot Depot. Equivalent to
Depot' = -Ka*Depot
Central' = Ka*Depot - (CL+Q)/Vc*Central + Q/Vp*Peripheral
Peripheral' = Q/Vc*Central - Q/Vp*Peripheralwhere absorption rate, Ka, clearance, CL, and volumes, Vc and Vp, and distribution clearance, Q, are required to be defined in the model through @param, @covariates, or @pre.
Depots2Central1
Pumas.Depots2Central1 — TypeDepots2Central1An analytical model for a one compartment model with a central compartment, Central, and two depots, Depot1 and Depot2. Equivalent to
Depot1' = -Ka1*Depot1
Depot2' = -Ka2*Depot2
Central' = Ka1*Depot1 + Ka2*Depot2 - CL/Vc*Centralwhere absorption rates, Ka1 and Ka2, clearance, CL, and volume, Vc, are required to be defined in the model through @param, @covariates, or @pre.
When using this model during simulation or estimation, it is preferred to have 2 dosing rows for each subject in the dataset, where the first dose goes into cmt =1 (or cmt = Depot1) and the second dose goes into cmt=2 (or cmt=Depot2). Central compartment gets cmt=3 or (cmt = Central). e.g.
ev = DosageRegimen([100,100],cmt=[1,2]) s1 = Subject(id=1, events=ev)
Depots2Central1Periph1
Pumas.Depots2Central1Periph1 — TypeDepots2Central1Periph1An analytical model for a two-compartment model with a central compartment, Central, a peripheral compartment, Peripheral, and two depots Depot1 and Depot2. Equivalent to
Depot1' = -Ka1*Depot1
Depot2' = -Ka2*Depot2
Central' = Ka1*Depot1 + Ka2*Depot2 - (CL+Q)/Vc*Central + Q/Vp*Peripheral
Peripheral' = Q/Vc*Central - Q/Vp*Peripheralwhere absorption rates, Ka1 and Ka2, clearance, CL, and volumes, Vc and Vp, and distribution clearance, Q, are required to be defined in the model through @param, @covariates, or @pre.
Differential Equations DEProblem
DEProblems are types from DifferentialEquations which are used to specify differential equations to be solved numerically via the solvers of the package. In the @model interface, the DEProblem is set to be an ODEProblem defining an ODE. The models are defined by writing each of the differential equations in the system, e.g.
@dynamics begin
Central' = -(CL / Vc) * Central
endfor a simple one compartment model and
@dynamics begin
Depot' = -Ka * Depot
Central' = Ka * Depot - (CL / Vc) * Central
endfor a one compartment model with first order absorption.
Default solver
Dynamical models that do not have an analytical solution have to be integrated numerically. There are a myriad of solvers with different properties and performance under different conditions. In Pumas the default solver is
AutoVern7(
Rodas5P(
autodiff = ADTypes.AutoForwardDiff(; chunksize = 1),
linsolve = LinearSolve.GenericLUFactorization(),
),
)The AutoX(Y) signature where X and Y are names of integrators means that X will be used unless stiffness is detected and then Y will be used. In both simobs and fit (or any other function where it may be relevant to set diffeq_options) it is possible to change these defaults using the diffeq_options keyword argument with an alg element. For example, it is possible to fit using Vern7 only using the syntax
results = fit(model, population, param, FOCE(); diffeq_options = (; alg = Vern7()))This should only be done if the user is certain that stiffness could not be detected even at extreme parameter values, but it would in principle remove a little bit of overhead if the model is indeed not stiff.