Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Specifying Class-Specific Longitudinal Trajectories

Latent Class Joint Models · Tutorial 444 of 697

Specifying Class-Specific Longitudinal Trajectories

Build and interpret class-specific longitudinal mean trajectories, including covariate-dependent slopes and the contrasts that reveal how latent subpopulations differ over time.

Advanced 11 min read

What You'll Learn

  • Specify a longitudinal mean model conditional on latent class membership.
  • Interpret class-specific intercepts, time effects, and class-by-time interactions.
  • Include baseline covariates in both mean levels and rates of change.
  • Calculate predicted class-specific means and trajectory contrasts.
  • Diagnose inadequate time specifications and distinguish mean-model choices from dependence assumptions.

Why Specify a Separate Mean Trajectory for Each Class?

A latent class joint model represents the population as a mixture of subpopulations that are not directly observed. Once class membership is introduced, the longitudinal part of the model must say what mean outcome pattern is expected within each class. The choice of trajectory matters: classes may differ in their average outcome at a reference time, their rate of change, their curvature, or their response to a baseline covariate.

This tutorial focuses on specifying that conditional mean. It does not imply that classes are known groups or that the fitted trajectories are causal effects. Class labels \(g=1,\ldots,G\) are mathematical labels for components of the mixture; the substantive meaning of a class depends on its estimated trajectory pattern and the wider model.

Definition: Let \(C_i\in\{1,\ldots,G\}\) denote the latent class for subject \(i\), \(Y_{ij}\) the continuous longitudinal outcome measured at time \(t_{ij}\), and \(x_i\) a vector of baseline covariates. A class-specific mean trajectory is $$ m_g(t,x)=E(Y_{ij}\mid C_i=g,\ t_{ij}=t,\ x_i=x). $$ It describes the expected outcome at time \(t\) for a subject with covariates \(x\), conditional on belonging to class \(g\).

The class membership model and the longitudinal mean model have distinct roles. A baseline covariate may help describe the probability of class membership, as in the earlier material on modeling class membership with baseline covariates; it may also predict the outcome level or rate of change within a class. Including a covariate in one part does not automatically include it in the other.

Building the Mean Model

For a continuous outcome, a useful starting point is a linear trajectory. Center time at a meaningful reference \(t_0\), and write \(u_{ij}=t_{ij}-t_0\). For one baseline covariate \(x_i\), a model that permits class-specific levels, slopes, covariate effects, and covariate-dependent slopes is

$$ Y_{ij}=m_{C_i}(u_{ij},x_i)+\varepsilon_{ij},\qquad m_g(u,x)=\beta_{0g}+\beta_{1g}u+\gamma_g x+\delta_g xu. $$

Here \(\beta_{0g}\) is the expected outcome in class \(g\) at the reference time for \(x=0\); \(\beta_{1g}\) is the time slope when \(x=0\); \(\gamma_g\) is the covariate difference at the reference time; and \(\delta_g\) is the change in the time slope for a one-unit increase in \(x\). For a binary covariate, \(\gamma_g\) compares covariate groups at \(u=0\), and \(\delta_g\) compares their slopes. The time slope for covariate value \(x\) is \(\beta_{1g}+\delta_gx\).

The more general version replaces \(x\) with a vector of covariates and adds basis functions of time, such as \(u^2\), to represent curvature. The required terms depend on the scientific question. If class trajectories are intended to have different slopes, the model needs class-specific time coefficients, equivalently class-by-time interactions. If slopes may also depend on covariates, the corresponding covariate-by-time terms are needed. A model with class-specific intercepts but a shared time coefficient cannot represent different class-specific linear rates of change.

Model assumptions: The stated mean is assumed to describe the conditional expectation adequately over the observed time range. Covariates and time must be coded meaningfully, and the model assumes that a subject's latent class is stable over the period being modeled. The residuals satisfy \(E(\varepsilon_{ij}\mid C_i=g,x_i,t_{ij})=0\). Their within-subject covariance must be handled appropriately for estimation and uncertainty; specifying a mean curve alone does not assert that repeated observations are independent. A Gaussian outcome model additionally requires a suitable conditional Gaussian error distribution, an assumption not required merely to define the mean.

