Example: Two-cpt oral with derived AUC

A two-compartment oral PK model with [derived] columns for micro-rate constants and NCA-style summaries: peak (CMAX, TMAX), first-week AUC (AUC_0_168), and a periodic 24-h AUC (AUC_TAU).

Model

library(ferx)

ex  <- ferx_example("two_cpt_oral_derived")
ferx_model_show(ex$model)
# model: two_cpt_oral_derived.ferx 
# Two-compartment oral PK with [derived] output

[parameters]
  theta TVCL(5.0,  0.1,  50.0)
  theta TVV1(30.0, 3.0, 300.0)
  theta TVQ( 2.0,  0.1,  20.0)
  theta TVV2(50.0, 5.0, 500.0)
  theta TVKA(1.0,  0.05, 20.0)

  omega ETA_CL ~ 0.09
  omega ETA_V1 ~ 0.09

  sigma PROP_ERR ~ 0.02 (sd)

[individual_parameters]
  CL = TVCL * exp(ETA_CL)
  V1 = TVV1 * exp(ETA_V1)
  Q  = TVQ
  V2 = TVV2
  KA = TVKA

[structural_model]
  pk two_cpt_oral(cl=CL, v=V1, q=Q, v2=V2, ka=KA)

[error_model]
  DV ~ proportional(PROP_ERR)

[derived]
  K10 = CL / V1
  K12 = Q  / V1
  K21 = Q  / V2

  CMAX       = max(IPRED)
  TMAX       = tmax(IPRED)
  AUC_0_168  = integral(IPRED, from=0, to=168, step=0.2)
  AUC_TAU    = integral(IPRED, window=24, anchor=0, step=0.2)

[output]
  CL V1 Q V2 KA

[fit_options]
  method  = focei
  maxiter = 500

The [derived] block computes:

Column Expression Description
K10 CL / V1 Elimination micro-rate constant
K12 Q / V1 Central→peripheral micro-rate
K21 Q / V2 Peripheral→central micro-rate
CMAX max(IPRED) Subject peak concentration
TMAX tmax(IPRED) Time of peak
AUC_0_168 integral(IPRED, from=0, to=168, step=0.2) Week-1 AUC
AUC_TAU integral(IPRED, window=24, anchor=0, step=0.2) Periodic 24-h AUC

[output] echoes CL, V1, Q, V2, KA into sdtab.

Note

This example uses the two_cpt_oral_cov dataset (which has WT and CRCL covariate columns). The model does not use these covariates — they are present in the dataset but ignored by the structural and individual-parameter blocks.

Fit

fit <- ferx_fit(ex$model, ex$data, verbose = FALSE)
print(fit)
============================================================
 NONLINEAR MIXED EFFECTS MODEL ESTIMATION
============================================================
 Model: two_cpt_oral_derived     Dataset: two_cpt_oral_cov
 Method: FOCEI | Gradient: ANALYTIC (DUAL2) | Subjects: 30 | Obs: 300

 STATUS: CONVERGED   89 iterations   2.7s
 OFV: -696.7943    AIC: -680.7943    BIC: -651.1641

MODEL STRUCTURE (auto-derived)
------------------------------------------------------------
  Structural:  2-cpt oral  (TVCL, TVV1, TVQ, TVV2, TVKA)
  IIV:         ETA_CL, ETA_V1
  IOV:         none
  Residual:    proportional

THETA
------------------------------------------------------------
Parameter            Estimate           SE       %RSE
----------------------------------------------------
TVCL                 4.414332     0.349631        7.9
TVV1                50.331591     3.730356        7.4
TVQ                  8.900905     0.390076        4.4
TVV2                91.174859     2.719697        3.0
TVKA                 1.274237     0.086451        6.8

OMEGA  (between-subject variability)
------------------------------------------------------------
  ETA_CL                   [log-normal]  = 0.181994  CV% = 44.7  SE = 0.049938
  ETA_V1                   [log-normal]  = 0.109042  CV% = 33.9  SE = 0.029767

SIGMA  (residual error)
------------------------------------------------------------
  PROP_ERR         [proportional] = 0.106962  (var = 0.011441, CV% = 10.7)  SE = 0.004935  [initial specified as SD]

SHRINKAGE
------------------------------------------------------------
 ETA_CL: 1.4%   ETA_V1: 2.4%   EPS: 9.8%

DIAGNOSTICS
------------------------------------------------------------
 Covariance: computed   Cond: 8.9   DW: 0.61 [positive autocorrelation]   IWRES lag-1 r: 0.657

RUN INFO
------------------------------------------------------------
 Gradient (requested): auto   (used: analytic (Dual2))
 ferx v0.1.6 (core v0.1.6)

SETTINGS  (model file / call-time override)
------------------------------------------------------------
  method                       focei  [model only]
  maxiter                      500  [model only]

------------------------------------------------------------
 2 warning  --  call ferx_warnings(fit) for details
============================================================

Derived columns

names(fit$sdtab)
 [1] "ID"        "TIME"      "DV"        "PRED"      "IPRED"     "CWRES"    
 [7] "IWRES"     "EBE_OFV"   "N_OBS"     "TAFD"      "TAD"       "CL"       
[13] "V1"        "Q"         "V2"        "KA"        "K10"       "K12"      
[19] "K21"       "CMAX"      "TMAX"      "AUC_0_168" "AUC_TAU"  

Micro-rate constants

K10, K12, K21 are per-row (constant per subject, dependent on EBE parameters):

head(unique(fit$sdtab[, c("ID", "CL", "V1", "Q", "V2", "K10", "K12", "K21")]))
   ID       CL       V1        Q       V2        K10       K12        K21
1   1 4.269122 34.27204 8.900905 91.17486 0.12456574 0.2597133 0.09762455
11  2 5.684280 42.37495 8.900905 91.17486 0.13414246 0.2100511 0.09762455
21  3 4.786122 51.33898 8.900905 91.17486 0.09322589 0.1733752 0.09762455
31  4 3.070183 27.35196 8.900905 91.17486 0.11224727 0.3254211 0.09762455
41  5 5.614791 44.67357 8.900905 91.17486 0.12568487 0.1992432 0.09762455
51  6 7.805920 41.54366 8.900905 91.17486 0.18789679 0.2142542 0.09762455

Peak and AUC summaries

head(unique(fit$sdtab[, c("ID", "CMAX", "TMAX", "AUC_0_168")]))
   ID     CMAX TMAX AUC_0_168
1   1 4.214750    1  88.36857
11  2 3.508052    2  65.50441
21  3 3.190077    2  79.24876
31  4 5.129848    1 121.02101
41  5 3.407356    2  66.55003
51  6 3.438284    1  45.33505

Periodic AUC

AUC_TAU changes from interval to interval as the concentration profile accumulates or washes out:

fit$sdtab[fit$sdtab$ID == fit$sdtab$ID[1],
          c("TIME", "TAFD", "AUC_TAU")]
   TIME TAFD   AUC_TAU
1   0.5  0.5 35.689408
2   1.0  1.0 35.689408
3   2.0  2.0 35.689408
4   4.0  4.0 35.689408
5   6.0  6.0 35.689408
6   8.0  8.0 35.689408
7  12.0 12.0 35.689408
8  24.0 24.0 11.635927
9  36.0 36.0 11.635927
10 48.0 48.0  8.208648

See also