Tutorials › Nonlinear Mixed-Effects Models (NLME) › A Worked SAEM Fit for Nonlinear Exponential Decay

The EM and SAEM Algorithms · Tutorial 204 of 797

A Worked SAEM Fit for Nonlinear Exponential Decay

Trace how SAEM uses simulated subject effects and stochastic approximation to estimate population parameters in a nonlinear exponential-decay model.

Advanced 12 min read

What You'll Learn

  • Specify an exponential-decay model with Gaussian subject-specific effects on log amplitude and log rate.
  • Identify the complete-data quantities needed for a SAEM update.
  • Calculate residual sums of squares from simulated subject effects.
  • Apply a stochastic-approximation update to running sufficient statistics.
  • Convert updated statistics into population means, variances, and residual variance.
  • Recognize Monte Carlo noise, poor mixing, and model limitations in a worked fit.

Why Work Through a Nonlinear SAEM Fit?

In an exponential-decay mixed model, each subject has an individual amplitude and decay rate, while the population distribution describes how those subject-specific quantities vary. The conditional mean is nonlinear in the effects, so the conditional expectations required by exact EM are generally not available in closed form. SAEM replaces those expectations with simulated latent effects and smooths the resulting sufficient statistics across iterations.

The goal here is to follow one numerical iteration from simulated effects to updated population parameters. The example is deliberately small and hypothetical; it illustrates the arithmetic, not a real pharmacometric analysis. We assume the latent effects have been generated from their conditional distribution given the observations and current parameters. The method used to generate those draws is a separate implementation issue.

Model and Complete-Data Quantities

There are \(m\) independent subjects. Subject \(i\) is observed at times \(t_{ij}\), for \(j=1,\ldots,n_i\), with total observation count \(N=\sum_i n_i\). Write \(a_i\) for log amplitude and \(b_i\) for log decay rate. The model is

$$ Y_{ij}=\exp(a_i)\exp\{-\exp(b_i)t_{ij}\}+\epsilon_{ij}, \qquad \epsilon_{ij}\sim N(0,\sigma^2). $$

The random-effects distribution is independent across subjects, and within a subject we assume the two effects are independent:

$$ \begin{pmatrix}a_i\\b_i\end{pmatrix} \sim N\left[ \begin{pmatrix}\mu_a\\\mu_b\end{pmatrix}, \begin{pmatrix}\omega_a^2&0\\0&\omega_b^2\end{pmatrix} \right]. $$

The population parameter vector is \(\theta=(\mu_a,\mu_b,\omega_a^2,\omega_b^2,\sigma^2)\). Conditional on the effects, observations are independent normal variables with the stated means and common residual variance. Effects are independent across subjects, and the random-effects covariance is diagonal. These are modeling assumptions, not consequences of SAEM.

Definition: For specified effects \(a_i,b_i\), define the conditional residual sum of squares \(Q(a,b)=\sum_i\sum_j [y_{ij}-\exp(a_i)\exp\{-\exp(b_i)t_{ij}\}]^2\). A convenient set of complete-data quantities is \(\sum_i a_i\), \(\sum_i a_i^2\), \(\sum_i b_i\), \(\sum_i b_i^2\), and \(Q(a,b)\). The first four support the Gaussian random-effects updates; the last supports the residual-variance update.

Ignoring constants that do not depend on the parameters, the complete-data log-likelihood is

$$ \ell_c(\theta;y,a,b)= -\frac{N}{2}\log(\sigma^2)-\frac{Q(a,b)}{2\sigma^2} -\frac{m}{2}\log(\omega_a^2) -\frac{\sum_i(a_i-\mu_a)^2}{2\omega_a^2} -\frac{m}{2}\log(\omega_b^2) -\frac{\sum_i(b_i-\mu_b)^2}{2\omega_b^2}. $$

The nonlinear observation model enters through \(Q(a,b)\). SAEM approximates the conditional expectations of the complete-data quantities using simulated effects, then updates smoothed statistics rather than replacing them with each iteration’s raw simulation.

Worked Example: Residual Sum of Squares for One Set of Effects

Suppose three hypothetical subjects each have observations at \(t=0\) and \(t=1\). Their observed values are respectively \((10.0,6.1)\), \((8.0,5.0)\), and \((12.0,7.0)\). Consider the simulated effects corresponding to amplitudes \((10,8,12)\) and rates \((0.50,0.45,0.55)\). In the model, these mean \(a_i=\log(A_i)\) and \(b_i=\log(k_i)\).

For subject 1 at \(t=1\), the prediction is \(10\exp(-0.50)=6.0653\). Its residual is \(6.1-6.0653=0.0347\), contributing approximately \(0.001204\) to \(Q\). For subject 2 the prediction is \(8\exp(-0.45)=5.1010\), giving residual \(5.0-5.1010=-0.1010\), whose square is approximately \(0.01021\). For subject 3 the prediction is \(12\exp(-0.55)=6.9234\), giving residual \(7.0-6.9234=0.0766\), whose square is approximately \(0.005868\).