Centering time changes the interpretation of the intercept without changing the fitted curve when the model is reparameterized correctly. In particular, \(u=0\) makes each class intercept refer to the same clinically interpretable time. A covariate also needs a meaningful reference value: if \(x=0\) is outside the observed range, centering \(x\) can make the intercept and time coefficient easier to interpret.

Worked Predictions and Trajectory Contrasts

Worked Example: Different Class-Specific Linear Slopes

Suppose the hypothetical outcome is a symptom score measured at months since enrollment, and time is centered at enrollment. The fitted means for two classes are \(m_1(u)=12+0.8u\) and \(m_2(u)=9+1.7u\). These equations imply a common outcome scale and use months as the time unit.

At month 3, the predicted means are \(m_1(3)=12+(0.8)(3)=14.4\) points and \(m_2(3)=9+(1.7)(3)=14.1\) points. At enrollment, class 1 has a predicted mean 3 points higher. But class 2 increases 0.9 points per month faster, since \(1.7-0.8=0.9\).

The class difference at month \(u\) is \(m_1(u)-m_2(u)=(12-9)+(0.8-1.7)u=3-0.9u\). It is 0.3 points at month 3 and reaches zero at \(u=3/0.9=3.33\) months. This crossing describes the two fitted means; it does not establish that subjects switch classes or that one class causes a change in symptoms.

The contrast calculation has a simple general form. For two linear class-specific means \(m_g(u)=\beta_{0g}+\beta_{1g}u\), subtracting gives

$$ m_g(u)-m_h(u) =(\beta_{0g}-\beta_{0h})+(\beta_{1g}-\beta_{1h})u. $$

The intercept difference is the class contrast at the reference time; the slope difference determines how that contrast changes per unit of time. Thus a class difference at one visit cannot summarize two trajectories when their slopes differ. For covariate-dependent slopes, the same subtraction applies at the specified covariate value, so any reported contrast should name both time and covariates.

Worked Example: A Baseline Covariate Modifies Change Over Time

Consider a hypothetical two-class model with a binary indicator \(x\), where \(x=0\) denotes the reference group and \(x=1\) the comparison group. In class 1, let \(m_1(u,x)=10+0.5u+2x+0.4xu\). Time is measured in years from baseline, and the outcome is measured in points.

For \(x=0\), the mean is \(10+0.5u\), with slope \(0.5\) points per year. For \(x=1\), it is \(10+0.5u+2+0.4u=12+0.9u\), with slope \(0.9\) points per year. The covariate-group difference at baseline is 2 points; the difference in slopes is 0.4 points per year.

At year 2, the predicted means are \(10+(0.5)(2)=11\) points for \(x=0\) and \(12+(0.9)(2)=13.8\) points for \(x=1\). Their difference is 2.8 points, also obtained as \(2+(0.4)(2)=2.8\). The class label is held fixed in both predictions; these are conditional model means, not unadjusted comparisons between observed groups.

Allowing Curvature and Choosing the Time Basis

A straight line is a modeling choice, not a defining feature of a latent class trajectory. When change plausibly accelerates, slows, or reverses, a quadratic mean can be used: \(m_g(u)=\beta_{0g}+\beta_{1g}u+\beta_{2g}u^2\). Its instantaneous rate of change is \(\beta_{1g}+2\beta_{2g}u\), so \(\beta_{1g}\) is the slope at the reference time, not a constant slope across follow-up. With higher-order polynomials or spline basis functions, each class can have its own coefficients, or some coefficients can be constrained to be shared.

Worked Example: Comparing Curved Class Trajectories

Suppose two hypothetical classes have means, in outcome points, \(m_1(u)=8+2u-0.5u^2\) and \(m_2(u)=7+u\), where \(u\) is years from baseline. At \(u=0\), their means are 8 and 7. The initial rates of change are 2 and 1 points per year, respectively.

