| Title: | Linear Compartment Model Solutions and Gradients for 'rxode2' |
|---|---|
| Description: | Analytic one, two and three compartment linear pharmacokinetic solutions with their parameter gradients from 'stan' automatic differentiation (Carpenter et al (2015) <doi:10.48550/arXiv.1509.07164>), eigen decompositions and derived-parameter conversions used by 'rxode2' (Wang, Hallow and James (2016) <doi:10.1002/psp4.12052>). Split out of 'rxode2' so its installation does not compile 'stan' AD items which made it take too long to compile by itself. The closed-form solutions follow the idea of the 'wnl' package (Bae, <https://CRAN.R-project.org/package=wnl>), though the implementation here is different. |
| Authors: | Matthew L. Fidler [aut, cre] (ORCID: <https://orcid.org/0000-0001-8538-6691>), Richard Upton [ctb] |
| Maintainer: | Matthew L. Fidler <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-09-24 19:35:39 UTC |
| Source: | https://github.com/cran/rxode2lincmt |
Converts one parameter set, in any of the linCmt() parameterizations, to
the central volume and micro-constants that the analytic solutions use.
linCmtMicros(p1, v1, p2 = 0, p3 = 0, p4 = 0, p5 = 0, ncmt, trans = 1L)linCmtMicros(p1, v1, p2 = 0, p3 = 0, p4 = 0, p5 = 0, ncmt, trans = 1L)
p1 |
first parameter (for example clearance or |
v1 |
central volume (or its parameterization-specific counterpart) |
p2 |
second parameter (two and three compartments) |
p3 |
third parameter (two and three compartments) |
p4 |
fourth parameter (three compartments) |
p5 |
fifth parameter (three compartments) |
ncmt |
number of compartments, 1 to 3 |
trans |
parameterization number (see Details) |
Supported trans values: one compartment 1 (cl, v), 2 (k, v), 10
(alpha, A with v1 holding A), 11 (alpha, v); two compartments 1
(cl, v, q, vp), 2 (k, v, k12, k21), 3 (cl, v, q,
vss), 4 (alpha, beta, k21), 5 (alpha, beta, aob), 10, 11;
three compartments 1 (cl, v, q, vp, q2, vp2), 2 (k, v,
k12, k21, k13, k31), 10, 11.
named numeric vector: v, k, and for two or more compartments
k12, k21, and for three compartments k13, k31
Matthew L. Fidler
linCmtMicros(p1 = 2, v1 = 20, ncmt = 1) linCmtMicros(p1 = 2, v1 = 20, p2 = 3, p3 = 40, ncmt = 2)linCmtMicros(p1 = 2, v1 = 20, ncmt = 1) linCmtMicros(p1 = 2, v1 = 20, p2 = 3, p3 = 40, ncmt = 2)
Advances the amounts of a one, two or three compartment linear model by
dt and returns the central concentration, optionally with its
derivatives. This is the per-row kernel behind rxode2's linCmt().
linCmtModelDouble( dt, p1, v1, p2, p3, p4, p5, ka, alastNV, rateNV, ncmt, oral0, trans, deriv, type, tau, tinf, amt, bolusCmt, ndiff, sensType = 3L, sensH = 0.001 )linCmtModelDouble( dt, p1, v1, p2, p3, p4, p5, ka, alastNV, rateNV, ncmt, oral0, trans, deriv, type, tau, tinf, amt, bolusCmt, ndiff, sensType = 3L, sensH = 0.001 )
dt |
time step |
p1, v1, p2, p3, p4, p5
|
parameters in the |
ka |
absorption rate constant (used when |
alastNV |
amounts at the start of the step (depot first when
|
rateNV |
zero-order rates into each compartment, in the same order |
ncmt |
number of compartments, 1 to 3 |
oral0 |
1 when the model has a depot compartment, otherwise 0 |
trans |
parameterization number |
deriv |
logical; also return the derivatives |
type |
0 for a regular step; 1 and 2 steady-state infusion, 3 steady-state bolus |
tau |
steady-state dosing interval |
tinf |
steady-state infusion duration |
amt |
steady-state bolus amount |
bolusCmt |
steady-state bolus compartment |
ndiff |
differentiation bit mask as used by rxode2 ( |
sensType |
derivative method: 3 or 30 forward-mode automatic
differentiation, 32 all directions in one forward-mode pass, 31
reverse mode, 100 automatic choice, 1 and 2 forward and central
differences with the kernel's own step, 10 and 20 forward and central
differences with step |
sensH |
finite-difference step for |
list with val (central concentration) and Alast (carried
state after the step); with deriv = TRUE also J (Jacobian of the
amounts) and Jg (gradient of val)
linCmtModelDouble(1, 2, 20, 0, 0, 0, 0, 0, 100, 0, 1L, 0L, 1L, FALSE, 0L, 0, 0, 0, 0L, 0L)linCmtModelDouble(1, 2, 20, 0, 0, 0, 0, 0, 100, 0, 1L, 0L, 1L, FALSE, 0L, 0, 0, 0, 0L, 0L)
Computes the exponents (L) and coefficient matrices (C1, C2) of the
two compartment linear system from its micro-constants. The idea comes
from the 'wnl' package by Kyun-Seop Bae; the implementation is different.
solComp2(k10, k12, k21)solComp2(k10, k12, k21)
k10 |
elimination rate |
k12 |
rate from central to peripheral compartment |
k21 |
rate from peripheral to central compartment |
List with L vector and matrices C1 and C2
Matthew L. Fidler, based on the idea in the 'wnl' package
solComp2(k10 = 0.1, k12 = 3, k21 = 1)solComp2(k10 = 0.1, k12 = 3, k21 = 1)
Eigenvalues and coefficients of the three compartment model
solComp3(k10, k12, k21, k13, k31)solComp3(k10, k12, k21, k13, k31)
k10 |
elimination rate |
k12 |
rate from central to peripheral compartment |
k21 |
rate from peripheral to central compartment |
k13 |
rate from central to peripheral compartment #2 |
k31 |
rate from peripheral compartment #2 to central |
List with L vector and matrices C1, C2 and C3
Matthew L. Fidler, based on the idea in the 'wnl' package
solComp3(k10 = 0.1, k12 = 3, k21 = 1, k13 = 2, k31 = 0.5)solComp3(k10 = 0.1, k12 = 3, k21 = 1, k13 = 2, k31 = 0.5)