Tutorials › Stochastic Differential Equations in Pharmacokinetics › Known Doses and Infusions in State Prediction

Kalman Filter and Extended Kalman Filter · Tutorial 63 of 100

Known Doses and Infusions in State Prediction

You will learn to propagate a linear Gaussian PK state across known boluses and infusions, and to handle doses that occur at an observation time without shifting the state at the wrong instant.

Advanced 12 min read

What You'll Learn

  • Write a known bolus as a state jump and a constant-rate infusion as a drift input.
  • Derive the affine state prediction over an interval with deterministic input.
  • Propagate the mean and covariance when the input is known.
  • Calculate predictions when boluses occur between observations or at an observation time.
  • Check dose timing, units, and infusion start and stop times for common prediction errors.
  • Compare continuous-time input integration with discrete-time input matrices.

Known Inputs Change the Predicted Mean

A linear state prediction describes how the distribution of a latent pharmacokinetic state changes between observation times. A known dose or infusion contributes to that prediction: it changes the expected state, but, when its amount and timing are known exactly, it does not itself add uncertainty. The distinction is important. A bolus is an instantaneous state jump; a constant-rate infusion is a continuous input over its infusion interval. Treating either one as if it were the other can produce a plausible-looking but incorrectly timed prediction.

Let \(X(t)\) be a \(p\)-dimensional state, such as compartment amounts, and consider an interval \([t_i,t_{i+1}]\) on which the linear stochastic dynamics are \(dX(t)=(AX(t)+Bu(t))dt+L\,dW(t)\). Here \(A\) is a constant \(p\times p\) drift matrix, \(B\) maps the known input \(u(t)\) into the state, \(L\) is a constant diffusion matrix, and \(W(t)\) is a standard Brownian motion of dimension \(r\). Assume the initial state has finite second moments and is independent of future Brownian increments. The input is deterministic and integrable; piecewise-constant infusion rates satisfy this condition. A bolus is handled separately as a jump at its event time.

Definition: A known bolus at time \(\tau\) is represented by \(X(\tau+)=X(\tau-)+Gd\), where \(d\) is the known dose vector and \(G\) maps dose units and route into the state. A known infusion rate \(u(t)\) enters the continuous-time drift through \(Bu(t)\) while the infusion is running. The symbols \(\tau-\) and \(\tau+\) denote the state immediately before and after the event.

For a one-compartment model whose state is amount in the body, \(A=-k\), where \(k\) is the elimination rate constant. An intravenous bolus of amount \(D\) adds \(D\) to that state. An intravenous infusion at rate \(R\) adds \(R\) amount-units per unit time to the drift while it runs. If the state is concentration instead, the dose-to-state mapping must include the appropriate volume. The units of \(G\), \(B\), and \(u(t)\) must agree with the state units.

Deriving the Affine Prediction

Write \(\Delta=t_{i+1}-t_i\) and \(\Phi(\Delta)=e^{A\Delta}\). On an interval without bolus jumps, variation of constants gives \(X(t_{i+1})=\Phi(\Delta)X(t_i)+\int_{t_i}^{t_{i+1}}e^{A(t_{i+1}-s)}Bu(s)\,ds+\int_{t_i}^{t_{i+1}}e^{A(t_{i+1}-s)}L\,dW(s)\). The first integral is the deterministic, input-driven contribution; the second is the process-noise contribution.

Theorem: Under the assumptions above, conditional on \(X(t_i)\), the transition is Gaussian with mean \(\Phi(\Delta)X(t_i)+g_i\) and covariance \(Q(\Delta)\), where \(g_i=\int_{t_i}^{t_{i+1}}e^{A(t_{i+1}-s)}Bu(s)\,ds\) and \(Q(\Delta)=\int_{t_i}^{t_{i+1}}e^{A(t_{i+1}-s)}LL^\mathsf{T}e^{A^\mathsf{T}(t_{i+1}-s)}\,ds\). If \(X(t_i)\) is Gaussian with mean \(m_i\) and covariance \(P_i\), then \(X(t_{i+1})\) is Gaussian with mean \(m_{i+1}=\Phi(\Delta)m_i+g_i\) and covariance \(P_{i+1}=\Phi(\Delta)P_i\Phi(\Delta)^\mathsf{T}+Q(\Delta)\).

To justify the transition, multiply the SDE by \(e^{-A(t-t_i)}\) and apply the product rule. Since this factor is deterministic and differentiable, the resulting differential is \(d(e^{-A(t-t_i)}X(t))=e^{-A(t-t_i)}Bu(t)\,dt+e^{-A(t-t_i)}L\,dW(t)\). Integrating from \(t_i\) to \(t_{i+1}\) and multiplying by \(e^{A\Delta}\) gives the stated representation. The deterministic integral is non-random. The stochastic integral has mean zero and, by the Itô isometry for deterministic integrands, covariance \(Q(\Delta)\). It is Gaussian because its integrand is deterministic and the driving process is Brownian motion. It is independent of \(X(t_i)\) by the assumed independence of future Brownian increments. Therefore the transition conditional on \(X(t_i)\) is Gaussian with the stated mean and covariance. Applying the mean and covariance rules to the affine transformation of the Gaussian \(X(t_i)\) gives the final formulas. \(\square\)

