Why an End-to-End Translation Needs More Than Matching Parameter Names
A population-estimation implementation and a simulation engine can use different names, code structures, and event conventions for the same pharmacokinetic model. Translating an oral two-compartment model therefore requires more than copying a parameter table. The translated model must preserve the state definitions, rate equations, parameter meanings, dose routing, bioavailability, and observation calculation. If any of those differ, the two implementations can produce different concentrations even when several parameter values appear to match.
Here the target is a linear, first-order absorption model with a depot, a central compartment, and a peripheral compartment. The purpose is to implement the same individual parameter vector in mrgsolve and verify its predictions against the source implementation. This is a prediction-equivalence exercise: it does not re-estimate the population parameters or compare estimation objectives.
\(dA_g/dt=-k_a A_g\)
\(dA_c/dt=k_a A_g-(CL/V_c+Q/V_c)A_c+(Q/V_p)A_p\)
\(dA_p/dt=(Q/V_c)A_c-(Q/V_p)A_p\)
The predicted central concentration is \(C=A_c/V_c\). The equations assume linear transfer and elimination, first-order absorption, and constant parameters over the prediction interval.
Map the Source Model Before Writing Target Code
First identify what each source parameter means, not just how it is spelled. A source model may use \(V_1\) for central volume and \(V_2\) for peripheral volume, while another uses \(V_c\) and \(V_p\). These are equivalent only if their definitions and units agree. Similarly, \(Q\) must be an intercompartmental clearance, not a rate constant. The model equations divide clearances by volumes to obtain rates with units of inverse time.
| Model quantity | Meaning and units | mrgsolve representation in this example |
|---|---|---|
| \(k_a\) | Absorption rate constant, time\(^{-1}\) | KA |
| \(CL\) | Systemic clearance, volume/time | CL |
| \(V_c\) | Central volume, volume | VC |
| \(Q\) | Intercompartmental clearance, volume/time | Q |
| \(V_p\) | Peripheral volume, volume | VP |
| \(F\) | Fraction of the oral dose reaching systemic circulation | F, applied to the GUT dose |
For an individual prediction, use the same individual parameter values in both implementations. If the estimation model defines an individual parameter from a typical value and an individual effect, evaluate that relationship first and transfer the resulting individual value. Transferring a typical value to one implementation and an individual value to the other is not a test of translation equivalence.
Worked Example: Build the Parameter and Compartment Map
Suppose a hypothetical source model uses \(ka=1.2\) h\(^{-1}\), \(CL=4.5\) L/h, \(V_1=20\) L, \(Q=3.0\) L/h, \(V_2=35\) L, and \(F=0.80\). The source receives a 100 mg oral dose at time zero. Map this model to the notation above.
Set \(k_a=1.2\) h\(^{-1}\), \(CL=4.5\) L/h, \(V_c=V_1=20\) L, \(Q=3.0\) L/h, \(V_p=V_2=35\) L, and \(F=0.80\). The available dose is \(F \times 100=80.0\) mg. The states are amounts, so the depot begins with 80.0 mg after bioavailability is applied, while the central and peripheral amounts begin at zero.
In mrgsolve, one suitable compartment order is GUT, CENT, PERIPH. The corresponding model structure can be expressed with the parameter and compartment declarations “$PARAM KA=1.2, CL=4.5, VC=20, Q=3.0, VP=35, F=0.80” and “$CMT GUT CENT PERIPH”. The differential equations are “dxdt_GUT = -KA*GUT”, “dxdt_CENT = KA*GUT - (CL/VC + Q/VC)*CENT + (Q/VP)*PERIPH”, and “dxdt_PERIPH = (Q/VC)*CENT - (Q/VP)*PERIPH”. In the model’s main block, assign “F_GUT = F” so that an oral event routed to GUT receives the same bioavailability as the source dose.
This mapping preserves both the dimensions and the role of each parameter: \(CL/V_c=0.225\) h\(^{-1}\), \(Q/V_c=0.150\) h\(^{-1}\), and \(Q/V_p=0.08571\) h\(^{-1}\). These rates enter the state equations; they should not be substituted for the clearance parameters in the parameter table.
Implement and Check the Prediction
In mrgsolve, the compartment declarations define the state amounts, the ODE block defines their rates of change, and the table block can calculate the observation from the central amount. For example, the concentration calculation is “capture CP = CENT/VC”. The dose record must be an oral event to GUT, with the same dose amount, time, and bioavailability convention as the source. An oral dose is not an intravenous bolus into CENT: those inputs generate different concentration-time profiles.
A useful independent check comes from deriving the expected concentration under the stated model. Define \(k_{10}=CL/V_c\), \(k_{12}=Q/V_c\), and \(k_{21}=Q/V_p\). The two disposition rates \(\alpha\) and \(\beta\), with \(\alpha>\beta>0\), are the roots of
For a dose \(D\) given orally at time zero, with no lag time and no prior drug in the system, the central concentration is
This expression assumes the rates are distinct, including \(k_a\ne\alpha\) and \(k_a\ne\beta\). If rates coincide, the corresponding limiting expression must be used rather than dividing by zero. The equation provides a numerical reference for the implementation; it does not replace checking event records and units.
Worked Example: Calculate Reference Concentrations
Use the hypothetical parameter values above and calculate the source-model predictions at 1, 4, and 12 hours after a single 100 mg oral dose.
The micro-rates are \(k_{10}=4.5/20=0.225\) h\(^{-1}\), \(k_{12}=3.0/20=0.150\) h\(^{-1}\), and \(k_{21}=3.0/35=0.08571\) h\(^{-1}\). Thus \(k_{10}+k_{12}+k_{21}=0.46071\) h\(^{-1}\) and \(k_{10}k_{21}=0.01929\) h\(^{-2}\). Solving the quadratic gives \(\alpha\approx0.4141\) h\(^{-1}\) and \(\beta\approx0.04657\) h\(^{-1}\). The two central-response coefficients are \((\alpha-k_{21})/(\alpha-\beta)\approx0.8935\) and \((k_{21}-\beta)/(\alpha-\beta)\approx0.1065\). The dose multiplier is \(FDk_a/V_c=(0.80)(100)(1.2)/20=4.8\) mg L\(^{-1}\) h\(^{-1}\).
At 1 hour, substituting these values gives
The same substitution at 4 hours gives \(C(4)\approx1.36\) mg/L, and at 12 hours gives \(C(12)\approx0.291\) mg/L. These are the reference predictions to compare with the source implementation and mrgsolve. Differences in the last displayed digit can arise from rounding; larger discrepancies call for investigation rather than immediate parameter adjustment.
Verify the Dose Semantics and Event Schedule
Prediction equivalence requires equivalent events as well as equivalent equations. Check the dose amount and units, dose time, route or target compartment, bioavailability, any lag time, and the observation times. For repeated dosing, also verify the interval and whether the records represent doses at the same boundaries in both tools. If the source model applies \(F\) within its absorption input, do not apply it a second time to the dose amount in mrgsolve.
Worked Example: Check a Second Oral Dose by Superposition
For the same hypothetical linear model, add a second 100 mg oral dose at 8 hours and compare the predicted concentration at 12 hours with the single-dose result.
Because the model is linear and time-invariant, the total concentration is the sum of the contributions from each dose. At 12 hours, the first dose contributes \(C(12)\approx0.291\) mg/L. The second dose has been in the system for \(12-8=4\) hours, so it contributes \(C(4)\approx1.36\) mg/L. Therefore,
An mrgsolve run with oral events at 0 and 8 hours should give approximately 1.65 mg/L at 12 hours, subject to numerical tolerance and output rounding. If it instead gives roughly 1.36 mg/L, the first dose may have been omitted or the event schedule may be wrong. If it gives a value inconsistent with the sum, inspect dose handling, model linearity, and the state initialization.
Diagnose Mismatches Systematically
The earlier material on testing cross-software prediction equivalence and event equivalence motivates comparing predictions at matched times, but a mismatch is easiest to diagnose by checking the model in layers. First confirm parameter values and units, then the model equations, then the dose events and output calculation. Compare the earliest time points as well as the later profile: an early discrepancy often points to input or absorption, while a discrepancy that develops during the terminal phase can indicate a disposition parameter or state-equation mismatch.
Confirm that time units agree and that clearances, volumes, and rates have not been interchanged. For example, \(CL/V_c\) has units of inverse time, while \(CL\) has units of volume per time.
Confirm that absorption enters CENT from GUT, distribution flows in both directions, and elimination occurs from CENT at rate \(CL/V_c\). Confirm that output uses \(CENT/VC\), not an amount or a peripheral concentration.
Verify oral routing, dose amount, dose times, bioavailability, and any lag. Make sure \(F\) is applied once, not zero times or twice.
Use the same individual parameter vector and event records, evaluate both implementations at the same times, and compare absolute and relative differences against a stated numerical tolerance.
A few common failures have recognizable signatures. A dose mistakenly placed into CENT creates an immediate central amount instead of gradual absorption from GUT. Omitting \(F\) increases exposure when \(F<1\); applying it twice decreases exposure. Confusing \(Q\) with \(Q/V_c\) gives a dimensional inconsistency and can radically change distribution. A concentration reported as CENT without division by \(V_c\) has units of amount, not concentration. Finally, different solver tolerances can cause small numerical differences, but they do not explain a consistent, substantial change in the profile.
What This Translation Does—and Does Not—Establish
There are two useful ways to verify the implementation. Comparing mrgsolve with the source implementation tests that their predictions agree under matched inputs. Comparing both with the analytical expression adds an independent check of the stated linear model. A direct ODE comparison is more flexible for models that lack a closed-form solution; the analytical calculation is valuable here because it can help distinguish an implementation error from a shared coding error.
Neither check establishes that the model is clinically adequate or that the estimated parameters are scientifically appropriate. Equivalence only means that the implementations reproduce the same specified model under the checked conditions. It also does not automatically verify residual-error calculations, likelihoods, random-effects distributions, covariate relationships, or estimation results. Those components require their own checks if they are part of the intended workflow. For this translation, keep the comparison focused on the structural prediction and dose semantics.
Check Your Understanding
Answer each question, then compare your reasoning with the brief solutions.
- If \(Q=3\) L/h and \(V_p=35\) L, what rate appears in the peripheral loss term, and what are its units?
- For a 100 mg oral dose with \(F=0.80\), what amount is available to the model if bioavailability is applied once?
- Why is an oral dose entered into GUT not equivalent to the same dose entered directly into CENT?
- For doses at 0 and 8 hours, which single-dose predictions are added to find the concentration at 12 hours in this linear model?
- Name two checks to make if the target and source predictions differ substantially at early times.
Solutions. (1) \(Q/V_p=3/35=0.08571\) h\(^{-1}\). (2) \(0.80\times100=80.0\) mg. (3) A GUT dose enters the absorption depot and reaches CENT gradually at rate \(k_a\); a CENT dose bypasses absorption and produces a different time course. (4) Add the first dose’s prediction at 12 hours to the second dose’s prediction at 4 hours: approximately \(0.291+1.36=1.65\) mg/L. (5) Check oral routing and dose time, parameter units and values, bioavailability being applied exactly once, and whether observations are calculated as \(CENT/VC\).