Tutorials › Stochastic Differential Equations in Pharmacokinetics › Filtering Distributions for Nonlinear State-Space Models

Particle Filters and Bayesian Estimation · Tutorial 68 of 100

Filtering Distributions for Nonlinear State-Space Models

Learn how the latent-state distribution changes as concentration observations arrive, and how filtering differs from prediction and smoothing.

Advanced 11 min read

What You'll Learn

  • Define predictive, filtering, and smoothing distributions by the observations they condition on.
  • Derive the Bayesian prediction and observation-update equations for a nonlinear state-space model.
  • Calculate how a nonlinear concentration measurement changes a two-state filtered distribution.
  • Distinguish a filtered concentration expectation from applying the concentration function to a filtered state mean.
  • Explain why smoothing can revise an earlier state estimate while filtering cannot use future observations.
  • Identify normalization, model, and approximation checks for distributional state estimates.

Three Distributions for a Latent State

A state estimate is not always a single concentration or compartment amount. In a nonlinear state-space model, uncertainty about the latent state is represented by a distribution, and the observations included in that distribution matter. The distribution before processing the current observation is a prediction; after processing it, it is a filter. If observations from later times are also used to infer an earlier state, the result is a smoother.

Let \(Z_k\) denote the latent state at observation time \(k\), and let \(Y_k\) denote the corresponding observation. Write \(y_{1:k}=(y_1,\ldots,y_k)\) for the observed data through time \(k\). A concentration may be a nonlinear function \(h(Z_k)\) of the state, such as the exponential of a log-concentration state.

Definition: The predictive distribution of \(Z_k\) is the conditional distribution of \(Z_k\) given observations only through time \(k-1\), \(p(z_k\mid y_{1:k-1})\). The filtering distribution is the conditional distribution of the current state given observations through the current time, \(p(z_k\mid y_{1:k})\). The smoothing distribution for a state at time \(k\), using observations through time \(T\geq k\), is \(p(z_k\mid y_{1:T})\).

These are distributions, not three names for the same point estimate. In particular, the one-step predictive distribution of the latent state is different from the predictive distribution of the next observation, \(p(y_k\mid y_{1:k-1})\). The latter is obtained by averaging the observation model over the latent-state prediction.

Bayesian Filtering Recursion

Assume a first-order Markov state model and conditionally independent observations: given the state sequence, observation \(Y_k\) depends on the states only through \(Z_k\). Suppose the initial state has a density, the transition from \(Z_{k-1}=z_{k-1}\) to \(Z_k=z_k\) has density \(q_k(z_k\mid z_{k-1})\), and the observation has density \(g_k(y_k\mid z_k)\). Densities are taken with respect to fixed dominating measures. Assume the integrals below exist and the observation normalizing constant is finite and strictly positive. The initial distribution is the filtering distribution at time zero, before observations.

The prediction step propagates the preceding filter through the state transition. The update step weights that prediction by how likely the current observation is at each possible state.

Theorem: Under the stated Markov and conditional-independence assumptions, the predictive density and filtering density satisfy
$$ p(z_k\mid y_{1:k-1}) =\int q_k(z_k\mid z_{k-1})p(z_{k-1}\mid y_{1:k-1})\,dz_{k-1}, \qquad p(z_k\mid y_{1:k}) =\frac{g_k(y_k\mid z_k)p(z_k\mid y_{1:k-1})} {\int g_k(y_k\mid u)p(u\mid y_{1:k-1})\,du}. $$

Derivation. Given the observations through \(k-1\), the Markov property makes the conditional distribution of \(Z_k\) depend on the past state through \(Z_{k-1}\). Integrating over that preceding state gives the prediction by the law of total probability. For the update, the joint conditional density of \(Z_k\) and \(Y_k=y_k\), given \(y_{1:k-1}\), factors as \(g_k(y_k\mid z_k)p(z_k\mid y_{1:k-1})\). Dividing by its integral over \(z_k\) gives the conditional density of \(Z_k\) given \(y_{1:k}\), by Bayes' rule. The denominator is also the one-step predictive observation density \(p(y_k\mid y_{1:k-1})\); its positivity makes the update well-defined. \(\square\)

The recursion is valid for nonlinear transitions and nonlinear observation functions. Nonlinearity generally prevents the distribution from remaining in a convenient finite-dimensional family, but it does not change the definitions or the Bayesian identities. The extended Kalman filter instead propagates an approximate state summary under additional approximations; it is not, in general, the exact nonlinear filtering distribution.