For a constant infusion rate \(u(s)=u_i\) across the whole interval, the input contribution becomes \(g_i=\int_0^\Delta e^{A(\Delta-r)}Bu_i\,dr\). If \(A\) is invertible, this can also be written \(A^{-1}(e^{A\Delta}-I)Bu_i\). The integral expression remains valid whether or not \(A\) is invertible. If the rate starts or stops inside the interval, split the integral at the change time, or evaluate the same integral with the appropriate piecewise value of \(u(s)\).

A useful second fact follows directly from the transition: adding a known bolus changes the mean prediction but not its covariance. Suppose a bolus \(Gd\) occurs at \(\tau\), with no other jump on \([t_i,t_{i+1}]\). Propagate first to \(\tau-\), add the dose, then propagate from \(\tau+\). The dose’s contribution at \(t_{i+1}\) is \(e^{A(t_{i+1}-\tau)}Gd\), while the covariance propagates through the two intervals and their process-noise terms. Because \(Gd\) is deterministic, it contributes zero variance and zero covariance with the state. This composition is exactly the same as applying the transition across the full interval and adding the appropriately propagated dose contribution. Thus event splitting is a valid way to implement the prediction, not an extra source of randomness. \(\square\)

Worked Predictions

Worked Example: A Bolus Between Observation Times

Consider the scalar amount model \(dX(t)=-0.2X(t)\,dt+3\,dW(t)\), with \(X(0)\sim N(80,25)\). A known bolus of 40 amount-units is administered at \(t=1\), and prediction is required at \(t=2\). The state immediately before the dose has mean \(e^{-0.2}(80)\). Immediately after, its mean is \(e^{-0.2}(80)+40\). Propagating the post-dose state for one more time unit gives \(m(2)=e^{-0.2}\{e^{-0.2}(80)+40\}=e^{-0.4}(80)+e^{-0.2}(40)\).

Numerically, \(e^{-0.4}\approx0.670320\) and \(e^{-0.2}\approx0.818731\), so the predicted mean is \(0.670320(80)+0.818731(40)=53.6256+32.7492=86.3748\).

The initial variance contributes \(e^{-0.4}(25)\approx16.7580\) after the first unit, then \(e^{-0.4}(16.7580)\approx11.2332\) after the second. Process noise over the two-unit interval contributes \(Q=9\int_0^2 e^{-0.4(2-s)}\,ds=\frac{9}{0.4}(1-e^{-0.8})\). Since \(e^{-0.8}\approx0.449329\), \(Q=22.5(0.550671)\approx12.3901\). Therefore \(P(2)=11.2332+12.3901=23.6233\). The dose changes the mean, not the variance.

Worked Example: Constant-Rate Infusion Over the Prediction Interval

Let \(X(t)\) be amount, with elimination rate \(k=0.1\) per hour, initial amount \(X(0)=50\), and a constant intravenous infusion \(R=20\) amount-units per hour from hour 0 through hour 3. Ignore process noise for this calculation. The dynamics are \(dX/dt=-0.1X+20\), so \(X(3)=e^{-0.3}(50)+20\int_0^3 e^{-0.1(3-s)}\,ds =e^{-0.3}(50)+\frac{20}{0.1}(1-e^{-0.3})\).

Using \(e^{-0.3}\approx0.740818\), the propagated starting amount is \(0.740818(50)=37.0409\). The infusion contribution is \(200(1-0.740818)=200(0.259182)=51.8364\). Thus \(X(3)\approx37.0409+51.8364=88.8773\) amount-units. The result is below the no-elimination total \(50+20(3)=110\), as expected because some infused and initial amount is eliminated during the interval.

Worked Example: Oral Bolus and Infusion in a Two-State Model

Let \(A_g\) be depot amount and \(A_c\) central amount. An oral bolus of 100 amount-units enters the depot at time 0, while a central infusion of 10 amount-units per hour runs from 0 to 2 hours. Let the absorption rate be \(k_a=0.5\) per hour and the elimination rate be \(k_e=0.2\) per hour. The equations are \(dA_g/dt=-0.5A_g\) and \(dA_c/dt=0.5A_g-0.2A_c+10\), with \(A_g(0+)=100\) and \(A_c(0+)=0\).

The depot trajectory is \(A_g(t)=100e^{-0.5t}\). The central amount at time 2 is the sum of the absorbed oral contribution and the infused contribution: \(A_c(2)=100\frac{0.5}{0.5-0.2}(e^{-0.2(2)}-e^{-0.5(2)})+\frac{10}{0.2}(1-e^{-0.2(2)})\).

