Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Class Membership Versus Shared Random Effects

Latent Class Joint Models · Tutorial 446 of 697

Class Membership Versus Shared Random Effects

Learn how class membership and shared random effects represent different kinds of subject heterogeneity, and what scientific assumptions follow from each choice.

Advanced 11 min read

What You'll Learn

  • Distinguish discrete latent classes from continuous subject-specific random effects.
  • State the conditional longitudinal and event models used to represent each form of heterogeneity.
  • Explain how shared random effects can link longitudinal measurements with event risk.
  • Interpret the assumptions behind combining classes and continuous random effects.
  • Use the law of total variance to separate within-class and between-class variation.
  • Recognize diagnostics and scientific misinterpretations that can arise from either representation.

Two Representations of Subject Heterogeneity

People can differ in their longitudinal trajectories and their event risks. A model must specify how it represents that variation. A latent-class model represents it using a finite set of qualitatively distinct groups. A shared-random-effects model represents it using continuous subject-specific deviations that enter both the longitudinal and event components. These are different scientific descriptions, not interchangeable labels for “unobserved differences.”

Let \(Y_{ij}\) denote the longitudinal measurement for subject \(i\) at time \(t_{ij}\), and let \(T_i\) and \(\delta_i\) denote the event time and event indicator. Let \(X_i\) denote baseline covariates. A latent class \(C_i\) takes one of \(K\) values, while \(b_i\) is a vector of continuous random effects. The class-specific trajectory and event-risk specifications established in earlier material provide the building blocks for this comparison.

Definition: A latent class is an unobserved categorical subject-level variable \(C_i\in\{1,\ldots,K\}\). It assigns a subject to one of a finite number of modeled subpopulations. A shared random effect is a continuous subject-level random variable or vector \(b_i\) that appears in both the longitudinal and event models, thereby allowing those outcomes to be associated through the subject’s latent deviation.

A class is usually treated as stable over the observation period: a subject belongs to one class, even though the class is not directly observed. In contrast, a random effect represents a subject’s position on a continuous scale, such as a higher-than-average intercept or slope. A model with random effects does not, by itself, divide subjects into a finite number of types.

What the Models Assume

A simple class-only model specifies a class probability \(\pi_{ic}=P(C_i=c\mid X_i)\), class-specific longitudinal means, and class-specific event risks. For example, a longitudinal distribution might be written

$$ Y_{ij}\mid C_i=c,X_i \sim N\!\left(m_c(t_{ij},X_i),\sigma_c^2\right). $$

The event model may likewise depend on \(c\), for example through a class-specific baseline hazard \(h_{0c}(t)\). Conditional on class and modeled covariates, a class-only formulation generally assumes that the remaining longitudinal and event outcomes have no additional subject-level dependence. That is a substantive assumption, not an automatic consequence of using classes.

A shared-random-effects model instead allows continuous deviations. A representative longitudinal component and event hazard are

$$ Y_{ij}\mid b_i,X_i \sim N\!\left(m(t_{ij},X_i)+Z_{ij}^{T}b_i,\sigma^2\right), \qquad h_i(t\mid b_i,X_i)=h_0(t)\exp\!\left\{\gamma^T X_i+\alpha^T b_i\right\}. $$

Here \(Z_{ij}\) specifies how the random effects affect the measurement, and \(\alpha\) specifies how they affect event risk. For example, a random intercept can shift a subject’s measurements upward and, through a nonzero corresponding element of \(\alpha\), increase or decrease that subject’s hazard. The association is modeled through \(b_i\); it does not assert that a measured biomarker causes the event.

These formulations require assumptions to be made explicit. Subjects are typically assumed independent of one another, conditional on the model and covariates. A random-effects model specifies a distribution for \(b_i\), commonly a mean-zero multivariate normal distribution with a covariance matrix. A class model specifies class probabilities and a finite set of class-specific distributions or parameters. For either approach, censoring must be noninformative conditional on the variables included in the model if the event-time analysis is to use the censoring mechanism in the usual way. A shared-effects formulation further assumes that the modeled shared effects adequately capture the relevant residual dependence between longitudinal and event outcomes.

How the Representations Differ