Worked Example: Updating a Nonlinear Concentration Model

Suppose the latent state is binary: \(Z_k=0\) represents log-concentration \(\log(1)\), and \(Z_k=1\) represents log-concentration \(\log(3)\). The corresponding concentrations are \(C_k=\exp(Z_k\log 3)\), namely 1 and 3. Let the transition probabilities be \(P(Z_k=1\mid Z_{k-1}=0)=0.2\) and \(P(Z_k=1\mid Z_{k-1}=1)=0.8\). If the previous filtered probability of state 1 is \(1/3\), calculate the predictive and filtering probabilities after observing \(Y_k=1.5\), where \(Y_k\mid Z_k=i\sim N(C_k,1)\).

Prediction. The predictive probability of state 1 is the probability of entering from either previous state:

$$ P(Z_k=1\mid y_{1:k-1}) =0.2\left(\frac{2}{3}\right)+0.8\left(\frac{1}{3}\right) =0.4. $$

Thus the predictive probabilities of states 0 and 1 are 0.6 and 0.4. For an observation of 1.5, the likelihood under state 0 has mean 1 and the likelihood under state 1 has mean 3. Their common normal-density factor cancels in the update, leaving relative likelihoods \(\exp(-0.5^2/2)\) and \(\exp(-1.5^2/2)\). The high-state likelihood divided by the low-state likelihood is \(\exp(-1)\).

Update. The posterior probability of state 1 is therefore

$$ P(Z_k=1\mid y_{1:k}) =\frac{0.4e^{-1}}{0.6+0.4e^{-1}} \approx 0.197. $$

The probability of state 0 is \(1-0.197=0.803\). The observation shifts probability toward the lower concentration because 1.5 is closer to 1 than to 3. The predictive mean concentration was \(0.6(1)+0.4(3)=1.8\); the filtered mean concentration is approximately \(0.803(1)+0.197(3)=1.394\). Neither mean alone describes the full two-point distribution.

Filtering Is Not Smoothing

A filter uses no observations later than the state time being estimated. A smoother does use later observations, and can consequently revise the inferred distribution of an earlier state. This distinction follows from the same factorization that underlies the filtering recursion.

Theorem: Under the Markov and conditional-independence assumptions, define the future-data likelihood \(\beta_k(z)=p(y_{k+1:T}\mid Z_k=z)\), with \(\beta_T(z)=1\). Then
$$ \beta_k(z)=\int q_{k+1}(u\mid z)g_{k+1}(y_{k+1}\mid u)\beta_{k+1}(u)\,du, \qquad p(z_k\mid y_{1:T}) =\frac{p(z_k\mid y_{1:k})\beta_k(z_k)} {\int p(v\mid y_{1:k})\beta_k(v)\,dv}. $$

Proof. Conditional on \(Z_k=z\), the next state has density \(q_{k+1}(u\mid z)\), and the next observation has density \(g_{k+1}(y_{k+1}\mid u)\). Given \(Z_{k+1}=u\), the remaining observations have likelihood \(\beta_{k+1}(u)\). Integrating their product over \(u\) gives the stated backward recursion. For the smoothing identity, factor the joint conditional density of \(Z_k\) and the future observations given \(y_{1:k}\) as \(p(z_k\mid y_{1:k})p(y_{k+1:T}\mid z_k,y_{1:k})\). The Markov property and conditional independence make the second factor \(\beta_k(z_k)\). Normalizing this product over \(z_k\) yields the conditional density given all observations through \(T\). \(\square\)

The backward factor \(\beta_k\) is large for states that make the future observations plausible. Thus smoothing is not simply filtering performed with a different numerical method: it conditions on a different data set.

Worked Example: A Future Measurement Revises an Earlier State

Let \(Z_1\) and \(Z_2\) each indicate low concentration (state 0, concentration 1) or high concentration (state 1, concentration 3). Suppose \(P(Z_1=1)=0.5\), with transition probabilities \(P(Z_2=1\mid Z_1=0)=0.2\) and \(P(Z_2=1\mid Z_1=1)=0.8\). The first observation has equal likelihood under both \(Z_1\) states, so it leaves \(P(Z_1=1\mid y_1)=0.5\). The second observation is \(y_2=1.5\) with the normal observation model from the previous example.