At \(t=0\), predictions equal the amplitudes, so the three residuals are all zero for this draw. Therefore \(Q\approx0.001204+0.01021+0.005868=0.01728\). This value is a simulated complete-data statistic, not the observed-data residual sum of squares after integrating over the random effects.

Stochastic Approximation and the M-Step

Let \(s^{(r)}\) be the vector of complete-data quantities calculated from the latent-effect draw at iteration \(r\). Let \(S^{(r)}\) be their running stochastic-approximation values. With gain \(\gamma_r\), the update is

$$ S^{(r)}=S^{(r-1)}+\gamma_r\{s^{(r)}-S^{(r-1)}\}. $$

When \(\gamma_r=1\), the statistic is replaced by the latest simulated value. With a gain between zero and one, the update moves only partway toward that value. The M-step maximizes the expected complete-data log-likelihood represented by the smoothed statistics.

For the Gaussian random effects, write the running statistics as \(S_a,S_{a2},S_b,S_{b2}\). Their M-step updates are

$$ \widehat{\mu}_a=\frac{S_a}{m},\qquad \widehat{\omega}_a^2=\frac{S_{a2}}{m}-\widehat{\mu}_a^2, \qquad \widehat{\mu}_b=\frac{S_b}{m},\qquad \widehat{\omega}_b^2=\frac{S_{b2}}{m}-\widehat{\mu}_b^2. $$

If \(S_Q\) is the running statistic for the residual sum of squares, then \(\widehat{\sigma}^2=S_Q/N\). These formulas presume the diagonal covariance and common residual variance specified above. In an actual implementation, a variance estimate at or below zero signals a numerical or modeling problem; it is not a valid Gaussian variance.

One SAEM Iteration, Calculated

Worked Example: Updating the Population Parameters

Use the same six hypothetical observations and the effects from the preceding example. Suppose the conditional simulation at this iteration yields amplitudes \((10,8,12)\) and rates \((0.50,0.45,0.55)\). Thus the latent draws are \(a=(2.302585,2.079442,2.484907)\) and \(b=(-0.693147,-0.798508,-0.597837)\), to six decimal places. Their raw statistics are

$$ s_a=6.866933,\quad s_{a2}=15.800736,\quad s_b=-2.089492,\quad s_{b2}=1.475477,\quad s_Q=0.01728. $$

For example, \(s_a=\log(10)+\log(8)+\log(12)=6.866933\), and \(s_{a2}=(\log10)^2+(\log8)^2+(\log12)^2=15.800736\). The other two effect statistics are calculated in the same way from the displayed log rates.

Assume the previous running statistics are \(S_a=6.907755\), \(S_{a2}=16.025694\), \(S_b=-2.079442\), \(S_{b2}=1.471359\), and \(S_Q=1.200000\). These are the carried-forward values for this hypothetical iteration. Take \(\gamma_r=0.5\). For the amplitude mean statistic, \(S_a^{(r)}=6.907755+0.5(6.866933-6.907755)=6.887344\). For the amplitude second-moment statistic, \(S_{a2}^{(r)}=16.025694+0.5(15.800736-16.025694)=15.913215\).

Similarly, \(S_b^{(r)}=-2.079442+0.5(-2.089492+2.079442)=-2.084467\), and \(S_{b2}^{(r)}=1.471359+0.5(1.475477-1.471359)=1.473418\). For the residual statistic, \(S_Q^{(r)}=1.200000+0.5(0.01728-1.200000)=0.60864\). The large change in \(S_Q\) reflects the deliberately high starting value, not an error in the arithmetic.

With \(m=3\) and \(N=6\), the updated population estimates are \(\widehat{\mu}_a=6.887344/3=2.295781\) and \(\widehat{\mu}_b=-2.084467/3=-0.694822\). The variance updates are \(\widehat{\omega}_a^2=15.913215/3-(2.295781)^2\approx0.03379\) and \(\widehat{\omega}_b^2=1.473418/3-(-0.694822)^2\approx0.00836\). Finally, \(\widehat{\sigma}^2=0.60864/6=0.10144\), in squared observation units.

The log-scale population means describe the distributions of log amplitude and log rate. For example, \(\exp(\widehat{\mu}_a)\) is the median amplitude under this lognormal model, not its arithmetic population mean. That mean is \(\exp(\widehat{\mu}_a+\widehat{\omega}_a^2/2)\). This distinction matters when translating estimates back to the original scale.

Why Update Statistics Rather Than Parameters Directly?

The stochastic approximation applies to the complete-data statistics. The parameter update is then computed from those smoothed statistics. Smoothing parameter estimates themselves is generally not the same operation: the M-step is nonlinear, as the variance formula’s subtraction of a squared mean makes clear.

Worked Example: A Second Iteration and the Smoothing Distinction

