The [derived] block adds computed columns to sdtab after the fit. The [output] block echoes individual PK parameters and covariates into sdtab that would not be there otherwise. Neither block affects estimation — they are pure post-processing.
Model
library (ferx)
ex <- ferx_example ("warfarin_derived" )
ferx_model_show (ex$ model)
# model: warfarin_derived.ferx
# One-compartment oral PK model (warfarin) -- [derived] and [output] demo
[parameters]
theta TVCL(0.2, 0.001, 10.0)
theta TVV(10.0, 0.1, 500.0)
theta TVKA(1.5, 0.01, 50.0)
omega ETA_CL ~ 0.09
omega ETA_V ~ 0.04
omega ETA_KA ~ 0.30
sigma PROP_ERR ~ 0.02 (sd)
[individual_parameters]
CL = TVCL * exp(ETA_CL)
V = TVV * exp(ETA_V)
KA = TVKA * exp(ETA_KA)
[structural_model]
pk one_cpt_oral(cl=CL, v=V, ka=KA)
[error_model]
DV ~ proportional(PROP_ERR)
[derived]
# Per-row: elimination rate and half-life
KE = CL / V
T_HALF = 0.6931472 / KE
# Which dosing day (tau = 24 h)
DAY = floor(TAFD / 24) + 1
TAU_TIME = TAFD mod 24
# Subject-level aggregates (one scalar per subject, repeated across rows)
CMAX = max(IPRED)
TMAX = tmax(IPRED)
# 1e-10 absorbs floating-point residuals when TAD is mathematically 0
CTROUGH = min(IPRED, TAD < 1e-10)
CMAX_D1 = max(IPRED, TAFD < 24)
CMAX_D14 = max(IPRED, TAFD >= 312 && TAFD < 336)
# AUC over first 72 h (fine internal grid, 500 steps)
AUC_0_72 = integral(IPRED, from=0, to=72)
# Periodic AUC: one value per 24-h dosing window
AUC_TAU = integral(IPRED, window=24, anchor=0, step=0.1)
# DV-based AUC (observation times only -- no interpolation)
AUC_DV_72 = integral(DV, from=0, to=72)
[output]
# Echo individual PK parameters (ETAs already automatic)
CL V KA
[fit_options]
method = foce
maxiter = 300
covariance = true
The model adds twelve derived columns covering all three computation kinds:
KE, T_HALF, DAY, TAU_TIME
Per-row
Evaluated at each observation time
CMAX, TMAX, CTROUGH, CMAX_D1, CMAX_D14
Aggregate
One value per subject (last two NaN for single-dose data)
AUC_0_72, AUC_TAU, AUC_DV_72
Integral
Trapezoidal / periodic / DV-based AUC
[output] then adds CL, V, and KA (individual EBE parameter values).
Fit
fit <- ferx_fit (ex$ model, ex$ data, verbose = FALSE )
print (fit)
============================================================
NONLINEAR MIXED EFFECTS MODEL ESTIMATION
============================================================
Model: warfarin_derived Dataset: warfarin
Method: FOCE | Gradient: ANALYTIC | Subjects: 10 | Obs: 110
STATUS: CONVERGED 49 iterations 1.1s
OFV: -280.3595 AIC: -266.3595 BIC: -247.4561
MODEL STRUCTURE (auto-derived)
------------------------------------------------------------
Structural: 1-cpt oral (TVCL, TVV, TVKA)
IIV: ETA_CL, ETA_V, ETA_KA
IOV: none
Residual: proportional
THETA
------------------------------------------------------------
Parameter Estimate SE %RSE
----------------------------------------------------
TVCL 0.132974 0.006628 5.0
TVV 7.730568 0.234046 3.0
TVKA 0.725259 0.124477 17.2
OMEGA (between-subject variability)
------------------------------------------------------------
ETA_CL [log-normal] = 0.028597 (CV% = 17.0) SE = 0.012799
ETA_V [log-normal] = 0.009578 (CV% = 9.8) SE = 0.004298
ETA_KA [log-normal] = 0.348920 (CV% = 64.6) SE = 0.160785
SIGMA (residual error)
------------------------------------------------------------
PROP_ERR [proportional] = 0.010748 (var = 0.000116, CV% = 1.1) SE = 0.000942 [initial specified as SD]
SHRINKAGE
------------------------------------------------------------
ETA_CL: 0.0% ETA_V: 0.2% ETA_KA: 0.0% EPS: 16.0%
DIAGNOSTICS
------------------------------------------------------------
Covariance: computed Cond: 2.6 DW: 2.73 [negative autocorrelation] IWRES lag-1 r: -0.365
RUN INFO
------------------------------------------------------------
Gradient (requested): auto (used: analytic)
ferx v0.4.0.9000 (core v0.4.0)
SETTINGS (model file / call-time override)
------------------------------------------------------------
method foce [model only]
maxiter 300 [model only]
covariance true [model only]
------------------------------------------------------------
1 warning -- call ferx_get_warnings(fit) for details
============================================================
sdtab columns
[1] "ID" "TIME" "DV" "PRED" "IPRED" "CWRES"
[7] "IWRES" "EBE_OFV" "N_OBS" "TAFD" "TAD" "CL"
[13] "V" "KA" "KE" "T_HALF" "DAY" "TAU_TIME"
[19] "CMAX" "TMAX" "CTROUGH" "CMAX_D1" "CMAX_D14" "AUC_0_72"
[25] "AUC_TAU" "AUC_DV_72"
Per-row columns
KE and T_HALF depend only on the subject’s EBE CL/V, so they are constant per subject but appear on every row. DAY increments with each 24-h window.
head (fit$ sdtab[, c ("ID" , "TIME" , "TAFD" , "KE" , "T_HALF" , "DAY" )], 12 )
ID TIME TAFD KE T_HALF DAY
1 1 0.5 0.5 0.01655682 41.86475 1
2 1 1.0 1.0 0.01655682 41.86475 1
3 1 2.0 2.0 0.01655682 41.86475 1
4 1 4.0 4.0 0.01655682 41.86475 1
5 1 8.0 8.0 0.01655682 41.86475 1
6 1 12.0 12.0 0.01655682 41.86475 1
7 1 24.0 24.0 0.01655682 41.86475 2
8 1 48.0 48.0 0.01655682 41.86475 3
9 1 72.0 72.0 0.01655682 41.86475 4
10 1 96.0 96.0 0.01655682 41.86475 5
11 1 120.0 120.0 0.01655682 41.86475 6
12 2 0.5 0.5 0.01860281 37.26035 1
Aggregate columns
CMAX, TMAX, and AUC_0_72 are the same on every row of a subject:
unique (fit$ sdtab[, c ("ID" , "CMAX" , "TMAX" , "AUC_0_72" )])
ID CMAX TMAX AUC_0_72
1 1 11.38196 4 510.6004
12 2 12.10263 8 544.0855
23 3 11.01842 4 514.6880
34 4 13.56277 8 594.5607
45 5 13.82650 4 637.7668
56 6 11.69731 2 521.2644
67 7 10.33760 8 442.3280
78 8 11.78633 4 467.7328
89 9 11.04311 4 563.8744
100 10 11.09479 8 533.2380
Filtered aggregates — CMAX_D1 vs CMAX
CMAX_D1 = max(IPRED, TAFD < 24) restricts the maximum to day-1 observations only. Comparing it against the overall CMAX shows how the peak shifts as the drug distributes:
unique (fit$ sdtab[, c ("ID" , "CMAX" , "CMAX_D1" , "TMAX" )])
ID CMAX CMAX_D1 TMAX
1 1 11.38196 11.38196 4
12 2 12.10263 12.10263 8
23 3 11.01842 11.01842 4
34 4 13.56277 13.56277 8
45 5 13.82650 13.82650 4
56 6 11.69731 11.69731 2
67 7 10.33760 10.33760 8
78 8 11.78633 11.78633 4
89 9 11.04311 11.04311 4
100 10 11.09479 11.09479 8
The model also declares CTROUGH = min(IPRED, TAD < 1e-10) to capture the pre-dose trough, and CMAX_D14 = max(IPRED, TAFD >= 312 && TAFD < 336) for the steady-state day-14 peak. Both are NaN here because the warfarin dataset is a single-dose study (no repeated doses, data ends at 120 h) — TAD never resets to ≈ 0 at an observation time, and no observations fall in the 312–336 h window. These columns are designed for multi-dose designs . For a working trough example see Example: ADDL/multiple-dose .
Periodic AUC (AUC_TAU)
AUC_TAU = integral(IPRED, window=24, anchor=0, step=0.1) produces one value per 24-h dosing window. It changes across windows as the concentration profile evolves:
fit$ sdtab[fit$ sdtab$ ID == fit$ sdtab$ ID[1 ],
c ("TIME" , "TAFD" , "AUC_TAU" )]
TIME TAFD AUC_TAU
1 0.5 0.5 233.53111
2 1.0 1.0 233.53111
3 2.0 2.0 233.53111
4 4.0 4.0 233.53111
5 8.0 8.0 233.53111
6 12.0 12.0 233.53111
7 24.0 24.0 165.74758
8 48.0 48.0 111.39721
9 72.0 72.0 74.86890
10 96.0 96.0 50.31860
11 120.0 120.0 40.41768
DV-based AUC (AUC_DV_72)
AUC_DV_72 = integral(DV, from=0, to=72) uses the observed values at each observation time rather than IPRED. The step= argument is ignored for DV-based integrals (no interpolation between observations):
unique (fit$ sdtab[, c ("ID" , "AUC_0_72" , "AUC_DV_72" )])
ID AUC_0_72 AUC_DV_72
1 1 510.6004 506.8519
12 2 544.0855 540.0808
23 3 514.6880 510.2423
34 4 594.5607 593.2185
45 5 637.7668 632.7343
56 6 521.2644 516.7186
67 7 442.3280 440.5478
78 8 467.7328 464.2751
89 9 563.8744 563.1022
100 10 533.2380 530.3337
[output] — individual parameter columns
CL, V, and KA appear in sdtab because of the [output] block. Without it, only the mandatory minimum columns plus [derived] names would be present:
unique (fit$ sdtab[, c ("ID" , "CL" , "V" , "KA" )])
ID CL V KA
1 1 0.1367467 8.259235 1.1747606
12 2 0.1350429 7.259276 0.5375599
23 3 0.1296689 8.464815 0.9427177
34 4 0.1292000 6.259370 0.3916313
45 5 0.1051902 6.843227 1.3108021
56 6 0.1315764 8.298857 2.8298526
67 7 0.1776028 8.216859 0.4157137
78 8 0.1738634 7.586184 0.7773206
89 9 0.1022817 8.492148 0.8958986
100 10 0.1250834 8.034697 0.4905144