Example: Two-compartment IV
This example fits a two-compartment IV bolus model — the standard starting point for drugs that show a bi-exponential concentration-time profile after intravenous dosing (rapid initial distribution followed by slower elimination).
Typical candidates: monoclonal antibodies, aminoglycosides, vancomycin, and any drug where a one-compartment model leaves systematic curvature in the terminal phase.
Dataset
IV bolus dosing uses the standard NONMEM CSV format. Dose rows have EVID=1 and a non-zero AMT; observation rows have EVID=0 and DV. No KA column is needed — the drug enters the central compartment instantaneously:
ID,TIME,DV,EVID,AMT,CMT,RATE,MDV
1,0,.,1,100,1,0,1
1,0.5,12.3,0,.,1,0,0
1,1,9.8,0,.,1,0,0
1,2,7.4,0,.,1,0,0
1,4,5.1,0,.,1,0,0
1,8,3.6,0,.,1,0,0
1,12,2.9,0,.,1,0,0
Model file
[parameters]
theta TVCL(5.0, 0.1, 100.0)
theta TVV1(15.0, 1.0, 500.0)
theta TVQ(3.0, 0.01, 100.0)
theta TVV2(30.0, 1.0, 500.0)
omega ETA_CL ~ 0.10
omega ETA_V1 ~ 0.10
omega ETA_Q ~ 0.10
omega ETA_V2 ~ 0.10
sigma PROP_ERR ~ 0.01
[individual_parameters]
CL = TVCL * exp(ETA_CL)
V1 = TVV1 * exp(ETA_V1)
Q = TVQ * exp(ETA_Q)
V2 = TVV2 * exp(ETA_V2)
[structural_model]
pk two_cpt_iv_bolus(cl=CL, v1=V1, q=Q, v2=V2)
[error_model]
DV ~ proportional(PROP_ERR)
[fit_options]
method = foce
maxiter = 500
covariance = true
The two_cpt_iv_bolus built-in solves the two-compartment system analytically. All four macro parameters (CL, V1, Q, V2) are estimated; BSV is placed on all four.
Running
library(ferx)
ex <- ferx_example("two_cpt_iv")
fit <- ferx_fit(ex$model, ex$data)
fitTips
- Model selection: compare OFV of the two-compartment model with a one-compartment fit using a likelihood-ratio test (ΔOFV ≥ 3.84 for p < 0.05 with 2 additional parameters: Q and V2).
- Identifiability: Q and V2 are often weakly identified unless sampling extends well into the terminal phase. Collect at least 3–4 samples per subject after Cmax.
- BSV on Q: if
ETA_Qshrinkage is high (> 40 %), consider fixing Q to its population value or dropping BSV on Q.