Why Use EM for a Latent Class Joint Model?
In a latent class joint model, each subject belongs to one of a fixed number of unobserved classes. The class affects both the longitudinal measurements and the event-time distribution. Because class membership is not observed, the likelihood sums over possible classes for each subject. That sum can make direct maximization inconvenient. The expectation-maximization (EM) algorithm handles it by alternating between estimating each subject’s class probabilities and fitting the model components using those probabilities as weights.
The weights are not hard assignments: a subject may contribute partly to several classes. This preserves uncertainty about class membership during estimation. The algorithm is an optimization method for the specified likelihood; by itself, it does not establish that the chosen number of classes or model form is appropriate.
Model and Assumptions
Suppose there are \(n\) independent subjects and \(G\) classes. Subject \(i\) has longitudinal data \(y_i=(y_{i1},\ldots,y_{im_i})\), event or censoring time \(t_i\), event indicator \(\delta_i\), and possibly baseline covariates \(x_i\). Here \(\delta_i=1\) denotes an event and \(\delta_i=0\) denotes right censoring. Let \(Z_{ig}=1\) if subject \(i\) belongs to class \(g\), and \(Z_{ig}=0\) otherwise. Exactly one \(Z_{ig}\) is 1 for each subject.
Let \(\pi_{ig}(\alpha)=P(Z_{ig}=1\mid x_i)\) be the class probability, with \(\sum_{g=1}^G\pi_{ig}(\alpha)=1\). Write \(f_g(y_i\mid x_i;\theta_g)\) for the longitudinal-data contribution and \(h_g(t_i,\delta_i\mid x_i;\psi_g)\) for the event-data contribution in class \(g\). Their product is the class-specific contribution \(L_{ig}\). The model assumes that, conditional on class and included covariates, the joint contribution factors into these longitudinal and event components. Subjects are independent, and censoring is noninformative for the event model conditional on the modeled information.
For a right-censored event time with class-specific hazard \(\lambda_g(t\mid x_i;\psi_g)\) and cumulative hazard \(\Lambda_g(t\mid x_i;\psi_g)\), the event contribution is
The observed-data likelihood and log likelihood are
where \(\Theta\) collects all model parameters. The EM algorithm treats the unobserved indicators \(Z_{ig}\) as missing data. The model assumptions must be considered before applying the algorithm: EM maximizes the likelihood that was specified, not a more general model that might better describe dependence or censoring.
The E-Step: Class Responsibilities
At iteration \(r\), evaluate the class probabilities and class-specific contributions at the current estimates, denoted \(\pi_{ig}^{(r)}\) and \(L_{ig}^{(r)}\). Bayes’ rule gives the conditional probability that subject \(i\) is in class \(g\), given the observed data and current estimates. This probability, also called the responsibility, is
For each subject, \(0\leq \tau_{ig}^{(r)}\leq 1\) and \(\sum_g\tau_{ig}^{(r)}=1\). The E-step does not change the model parameters. It computes the expected latent class indicators under the current estimates.
Worked Example: Calculating Responsibilities
Consider three hypothetical subjects and two classes. Suppose the current class probabilities are \(0.6\) and \(0.4\) for everyone. The class-specific joint contributions \(L_{i1},L_{i2}\) are \((0.8,0.2)\), \((0.3,0.9)\), and \((0.1,0.7)\), respectively.
For subject 1, the two weighted contributions are \(0.6(0.8)=0.48\) and \(0.4(0.2)=0.08\). Thus \(\tau_{11}=0.48/(0.48+0.08)=0.8571\), and \(\tau_{12}=0.08/0.56=0.1429\).
For subject 2, they are \(0.6(0.3)=0.18\) and \(0.4(0.9)=0.36\), giving \(\tau_{21}=0.18/0.54=0.3333\) and \(\tau_{22}=0.6667\). For subject 3, they are \(0.06\) and \(0.28\), giving \(\tau_{31}=0.06/0.34=0.1765\) and \(\tau_{32}=0.8235\). Each pair sums to 1, as required. These probabilities will weight each subject’s contribution in the M-step.
The M-Step: Maximize the Expected Complete-Data Log Likelihood
If class membership were observed, the complete-data log likelihood would be
The EM algorithm replaces each unobserved \(Z_{ig}\) by its conditional expectation from the E-step. The resulting function to maximize is
When the parameter blocks are separate as written, the M-step maximizes \(Q\) with respect to class-membership, longitudinal, and survival parameters. Each block uses the same responsibilities, but a different weighted log likelihood.
Updates for Class Proportions and Longitudinal Parameters
If class probabilities are constant across subjects, write them as \(\pi_g\), where \(\sum_g\pi_g=1\). The class-proportion part of \(Q\) is \(\sum_g(\sum_i\tau_{ig})\log\pi_g\). Maximizing subject to the sum-to-one constraint gives
Thus the updated proportion is the average responsibility for that class, not the fraction of subjects assigned to it by a hard rule. If class membership is modeled using baseline covariates, for example a multinomial logistic model, the class-membership M-step is a responsibility-weighted multinomial regression. Its coefficients generally require numerical maximization rather than this closed-form update.
For the longitudinal component, the M-step maximizes \(\sum_i\tau_{ig}^{(r)}\log f_g(y_i\mid x_i;\theta_g)\) for each class. Consequently, it is a weighted longitudinal fit, with subject \(i\) receiving weight \(\tau_{ig}^{(r)}\) in class \(g\). The precise update depends on the chosen longitudinal model. For example, if each subject contributes one Gaussian observation \(y_i\) with class-specific mean \(\mu_g\) and variance \(\sigma_g^2\), the updates are the weighted mean and weighted variance:
Worked Example: Updating Proportions and Longitudinal Means
Use the three subjects and responsibilities from the previous example. Suppose their hypothetical single biomarker measurements are 2, 4, and 8 units. The total responsibility for class 1 is \(0.8571+0.3333+0.1765=1.3669\), so its updated proportion is \(1.3669/3=0.4556\). The class 2 total is \(0.1429+0.6667+0.8235=1.6331\), giving \(1.6331/3=0.5444\). The updated proportions sum to 1.
For class 1, the weighted longitudinal mean is \( \{0.8571(2)+0.3333(4)+0.1765(8)\}/1.3669 =(1.7142+1.3332+1.4120)/1.3669 =4.4594/1.3669\approx3.262 \) units. For class 2, it is \( \{0.1429(2)+0.6667(4)+0.8235(8)\}/1.6331 =(0.2858+2.6668+6.5880)/1.6331 =9.5406/1.6331\approx5.842 \) units.
The displayed calculations consistently use responsibilities rounded to four decimal places, so the results are approximate. With the unrounded responsibilities, the values may differ slightly in their last reported digits. A Gaussian-variance update would use the weighted squared residuals about each updated mean, divided by that class’s total responsibility.
Updating Survival Parameters
The survival M-step maximizes \(\sum_i\tau_{ig}^{(r)}\log h_g(t_i,\delta_i\mid x_i;\psi_g)\) for each class. For a parametric model, this is the usual survival log likelihood with fractional subject weights. One useful illustration is a class-specific exponential model with constant hazard \(\lambda_g\), for which \(h_g(t_i,\delta_i)=\lambda_g^{\delta_i}\exp(-\lambda_g t_i)\). The weighted log likelihood is
Setting its derivative with respect to \(\lambda_g\) to zero gives the weighted event-count divided by weighted exposure-time update:
This requires positive weighted exposure time. More generally, a chosen parametric or semiparametric survival specification determines the form of the weighted survival maximization; an update for an exponential hazard should not be used for a different hazard model without derivation.
Worked Example: Updating Exponential Hazards
Suppose the three hypothetical subjects have follow-up times \(t=(2,3,4)\) years and event indicators \(\delta=(1,0,1)\). Use the responsibilities already calculated. For class 1, the weighted event count is \(0.8571(1)+0.3333(0)+0.1765(1)=1.0336\). The weighted exposure is \(0.8571(2)+0.3333(3)+0.1765(4)=1.7142+0.9999+0.7060=3.4201\) years. Therefore, \( \lambda_1^{(r+1)}=1.0336/3.4201=0.3022 \) events per year.
For class 2, the weighted event count is \(0.1429+0+0.8235=0.9664\), and the weighted exposure is \(0.1429(2)+0.6667(3)+0.8235(4)=0.2858+2.0001+3.2940=5.5799\) years. Thus \( \lambda_2^{(r+1)}=0.9664/5.5799=0.1732 \) events per year. These estimates illustrate the class-specific survival M-step; they do not imply that the exponential model is appropriate for all event-time data.
Why the Algorithm Increases the Likelihood
The EM likelihood argument follows from a lower bound. For one subject, put \(a_{ig}=\pi_{ig}L_{ig}\), so that the observed log-likelihood contribution is \(\log\sum_g a_{ig}\). For any probabilities \(q_{ig}\) that sum to 1 and any nonnegative candidate contributions \(a_{ig}\), write
The first inequality holds because it retains only terms with \(q_{ig}>0\); Jensen’s inequality for the concave logarithm gives the second inequality. A positive candidate contribution with \(q_{ig}=0\) is simply omitted, so the bound remains valid. Taking \(q_{ig}=\tau_{ig}^{(r)}\) gives equality at the current parameter values: every positive current contribution has positive posterior responsibility, and the Jensen bound is tight. The lower bound, summed across subjects, differs from \(Q(\Theta\mid\Theta^{(r)})\) only by terms that do not depend on \(\Theta\). Maximizing \(Q\) therefore cannot decrease the observed-data log likelihood. An exact M-step increases or preserves it; a generalized EM step has the same guarantee if it increases \(Q\). This is a monotonicity result, not a guarantee of reaching the global maximum.
Diagnostics, Alternatives, and Limitations
Track the observed-data log likelihood after each full iteration. It should not decrease beyond small numerical rounding error when the E- and M-steps are implemented correctly. Also monitor parameter changes and the largest changes in responsibilities. Use stable log-sum-exp calculations for the denominator in the responsibility formula when likelihood contributions are extremely small; direct multiplication can underflow to zero. Check that responsibilities sum to one and that the M-step uses the same weights consistently across all parameter blocks.
Convergence of the log likelihood alone is not enough to establish a trustworthy fit. A nearly empty class can have a very small total responsibility, making its parameter estimates unstable or poorly determined. Different initial values can lead to different stationary solutions. Run multiple sensible initializations, compare attained log likelihoods, and inspect whether estimates and fitted contributions are numerically plausible. If the likelihood decreases, first check coding, weight normalization, and whether each M-step truly maximizes or increases its weighted objective.
| Approach | How it handles class membership | Main trade-off |
|---|---|---|
| EM | Uses posterior responsibilities as fractional weights. | Often yields simple weighted steps, but may converge slowly near a solution and can stop at a local maximum or other stationary point. |
| Direct observed-likelihood optimization | Maximizes the likelihood with the class sums retained. | Can use general optimization tools, but the objective may be numerically difficult and requires reliable gradients and starting values. |
| Hard assignment followed by separate fits | Assigns each subject to one class, then fits class-specific models. | Discards classification uncertainty and is not, in general, a maximization of the latent class observed-data likelihood. |
EM is a computational strategy, not a remedy for model misspecification. Its weighted updates rely on the stated class-specific longitudinal and survival likelihoods, class-membership model, and censoring assumptions. It may converge slowly, and monotone improvement does not ensure global optimality. The suitability of the number and form of classes, as well as the substantive interpretation of fitted classes, requires separate assessment.
Common Mistakes
- Treating responsibilities as observed class labels. They are conditional probabilities under the current estimates, and generally lie between 0 and 1.
- Updating parameters with hard assignments. This changes the procedure and discards uncertainty; the EM M-step uses \(\tau_{ig}^{(r)}\) as weights.
- Using the new parameters in the same E-step. Compute responsibilities from the current iteration’s parameters, hold them fixed through the M-step, and then recalculate.
- Assuming every M-step has a closed form. Covariate-dependent class probabilities and many longitudinal or survival models require numerical weighted maximization.
- Calling a nondecreasing likelihood proof a global-optimum proof. The guarantee is monotonicity, not global convergence.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- For one subject, the weighted class contributions are 0.12 and 0.08. What are the two E-step responsibilities?
- Three subjects have responsibilities \(0.2,0.5,0.9\) for one class. With constant class proportions, what is that class’s updated proportion?
- For an exponential event model, suppose the weighted event count is 3 and weighted exposure is 15 years. Find the updated hazard and state its units.
- Why does an increasing observed-data log likelihood not show that EM found the global maximum?
Solutions. 1. Divide each contribution by their sum, \(0.12+0.08=0.20\). The responsibilities are \(0.12/0.20=0.6\) and \(0.08/0.20=0.4\). 2. The total responsibility is \(0.2+0.5+0.9=1.6\), so the updated proportion is \(1.6/3=0.5333\). 3. The update is \(3/15=0.2000\) events per year. 4. EM guarantees nondecrease under its assumptions, but the likelihood can have multiple stationary solutions; the result can depend on initialization and need not be the global maximum.