FeatureLatent classesShared random effects
Subject heterogeneityMembership in one of a finite number of groupsContinuous deviations from a population pattern
Within-group variationMay remain after class membership is specifiedRepresented by the random-effects distribution and residual variation
Longitudinal–event linkCan arise because both components depend on the same classArises through continuous effects shared by both components
Scientific interpretationSubpopulations with distinct modeled profilesA graded continuum of subject-specific deviations

A class-only model can induce an association between measurements and event risk if both vary across classes. But it does so by asserting a finite grouping structure. A shared-random-effects model can induce association without asserting such groups. Its interpretation depends on the random-effects distribution and on which effects are shared. In particular, if \(\alpha=0\), the random effects in the displayed hazard do not link \(b_i\) to event risk, even if they explain longitudinal variation.

Why Mixtures Can Look Like Continuous Variation

The law of total variance makes one distinction precise. Let \(Y\) be a measurement with class-specific mean \(\mu_c\) and within-class variance \(v_c\), and let \(P(C=c)=\pi_c\). Then

$$ \operatorname{Var}(Y) = E\{\operatorname{Var}(Y\mid C)\} + \operatorname{Var}\{E(Y\mid C)\} = \sum_{c=1}^{K}\pi_c v_c + \sum_{c=1}^{K}\pi_c(\mu_c-\bar{\mu})^2, \qquad \bar{\mu}=\sum_{c=1}^{K}\pi_c\mu_c. $$

The first term is average variation within classes; the second is variation between class means. A continuous random-intercept model can also produce variation in the marginal measurements. Therefore, matching a model to the overall variance alone cannot determine whether the underlying heterogeneity is discrete or continuous. The distribution’s shape, the time pattern, the event association, and the scientific question all matter.

Worked Example: Separating Within-Class and Between-Class Variation

Suppose a hypothetical population has two latent trajectory classes. Class 1 has probability \(0.60\) and a measurement mean of \(0\) units; class 2 has probability \(0.40\) and a mean of \(4\) units. Assume each class has variance \(1\) square unit. These values describe a simple class model with equal within-class variances.

The overall mean is \(\bar{\mu}=0.60(0)+0.40(4)=1.6\) units. The within-class contribution to variance is \(0.60(1)+0.40(1)=1\) square unit. The between-class contribution is \(0.60(0-1.6)^2+0.40(4-1.6)^2=0.60(2.56)+0.40(5.76)=3.84\) square units.

Thus the total variance is \(1+3.84=4.84\) square units. Most of the variation in this example is between the two class means. A continuous random-effects model could be constructed to have the same overall variance, but that equality would not establish that the two models describe the same kind of population structure. The class representation posits two groups; the continuous representation posits graded deviations.

The decomposition is a justification for examining both sources of variation rather than treating an overall variance estimate as evidence for a particular representation. It follows directly from \(\operatorname{Var}(Y)=E(Y^2)-E(Y)^2\), by conditioning the first moment and variance on \(C\).

When Both Forms of Heterogeneity Are Plausible

A scientific setting may suggest both broad subpopulations and meaningful variation within each subpopulation. Conceptually, a combined model assigns a class \(C_i\) and also allows a continuous effect \(b_i\) within that class. The class can distinguish broad trajectory or risk patterns, while \(b_i\) can represent subject-specific departures around the pattern. One possible conceptual specification is

$$ Y_{ij}\mid C_i=c,b_i,X_i \sim N\!\left(m_c(t_{ij},X_i)+Z_{ij}^{T}b_i,\sigma_c^2\right), \qquad h_i(t\mid C_i=c,b_i,X_i) = h_{0c}(t)\exp\!\left\{\gamma_c^T X_i+\alpha^T b_i\right\}. $$

This equation illustrates a combined representation; it is not a claim that every application needs both components. It implies finite class structure and continuous within-class heterogeneity. The distribution of \(b_i\) may itself depend on class, so the analyst must state whether its mean or covariance differs across classes. The substantive interpretation also depends on the conditional-independence assumptions: after conditioning on \(C_i\), \(b_i\), and covariates, any remaining dependence between repeated measurements and the event must be addressed or judged negligible.

Worked Example: Interpreting a Shared Random Effect

Consider a hypothetical shared-random-effects model in which \(b_i\) is a random intercept measured in biomarker units, and its coefficient in the log hazard is \(\alpha=0.5\) per biomarker unit. Compare two otherwise identical subjects whose random intercepts differ by \(2\) units. Assume the hazard model and the shared-effect specification are appropriate for this comparison.

