Margossian 2022 - Nonlinear PKPD and ODE Solvers
Summary
The Friberg-Karlsson semi-mechanistic model couples a PK model to a five-state nonlinear ODE (proliferating cells, three transit compartments, circulating neutrophils) with a feedback term and a drug effect . It needs a numerical ODE solver. Because PK feeds PD one way, Torsten solves PK analytically and only the PD part numerically, which is faster.
Overview
This is the ‘nonlinear ODE inside the likelihood’ case: the posterior is explored by HMC, which needs gradients of the ODE solution with respect to parameters (obtained in Stan by forward sensitivity analysis, per Chen 2018 - Scope, Limitations and Statistical Use).
Main Content
Friberg-Karlsson PK/PD model (eq. 4)
is the mean transit time through three transit compartments. With from the PK model,
, and the absolute neutrophil count likelihood is . The delayed negative feedback holds ANC at baseline ; the drug reduces proliferation. The cap at 1 prevents the feedback loop from flipping sign if is huge during warmup, improving numerical stability. (In the Stan code the states are stored as differences from and is bounded below by machine precision.)
Parameters. PK: ; PD: MTT, , (feedback strength), (linear drug effect); lognormal priors on all; measurement errors (PK) and (PD). The complete system couples eq. (1) (PK) with eq. (4).
Numerical solving in Stan
Define the right-hand side in the functions block; call an ODE solver (RK45 etc.) in transformed parameters, passing parameters and the event times; solve both PK and PD states as one system (8 states: 3 PK + 5 PD). This approach applies to any ODE model.
Coupled solver (Torsten)
One-way coupling exploited by Torsten
The PK (eq. 1) and PD (eq. 4) are coupled through and in only one direction, so PK can be solved independently. Torsten’s
pmx_solve_twocpt_rk45solves the linear PK analytically and passes the PK solution to the PD ODE, which is solved numerically. The numerical ODE then has lower dimension, so the coupled strategy is “in general more efficient”. Only two code changes are needed: the ODE function now returns only PD states, and the solver call changes.
Checks. PPCs must be done for both outputs (PK concentration and neutrophil counts) (Fig. 8); generated quantities can be run on a fitted model without refitting (mod$generate_quantities(fit)).
Section 5: role of Stan/Torsten
Strengths: random effects other than normal, priors beyond those in standard pharmacometric tools, multiple submodels with different random-effect structures. Costs: HMC can be computationally intensive for hierarchical ODE models; Stan’s optimization and variational engines can be slow and error-prone for large population models. Alternatives: PyMC3, TensorFlow Probability, Turing offer similar modelling capability. Part II topics: within-chain parallelism and group solvers, divergent transitions, fake-data simulation and prior predictive checks, solver choice, accuracy control and stability.
Examples
Simulating the neutrophil nadir (SciPy; parameter values illustrative, not the paper’s).
import numpy as np
from scipy.integrate import solve_ivp
circ0, mtt, gamma, alpha = 5.0, 125., 0.17, 0.1 # illustrative, units 1e9/L and hours
ktr = 4/mtt; kprol = ktr
def rhs(t, y, conc):
prol, t1, t2, t3, circ = y
edrug = min(alpha*conc(t), 1.0)
circ = max(circ, 1e-12)
return [kprol*prol*(1-edrug)*(circ0/circ)**gamma - ktr*prol,
ktr*(prol-t1), ktr*(t1-t2), ktr*(t2-t3), ktr*(t3-circ)]
conc = lambda t: 5.0*np.exp(-0.2*(t % 336)) if t < 336 else 0.0 # crude PK drive, one cycle
sol = solve_ivp(rhs, [0, 1000], [circ0]*5, args=(conc,), max_step=2.0)
print(round(sol.y[4].min(), 2), round(sol.y[4][-1], 2)) # 4.69 4.99: nadir below baseline 5.0, then recovery (verified)Illustrative code for understanding the structure; not from the paper.
Relevance to marketing measurement
A delayed negative-feedback mechanism with transit-compartment lags is the pharmacological analogue of distributed-lag adstock with a saturating effect (the cap on mirrors bounded response). The generalization lesson: encode bounds so that sampler excursions do not break the model.
Connections
Likelihoods Built on Differential Equations (Concept Note), Chaos, Rough Likelihoods and Data Assimilation (Concept Note), ODE Filters and Smoothers, Challenge of Multimodality - Differential Equation for Planetary Motion.
See Also
Margossian 2022 - Bayesian Pharmacometrics - Overview, Chen 2018 - Neural ODEs - Overview.