At year 2, \(m_1(2)=8+(2)(2)-(0.5)(2^2)=10\) points, while \(m_2(2)=7+2=9\) points. The difference is 1 point. At year 3, \(m_1(3)=8+6-4.5=9.5\) points and \(m_2(3)=10\) points, so the difference is \(-0.5\) points. The first class's modeled rate at year 3 is \(2-(1)(3)=-1\) point per year, while the second remains at 1 point per year. These evaluations show why interpreting \(\beta_{1g}\) alone as the overall trajectory rate would be wrong for a quadratic model.

Restrictions, Diagnostics, and Alternatives

A flexible model can describe meaningful class differences, but adding many class-specific parameters can also make the model difficult to estimate, especially when some classes are small or follow-up is sparse. Begin with a time basis that is scientifically plausible and supported by the measurement schedule. Examine whether fitted means capture the broad observed patterns across time and covariates, and check residual patterns for systematic curvature or time-dependent spread. Compare predictions with the range and timing of actual measurements; polynomial curves can behave implausibly when extrapolated far beyond that range.

Class-specific residual checks require care because class membership is latent, not directly observed. A residual pattern based on a hard assigned class can obscure uncertainty in assignment. Also inspect whether the overall fitted trajectories are driven by a few observations or by extrapolation into poorly supported time-covariate combinations. These checks assess the chosen mean specification; they do not by themselves establish that the number of classes is correct or that the classes have a unique substantive interpretation.

The main alternatives impose different structures. A shared trajectory with class-specific intercepts assumes classes differ in level but not in rate of change. A shared slope is a restriction that can be useful if scientifically justified, but it cannot represent class-specific rates. Separate curves for externally observed groups treat group membership as known, unlike a latent-class model. A shared-random-effects approach represents subject-to-subject variation through continuous latent effects rather than necessarily through distinct trajectory classes. Flexible splines can represent nonlinear time trends, but class-specific spline coefficients increase the number of parameters. These approaches answer different modeling questions rather than serving as interchangeable labels for the same specification.

A frequent pitfall is to interpret a class-specific intercept difference as evidence that the classes remain separated throughout follow-up. With class-by-time interactions, the gap can widen, narrow, or reverse, as the first worked example showed. The correction is to calculate the contrast at the time and covariate values of interest, and to state its units. Another mistake is to interpret a covariate's main-effect coefficient as its difference at every visit: in a model with \(xu\), that difference varies with time.

Key takeaway: Specify a time basis that matches the desired trajectory shape, include class-by-time terms when classes may change at different rates, and report contrasts at explicit times and covariate values. The conditional mean structure does not, by itself, specify residual dependence or explain how class membership is estimated.

Check Your Understanding

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

  1. For \(m_1(u)=5+u\) and \(m_2(u)=8+0.4u\), what is the class difference \(m_1(u)-m_2(u)\) at \(u=2\), and how does the gap change per time unit?
  2. In \(m_g(u,x)=\beta_{0g}+\beta_{1g}u+\gamma_gx+\delta_gxu\), what is the time slope for covariate value \(x\)?
  3. For \(m(u)=6+3u-0.5u^2\), calculate the predicted mean at \(u=2\) and the instantaneous slope there.
  4. Why is a model with class-specific intercepts but a single shared time slope unable to represent different linear rates of change across classes?

Solutions. 1. The difference is \((5-8)+(1-0.4)u=-3+0.6u\); at \(u=2\), it is \(-3+1.2=-1.8\) outcome units. It increases by 0.6 outcome units per time unit. 2. The slope is \(\beta_{1g}+\delta_gx\), obtained by collecting the terms that multiply \(u\). 3. The mean is \(6+(3)(2)-0.5(2^2)=10\); the instantaneous slope is \(3-2(0.5)=2\) outcome units per time unit. 4. A shared time coefficient assigns the same slope to every class; changing intercepts shifts the lines vertically but cannot change their rates of change.

Clinical Biostats