Suppose a subsequent conditional simulation gives log amplitudes \((2.25,2.10,2.50)\). Its raw first and second amplitude statistics are \(s_a=2.25+2.10+2.50=6.85\) and \(s_{a2}=2.25^2+2.10^2+2.50^2=15.7225\). With gain \(\gamma=0.25\) and the previous running values from the worked update,

$$ S_a^{\mathrm{new}}=6.887344+0.25(6.85-6.887344)=6.878008, \qquad S_{a2}^{\mathrm{new}}=15.913215+0.25(15.7225-15.913215)=15.865536. $$

The corresponding mean estimate is \(6.878008/3=2.292669\), and the variance estimate is \(15.865536/3-(2.292669)^2\approx0.0322\). This calculation updates the statistics first and then derives the parameters. It does not average an old variance estimate with a variance calculated from the new draw.

The reason the formulas have this form follows directly from the complete-data likelihood. For \(a_i\), the part involving the population mean and variance is proportional to \(-m\log(\omega_a^2)/2-\sum_i(a_i-\mu_a)^2/(2\omega_a^2)\). Differentiating with respect to \(\mu_a\) and setting the result to zero gives \(\sum_i(a_i-\mu_a)=0\), hence \(\mu_a=\sum_i a_i/m\). Substituting that mean and maximizing with respect to \(\omega_a^2\) gives \(\omega_a^2=\sum_i(a_i-\mu_a)^2/m\), which expands to \(\sum_i a_i^2/m-\mu_a^2\). Replacing the complete-data sums by their smoothed SAEM statistics yields the displayed updates. The same argument applies to \(b_i\). Differentiating the residual part \(-N\log(\sigma^2)/2-S_Q/(2\sigma^2)\) gives \(\sigma^2=S_Q/N\).

Diagnostics, Alternatives, and Limitations

A single SAEM iteration is not expected to improve every statistic monotonically. Simulation noise can make running estimates move up or down, and the observed-data likelihood need not increase at every stochastic iteration. Assess the fit over a run, not from one update alone.

  • Check the simulated effects. Draws that barely change across iterations may indicate inadequate exploration of the conditional distribution. A narrow-looking trace is not reassuring if the sampler is stuck.
  • Inspect the statistics and parameter traces. Persistent large oscillations can indicate excessive simulation noise, an unsuitable gain, or weak information in the data. A variance approaching zero or an implausibly large value warrants investigation.
  • Check the model fit over time. Residual patterns across observation time can reveal a poor exponential-decay description, even when the residual variance update is numerically valid.
  • Assess information in the design. Sparse observations, especially observations over a narrow time range, can make amplitude and decay rate difficult to distinguish. SAEM cannot create information that the sampling design does not contain.

Exact EM uses conditional expectations rather than simulated approximations, but those expectations are often intractable for nonlinear random-effects models. Monte Carlo EM estimates the expectations afresh by simulation at each iteration; SAEM instead recursively smooths sufficient statistics, which can reduce the need for highly accurate Monte Carlo averages at every step. Direct likelihood maximization with numerical integration is another approach, but its reliability depends on accurate integration. These alternatives have different computational and numerical trade-offs; none removes the need to check model fit and identifiability.

The example assumes independent random effects and constant additive residual variance. It does not address correlated effects, alternative residual-error models, or the details of constructing a conditional simulator. Those choices can change the sufficient statistics, M-step, or simulation behavior. In particular, the estimates above are one iteration’s updates and should not be reported as a converged fit.

Common pitfall: Treating the latest simulated effects as if they were the exact conditional expectations, then interpreting their M-step estimates as stable population estimates, ignores Monte Carlo variation. SAEM updates running sufficient statistics using a gain; a fit requires repeated iterations, adequate conditional simulation, and diagnostic assessment.

Check Your Understanding

Use the model and definitions in this tutorial. Solutions are included after the questions.

  1. For \(a_i=\log(10)\), \(b_i=\log(0.5)\), and \(t=1\), calculate the model prediction to three significant figures.
  2. With \(S_a=6.0\), raw statistic \(s_a=6.4\), and gain \(\gamma=0.25\), what is the updated \(S_a\)?
  3. If \(m=4\), \(S_a=8\), and \(S_{a2}=17\), calculate \(\widehat{\mu}_a\) and \(\widehat{\omega}_a^2\).
  4. Why is the residual sum of squares from simulated effects not generally the observed-data residual sum of squares?
  5. What does \(\exp(\mu_a)\) represent under the stated random-effects model?

Solutions. (1) The prediction is \(10\exp(-0.5)=6.065\), or \(6.07\) to three significant figures. (2) \(S_a^{\mathrm{new}}=6.0+0.25(6.4-6.0)=6.1\). (3) \(\widehat{\mu}_a=8/4=2\), and \(\widehat{\omega}_a^2=17/4-2^2=0.25\). (4) The simulated effects are latent variables; the observed-data likelihood or residual assessment accounts for their uncertainty rather than conditioning on one draw. (5) Since amplitude is lognormally distributed, \(\exp(\mu_a)\) is its population median; its arithmetic mean is \(\exp(\mu_a+\omega_a^2/2)\).