Using \(e^{-0.4}\approx0.670320\) and \(e^{-1}\approx0.367879\), the oral contribution is \((50/0.3)(0.670320-0.367879)=166.6667(0.302441)\approx50.4068\). The infusion contribution is \(50(1-0.670320)=50(0.329680)\approx16.4840\). Hence \(A_c(2)\approx50.4068+16.4840=66.8908\) amount-units. This calculation illustrates why a dose entering a depot and an infusion entering the central compartment require different input mappings even when both are known.

Boluses at Observation Times

When a dose time coincides with an observation time, the observation convention must be explicit. The recorded observation may correspond to the state just before administration, \(X(\tau-)\), or just after it, \(X(\tau+)\). The prediction must target the same convention. If the observation is pre-dose, first predict to \(\tau-\), evaluate the observation there, and then apply the jump for subsequent propagation. If it is post-dose, apply the jump before evaluating the state at \(\tau+\). A continuous-time diffusion has no finite-duration evolution between \(\tau-\) and \(\tau+\); the difference is the known jump.

For several known events, order them by time. Propagate to the first event, apply any bolus jump, change the infusion rate if needed, and continue. Events at the same time require a stated convention for their ordering and for whether the observation is pre-event or post-event. In a linear model, additive known boluses at the same time can be combined into one jump, but the observation convention still matters.

1
Propagate to the next event.
Use the transition matrix and the input integral over the interval on which the infusion rate is constant.
2
Apply the event.
Add \(Gd\) for a bolus, and update the infusion rate if it starts, stops, or changes.
3
Match the observation convention.
Use the pre-event state for a pre-dose observation and the post-event state for a post-dose observation.
4
Continue to the prediction time.
Repeat until the desired time is reached, carrying the covariance through each stochastic interval.

Diagnostics, Alternatives, and Limitations

The continuous-time input integral and a discrete-time input matrix are two ways to express the same prediction. For a constant rate on an interval, one can define \(B_\Delta=\int_0^\Delta e^{A(\Delta-r)}B\,dr\) and write the input contribution as \(B_\Delta u_i\). This is convenient in a discrete-time implementation. Replacing \(B_\Delta\) with \(\Delta B\) is generally only an approximation: it ignores the effect of state evolution during the infusion. It may be adequate for a very short interval with slowly changing dynamics, but it is not the exact transition in general.

A practical check is to verify that a zero input gives \(g_i=0\), that a positive infusion increases the state in the intended direction, and that the infusion contribution tends to zero as the interval length tends to zero. For a bolus, check that the jump occurs exactly once and is propagated only over the time after administration. A dose applied at the start of an interval is attenuated over the full interval; a dose at its end is not attenuated before that endpoint. Check units as well: a rate multiplied by time has amount units, while a bolus is already an amount.

Common failures include treating a bolus as a short infusion without specifying its duration, applying a dose both in the initial state and again as an event, integrating an infusion after its stop time, and using a post-dose state when the observation is pre-dose. Another error is adding a known dose to the covariance. Under the stated assumptions, a known deterministic input contributes no uncertainty; uncertainty in dose amount, administration time, or adherence would require a different model.

These formulas rely on linear dynamics with known coefficients and known inputs over the prediction interval. If the input is uncertain or depends on the latent state, it cannot simply be treated as the deterministic \(g_i\) above. If the PK dynamics are nonlinear, the linear Gaussian prediction formulas do not apply directly. The covariance formula also depends on the specified process-noise model; adding a dose does not remove uncertainty already present from the initial state or process noise.

Key takeaway: A known bolus enters the prediction as a timed jump, and a known infusion enters through a time-weighted integral. Both shift the predicted mean; neither adds covariance when known exactly. At an observation time, decide explicitly whether the observation is pre-dose or post-dose.

Check Your Understanding

Try each problem, then check the solutions below.

  1. A one-compartment amount state has \(k=0.2\) per hour. A bolus of 30 units is given at hour 1, and prediction is needed at hour 3. What is the bolus contribution to the predicted mean?
  2. For a scalar model with \(k=0.1\) per hour, calculate the infusion contribution after 2 hours of a constant rate \(R=5\) units per hour.
  3. Does a known bolus increase the state covariance? State the assumption that makes your answer hold.
  4. An observation at the exact bolus time is defined as pre-dose. Which state should be used for that observation, and when should the jump be applied?

Solutions. (1) The dose is propagated for the 2 hours after administration, so its contribution is \(30e^{-0.2(3-1)}=30e^{-0.4}\approx30(0.670320)=20.1096\) units. (2) The contribution is \(R(1-e^{-k\Delta})/k=5(1-e^{-0.2})/0.1=50(0.181269)\approx9.0635\) units. (3) No. If the bolus amount and time are known exactly, it is a deterministic shift and adds zero covariance; existing initial-state and process-noise uncertainty remain. (4) Use \(X(\tau-)\) for the observation, then apply the jump to obtain \(X(\tau+)\) for subsequent propagation.

Clinical Biostats