The conditional hazard ratio for the subject with the higher random intercept relative to the lower one is \(\exp\{0.5(2)\}=\exp(1)=2.718\). Thus, conditional on the modeled covariates and the random effects, the higher-intercept subject has an estimated instantaneous event hazard about 2.72 times as large. This is not a 2.72-fold change in event probability, and it is not a causal effect of increasing the biomarker. It is the model’s conditional association induced by the shared random effect.

Worked Example: Interpreting a Combined Representation

Suppose a hypothetical combined model has class probabilities \(0.70\) and \(0.30\), class-specific mean biomarker levels of \(1\) and \(5\) units, and a within-class random-intercept variance of \(0.25\) square units in both classes. Let the measurement residual variance be \(0.75\) square units. Assume the random intercept and residual are independent conditional on class, so their variances add.

The within-class measurement variance is \(0.25+0.75=1\) square unit. The population mean is \(0.70(1)+0.30(5)=2.2\) units. The between-class contribution is \(0.70(1-2.2)^2+0.30(5-2.2)^2=0.70(1.44)+0.30(7.84)=3.36\) square units. The total variance is therefore \(1+3.36=4.36\) square units.

The class labels describe the separation between broad mean profiles; the random intercept describes additional continuous variation within either class. If the event hazard also depends on that random intercept, the model permits within-class differences in event risk as well. These components have different interpretations and should not be collapsed into a single statement that “the model finds two types.”

Diagnostics, Alternatives, and Limitations

The choice should be guided by the scientific structure and checked against observed patterns. A class model may be inadequate if substantial continuous variation remains within its modeled groups, or if a few classes fail to capture smooth variation. A random-effects model may be inadequate if the assumed continuous distribution is a poor description of sharply separated patterns or if residual dependence with event risk remains. In either case, useful warning signs include systematic trajectory residual patterns, poor fit across event-risk strata, implausible variance estimates, and estimates that change greatly under reasonable modeling choices. These signs motivate investigation; they do not, by themselves, identify the correct representation.

The main alternative to a class representation is a continuous random-effects representation; the main alternative to a shared-effects representation is to model the longitudinal and event components without a shared latent source, if conditional independence is scientifically defensible. A combined model is an additional option when both kinds of heterogeneity are credible, but it requires more assumptions and parameters. It may be difficult to distinguish class separation from broad continuous variation using limited or noisy data. No representation should be selected solely because it yields a preferred scientific story or a better in-sample fit.

A common mistake is to interpret estimated classes as objectively existing biological types. The correction is that classes are features of a specified statistical model: evidence for them depends on the measurement schedule, the assumed distributions, covariates, and other modeling choices. Likewise, a random effect is not automatically a measured trait or a causal mechanism. It is a model-based latent quantity. Interpret either representation as a useful description of heterogeneity only to the extent that its assumptions and diagnostics support that use.

Key takeaway: Classes represent finite categorical heterogeneity; shared random effects represent continuous subject-level heterogeneity that links the longitudinal and event components. A combined model asserts both, so its additional flexibility must be matched by scientific justification and adequate data.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. What scientific distinction does a latent class make that a continuous random intercept does not?
  2. In a shared-effects hazard model, what does \(\alpha=0\) imply about the link through \(b_i\)?
  3. For two classes with probabilities \(0.5\) and \(0.5\), means \(2\) and \(6\), and within-class variances \(1\) and \(1\), calculate the total variance.
  4. Why does a combined class-and-random-effects model require more assumptions than either representation alone?
  5. A fitted model identifies two classes. Why is it not automatically justified to call them two real biological types?

Solutions. (1) A class asserts membership in one of finitely many groups; a random intercept represents graded continuous subject-specific deviations. (2) The random effects do not link longitudinal variation to event risk through the displayed hazard term, because its contribution is multiplied by zero. (3) The overall mean is \(0.5(2)+0.5(6)=4\). The between-class variance is \(0.5(2-4)^2+0.5(6-4)^2=4\), and the within-class contribution is \(1\); total variance is \(5\) square units. (4) It posits both finite class structure and continuous within-class effects, including assumptions about the random-effects distribution and how those effects relate to each component. (5) Classes are model-dependent representations of heterogeneity; their existence and interpretation depend on the assumptions and data, not just on the fitted labels.

Clinical Biostats