Why the Auxiliary Function Must Be Constructed Carefully
In a shared-random-effects joint model, each subject’s longitudinal measurements and event history are conditionally related through latent random effects. The observed-data likelihood integrates those effects out, whereas the complete-data likelihood treats them as if they were observed. The EM algorithm uses the latter to form an objective that can be optimized more easily, but its expectation must be taken using the random-effects posterior at the current parameter values.
This tutorial focuses on constructing that expected complete-data log likelihood, usually called the EM auxiliary function. It is not obtained by simply plugging a posterior mean into the complete-data likelihood: nonlinear terms, including survival contributions, generally require expectations over the full posterior distribution.
Complete-Data Likelihood and the E-Step Distribution
For subject \(i\), let \(y_{ij}\) be the longitudinal outcome at time \(t_{ij}\), for \(j=1,\ldots,n_i\). Let \(T_i\) be the observed event or censoring time and let \(\delta_i=1\) indicate an event and \(\delta_i=0\) indicate right censoring. Let \(b_i\) be the subject’s vector of shared random effects, and write \(O_i\) for all observed data on that subject, including the longitudinal and event-time data and the covariates.
Write \(\theta\) for the full parameter vector. A standard shared-random-effects specification assumes conditional independence of the longitudinal observations and event process given \(b_i\) and covariates. Its subject-specific complete-data log likelihood is
Here \(f_Y\) is the longitudinal conditional density, \(h_i\) is the event hazard, \(H_i(t\mid b_i;\theta)=\int_0^t h_i(u\mid b_i;\theta)\,du\) is the cumulative hazard, and \(f_b\) is the random-effects density. The survival expression is the log event-time contribution for either an observed event or right censoring; when \(\delta_i=0\), the hazard-at-event term is absent. This form assumes censoring is noninformative for the event-time model conditional on the covariates and random effects, or otherwise appropriately handled in the likelihood.
At an EM iteration, denote the current parameter value by \(\theta^{\mathrm{old}}\). The E-step distribution for subject \(i\) is
It is the posterior based on all of that subject’s observed data under the current parameters, not just the longitudinal measurements. The auxiliary function is the sum of expectations of the complete-data log likelihood under these distributions:
The candidate parameter \(\theta\) appears inside the complete-data log likelihood, while the distribution \(q_i\) stays fixed at the current iteration. In expanded form, the expectation applies separately to the longitudinal log-density terms, the survival terms, and the random-effects log-density. Terms constant in \(\theta\) may sometimes be dropped when optimizing, but retaining them makes the construction and comparisons transparent.
What the Expectation Does to Each Model Component
For a Gaussian longitudinal model with conditional mean \(m_{ij}(b_i;\theta)\) and residual standard deviation \(\sigma\), one contribution is
Thus the needed expectation is a posterior expected squared residual. In a linear random-intercept model, it can be calculated from the posterior mean and variance; in more complex models, it may require numerical integration. For survival, the expectation includes both \(E_{\mathrm{old}}[\delta_i\log h_i(T_i\mid b_i;\theta)\mid O_i]\) and \(E_{\mathrm{old}}[H_i(T_i\mid b_i;\theta)\mid O_i]\). The latter is not generally equal to the cumulative hazard evaluated at the posterior mean of \(b_i\).
Worked Example: Expected Gaussian Longitudinal Contribution
Suppose one hypothetical subject has one measurement \(y=2.0\), and the candidate conditional mean is \(1.2+b\). Let \(\sigma=1.5\). For this calculation, suppose the current posterior is \(b\mid O\sim N(0.4,0.09)\), where the second argument is the variance. The expected squared residual is
The expected log-density contribution is therefore
The posterior variance contributes \(0.09\) to the expected squared residual. Substituting only the posterior mean would give a squared residual of \(0.16\), which misses that uncertainty and would produce a different auxiliary-function contribution.
Worked Example: Expected Survival Contribution From Posterior Weights
Consider a hypothetical subject with an event at \(T=2\). Conditional on \(b\), suppose the hazard is constant in time and equals \(0.2\exp\{(\log 2)b\}\). For this illustration, approximate the current posterior by two quadrature points: \(b=0\) with weight \(0.4\), and \(b=1\) with weight \(0.6\). These weights sum to one. At a constant hazard, the event contribution is \(\log h(T\mid b)-2h(T\mid b)\).
At \(b=0\), \(h=0.2\), so the contribution is \(\log(0.2)-0.4\). At \(b=1\), \(h=0.4\), so it is \(\log(0.2)+\log(2)-0.8\). Average the contributions using the posterior weights, keeping the unrounded values:
This is a posterior-weighted expectation of the log survival contribution. It is not the log of a posterior-weighted mean hazard or likelihood. The quadrature approximation is appropriate only to the extent that its nodes and weights adequately represent the posterior for this expectation.
Why This Construction Supports EM
The role of \(Q\) follows from a likelihood identity. Let \(p_\theta(b\mid O)\) be the posterior of the random effects under a candidate \(\theta\). For any fixed density \(q(b)\) supported where this posterior is positive, the Kullback–Leibler divergence is \(D_{\mathrm{KL}}(q\|p_\theta)=\int q(b)\log\{q(b)/p_\theta(b\mid O)\}\,db\), which is nonnegative. Since \(p_\theta(O,b)=p_\theta(O)p_\theta(b\mid O)\), rearranging gives
Set \(q\) equal to the posterior at \(\theta^{\mathrm{old}}\). The entropy term \(-\int q\log q\) is then constant as \(\theta\) varies. At \(\theta^{\mathrm{old}}\), the divergence is zero. Consequently,
Because the final term is nonnegative, increasing \(Q\) from its value at the current parameter cannot decrease the observed-data log likelihood. This justification depends on using the actual current posterior for the E-step and the same complete-data model in both the expectation and the observed-data likelihood. The identity explains why constructing \(Q\) correctly matters; it does not require that every expectation have a closed form.
Worked Example: Assembling All Three Expected Contributions
Consider a hypothetical subject with two longitudinal measurements, \(y_1=1.8\) and \(y_2=2.4\), whose candidate means are \(1.2+b\) and \(1.7+b\). Let both residual standard deviations be \(1\), and suppose the current posterior is \(b\mid O\sim N(0.3,0.04)\). The candidate random-effects distribution is \(b\sim N(0,0.5)\). The subject is censored at time \(2\), with candidate hazard \(0.1\exp\{(\log 2)b\}\).
For the longitudinal term, the residual offsets before subtracting \(b\) are \(0.6\) and \(0.7\). Their posterior expected squares are \(0.3^2+0.04=0.13\) and \(0.4^2+0.04=0.20\). Thus the sum is \(0.33\), and the expected longitudinal log likelihood is
For the random-effects density, \(E_{\mathrm{old}}[b^2\mid O]=0.3^2+0.04=0.13\), giving
There is no event log-hazard term because \(\delta=0\). For the cumulative hazard, the normal moment-generating formula gives \(E[\exp(cb)]=\exp\{c(0.3)+c^2(0.04)/2\}\), with \(c=\log 2\). Therefore the expected survival contribution is
The subject’s full expected complete-data log likelihood is the sum of the three contributions, approximately \(-2.003-0.7024-0.2486=-2.954\). Each component has been averaged under the same current posterior, while its density or hazard uses the candidate parameters.
Approximations, Diagnostics, and Common Pitfalls
When posterior expectations are not available analytically, they may be evaluated by numerical integration, such as quadrature over the random effects. The earlier material on Gauss–Hermite quadrature and posterior-focused integration provides the numerical integration tools; here the key requirement is to apply the approximation to the expectation of the complete-data log-likelihood terms under the current posterior. Check that posterior weights are normalized, that estimates are stable as integration accuracy is increased, and that each term uses the same posterior approximation.
Direct maximization of the integrated observed-data likelihood is a main alternative: it targets the same likelihood without constructing an EM auxiliary function, but it requires evaluating the integrated likelihood as parameters vary. EM instead separates posterior expectation from maximization. Its auxiliary function may still require numerical integration, and it need not have closed-form updates. The purpose of this tutorial is to construct \(Q\), not to derive parameter-specific M-step updates.
Common warning signs include a Q value that changes when only the candidate parameter is changed inside the E-step posterior, quadrature weights that do not sum to one, and a survival expectation computed only at the posterior mean despite a nonlinear hazard. A further diagnostic is to compare the component-wise sum with a direct numerical expectation of the full complete-data log likelihood at a test parameter.
- Wrong reasoning: “The random effect is unobserved, so I can replace it everywhere by its posterior mean and evaluate the complete-data log likelihood there.”
- Correction: The auxiliary function is an expectation of the log likelihood over the full current posterior. Posterior variance and nonlinear functions of the random effects can affect that expectation, as the worked calculations show.
- Wrong reasoning: “For each candidate parameter, I should recompute the posterior inside \(Q\).”
- Correction: In the E-step, form the posterior using \(\theta^{\mathrm{old}}\). Hold it fixed while evaluating \(Q(\theta\mid\theta^{\mathrm{old}})\); update the posterior at the next iteration.
Check Your Understanding
Answer each question, then compare with the solutions below.
- In \(Q(\theta\mid\theta^{\mathrm{old}})\), which parameter value determines the random-effects posterior, and which parameter value appears in the complete-data log likelihood?
- If \(b\mid O\sim N(0.2,0.09)\), calculate \(E[(0.5-b)^2\mid O]\).
- Why is the survival cumulative hazard generally averaged over the posterior rather than evaluated at the posterior mean of \(b\)?
- For a censored subject with \(\delta=0\), which part of \(\delta\log h(T\mid b)-H(T\mid b)\) remains?
Solutions. (1) The posterior uses \(\theta^{\mathrm{old}}\); the complete-data log likelihood uses the candidate \(\theta\). (2) The posterior mean is \(0.2\) and variance is \(0.09\), so \(E[(0.5-b)^2]=(0.5-0.2)^2+0.09=0.18\). (3) The cumulative hazard can be nonlinear in \(b\), so in general \(E[H(T\mid b)\mid O]\ne H(T\mid E[b\mid O])\). (4) Only \(-H(T\mid b)\) remains, since \(\delta=0\).