Example 3 — Two-Compartment IV (ADVAN3)
Model: 2-compartment IV bolus, ADVAN3 with micro-rate mapping in $PK, First Order
Script: examples/03_two_compartment_iv.py
Demonstrates estimation with a 2-compartment model on simulated IV data.
Model
result = (
ModelBuilder()
.problem("2-cmt IV ADVAN3 FO")
.data("two_cmt_iv.csv")
.subroutines(advan=3, trans=1)
.pk("""
CL = THETA(1) * EXP(ETA(1))
V1 = THETA(2) * EXP(ETA(2))
Q = THETA(3)
V2 = THETA(4)
K = CL / V1
K12 = Q / V1
K21 = Q / V2
""")
.error("Y = F * (1 + EPS(1))")
.theta([(0.01, 1.6, 30),
(1.0, 8.0, 100),
(0.1, 0.64, 10),
(1.0, 8.0, 100)])
.omega([0.4, 0.4])
.sigma(0.05)
.estimation(method="FO", maxeval=600)
.build()
.fit()
)
Output
openpkpd/estimation/fo.py:114: UserWarning: ETA1 shrinkage is 100.0% (>30%). EBE-based analyses for this parameter may be unreliable.
res.compute_shrinkage()
openpkpd/estimation/fo.py:114: UserWarning: ETA2 shrinkage is 100.0% (>30%). EBE-based analyses for this parameter may be unreliable.
res.compute_shrinkage()
Running FO on 2-cmt IV model...
Method: FO
OFV: -40.8415
AIC: -24.8415
BIC: inf (n_obs = 0)
n_parameters: 8
Converged: True
THETA: [ 1.24529389 94.17357065 0.20316919 3.04172412]
OMEGA (diagonal): [77.09224477 0.99739723]
SIGMA (diagonal): [0.00601016]
ETA shrinkage: ['100.0%', '100.0%']
Shrinkage warnings:
ETA1 shrinkage is 100.0% (>30%). EBE-based analyses for this parameter may be unreliable.
ETA2 shrinkage is 100.0% (>30%). EBE-based analyses for this parameter may be unreliable.
Figures

Biexponential decline
The 2-compartment model produces a biexponential concentration-time profile. On a log scale this appears as two distinct slopes (distribution and elimination phases).
Notes
ADVAN3 uses eigenvalue decomposition of the 2×2 rate constant matrix.
With small sample sizes FO may converge to a local minimum — try FOCE if estimates look unreasonable.
Peripheral compartment initial estimates (
Q,V2) often need careful tuning; start near physiologically reasonable values.