The likelihood ratio for the second observation, high state versus low state, is \(r=e^{-1}\). Given \(Z_1=0\), the likelihood of \(y_2\) is proportional to \(0.8+0.2r\). Given \(Z_1=1\), it is proportional to \(0.2+0.8r\). Bayes' rule therefore gives

$$ P(Z_1=1\mid y_1,y_2) =\frac{0.5(0.2+0.8e^{-1})} {0.5(0.8+0.2e^{-1})+0.5(0.2+0.8e^{-1})} \approx 0.362. $$

The filtered probability at time 1 remains 0.5, while the smoothed probability is about 0.362. The later observation favors a low state at time 2, which is more likely after a low state at time 1. This is precisely the information unavailable to the time-1 filter.

Nonlinear Concentration Summaries

When the state is transformed to concentration, transform the distribution rather than assuming that a transformed mean is a mean. For a function \(h\), the distribution of \(h(Z_k)\) is the probability assigned to its values by the distribution of \(Z_k\). Its expectation is \(E[h(Z_k)\mid y_{1:k}]\), not generally \(h(E[Z_k\mid y_{1:k}])\). This matters when reporting concentration from a filtered log-state or from a vector of compartment states.

Worked Example: Transforming the State Mean Is Not the Mean Concentration

Use the filtered probabilities from the first example: state 0 has probability 0.803 and log-state 0; state 1 has probability 0.197 and log-state \(\log 3\). Compute both the mean concentration and the concentration obtained by transforming the mean log-state.

The mean log-state is \(0.803(0)+0.197\log 3\), approximately 0.216. Transforming it gives \(\exp(0.216)\approx1.241\). The mean concentration instead is

$$ E[C_k\mid y_{1:k}] =0.803\exp(0)+0.197\exp(\log 3) =0.803+0.591 =1.394. $$

The difference, \(1.394-1.241=0.153\), is a consequence of the nonlinear exponential transformation, not a calculation error. For this distribution, a concentration summary should be computed from the filtered state distribution using the intended concentration function.

Diagnostics, Alternatives, and Limitations

For an exact density update, check that the prediction integrates to one, that the likelihood is evaluated at the correct state-dependent concentration, and that the update denominator is finite and positive. In a numerical approximation, check that reported probabilities or weights normalize to one and that posterior summaries respond in the direction implied by the likelihood. A posterior that barely changes despite a highly discriminating observation may signal a coding, scaling, or likelihood problem; it may also reflect a genuinely diffuse prediction.

The exact recursion is an integral identity, not a promise that the integrals can be evaluated analytically. Linear Gaussian models admit a compact Gaussian recursion. For nonlinear models, an extended Kalman filter uses local approximations; quadrature or grid methods approximate integrals on selected state spaces; particle methods represent distributions with samples and weights. These alternatives differ in computational cost and approximation error. The filtering distribution remains the target object, regardless of the method used to approximate it.

Approximation quality can deteriorate when the state is high-dimensional, when observations are very informative relative to the predictive distribution, or when the transition and observation models are badly misspecified. An apparently precise filtered concentration does not account for uncertainty omitted from the model. Also, predictions for a future observation must average over state uncertainty; substituting only a point estimate into a nonlinear observation function can give a misleading result.

Common pitfall: Calling \(p(z_k\mid y_{1:k-1})\) the filtering distribution, or treating \(p(z_k\mid y_{1:T})\) as a filter, confuses which observations were conditioned on. The correction is to state the time index and the conditioning data explicitly: prediction stops at \(k-1\), filtering at \(k\), and smoothing may use observations beyond \(k\).

Check Your Understanding

Answer each question, then check the solutions below.

  1. At time \(k\), which observations condition the predictive distribution of \(Z_k\)?
  2. If an observation has equal likelihood at every state, what happens to the filtering distribution relative to the predictive distribution?
  3. Why can the smoother for \(Z_k\) differ from the filter even when the observation at time \(k\) is unchanged?
  4. For a nonlinear concentration function \(h\), is \(E[h(Z_k)\mid y_{1:k}]\) generally equal to \(h(E[Z_k\mid y_{1:k}])\)?

Solutions. (1) It is conditioned on \(y_{1:k-1}\), not \(y_k\). (2) The likelihood is a constant multiplier in the Bayes update and cancels with the normalizer, so the filter equals the prediction. (3) The smoother also conditions on future observations, whose likelihood can favor some time-\(k\) states over others through the state transitions. (4) No; equality is not generally valid for nonlinear \(h\). In the worked exponential example, the two values are approximately 1.394 and 1.241.

Clinical Biostats