Tutorials › Nonlinear Mixed-Effects Models (NLME) › The Two-Class NLME Likelihood

Mixture and Latent Subpopulation Models · Tutorial 523 of 797

The Two-Class NLME Likelihood

Learn how class-specific NLME likelihoods combine into a population likelihood when each subject’s metabolizer class is unobserved.

Advanced 9 min read

What You'll Learn

  • Define the class-specific likelihood for a subject by integrating over that subject’s random effects.
  • Construct a two-class likelihood using fast- and slow-class prevalence weights.
  • Derive the subject-level sum from the law of total probability.
  • Distinguish independent subject class assignments from one class shared by an entire sample.
  • Check the order of summation and multiplication in the population likelihood.
  • Recognize the assumptions and limitations behind this likelihood construction.

Why the Likelihood Must Account for Class Uncertainty

When a subject’s metabolizer class is unobserved, the data do not tell us to use only a fast-class model or only a slow-class model for that subject. Instead, the likelihood contribution must account for both possibilities, weighted by their probabilities in the population. This is a statement about the probability model for the observed data, not a rule for assigning a subject to one class.

The key order of operations is: first combine the two class-specific likelihood contributions for each subject; then multiply those subject contributions across independent subjects. Reversing that order corresponds to a different assumption, namely that every subject in the study shares one latent class.

Definition: Let \(i=1,\ldots,N\) index independent subjects and \(j=1,\ldots,n_i\) index observations within subject \(i\). Let \(Z_i\) denote the subject’s unobserved class, with \(Z_i=F\) for fast metabolizer and \(Z_i=S\) for slow metabolizer. Write \(P(Z_i=F)=\pi\) and \(P(Z_i=S)=1-\pi\), where \(0<\pi<1\). If \(L_{iF}\) and \(L_{iS}\) are subject \(i\)’s likelihood contributions under the fast and slow classes, respectively, the two-class subject contribution is \(L_i=\pi L_{iF}+(1-\pi)L_{iS}\). Under independent subjects, the population likelihood is \(L=\prod_{i=1}^{N} L_i\).

What a Class-Specific NLME Likelihood Contains

A class-specific likelihood is not generally just the product of observation densities evaluated at a typical subject. In an NLME model, subject \(i\) has a random effect \(\eta_i\). Conditional on a class and that random effect, the observations have a specified density; the random effect itself has a population distribution. Since \(\eta_i\) is not observed, the class-specific subject likelihood integrates over its possible values.

For class \(k\), where \(k\) is \(F\) or \(S\), let \(y_i=(y_{i1},\ldots,y_{in_i})\) denote the observations, \(f_{ij,k}(y_{ij}\mid\eta_i)\) their conditional densities, and \(g_k(\eta_i)\) the random-effects density. Under conditional independence of a subject’s observations given class and random effects, the class-specific likelihood is:

$$ L_{ik}=\int \left\{\prod_{j=1}^{n_i} f_{ij,k}(y_{ij}\mid\eta_i)\right\} g_k(\eta_i)\,d\eta_i. $$

The conditional density can depend on dose, time, and other known design information, which is suppressed in the notation. The class can affect the structural model, the random-effects distribution, or both. The particular parameterization of fast and slow clearance is not needed to derive the mixture likelihood.

This construction assumes that each subject belongs to exactly one of the two classes; that class membership is drawn according to the stated prevalence; that the class remains the same across that subject’s observations; and that subjects are independent conditional on the population model. It also assumes the observation and random-effects distributions used in \(L_{ik}\) are appropriate. If the class is observed, the subject contributes the likelihood for that known class rather than a prevalence-weighted sum.

Why the Subject Contributions Are Added

For a particular subject, the observed data can arise through either of two mutually exclusive latent events: \(Z_i=F\) or \(Z_i=S\). The law of total probability says to sum the conditional data likelihood over these possibilities, multiplying each by the probability of that possibility. Applying it gives:

$$ \begin{aligned} P(y_i) &=P(y_i\mid Z_i=F)P(Z_i=F)+P(y_i\mid Z_i=S)P(Z_i=S)\\ &=L_{iF}\pi+L_{iS}(1-\pi). \end{aligned} $$

Here, \(P(y_i)\) is understood as a probability mass for discrete data or a density for continuous data. Either way, its likelihood contribution is the weighted sum. The sum does not assert that the subject is partly fast and partly slow. It accounts for uncertainty about which single class generated the subject’s data.

Once each subject’s class has been marginalized in this way, independence across subjects gives the full likelihood as the product of the subject contributions. Explicitly, with independent class assignments across subjects:

$$ L=\prod_{i=1}^{N}\left\{\pi L_{iF}+(1-\pi)L_{iS}\right\}. $$

The formula depends on the stated model: a shared population prevalence \(\pi\), one latent class per subject, and independent subjects. A model with a common class shared by all subjects would instead sum the two class-specific whole-sample likelihoods. That is not the usual subject-level latent-class model.

Worked Example: One Subject’s Weighted Likelihood

Suppose a hypothetical subject has already been evaluated under both class-specific NLME models, including integration over the subject’s random effect. The resulting likelihood contributions are \(L_{iF}=0.080\) and \(L_{iS}=0.020\). Suppose the fast-class prevalence is \(\pi=0.25\). Calculate the subject’s contribution to the two-class likelihood.

The slow-class prevalence is \(1-\pi=0.75\). Therefore:

$$ L_i=(0.25)(0.080)+(0.75)(0.020) =0.020+0.015 =0.035. $$

The subject contributes \(0.035\) on the likelihood scale used for the class-specific contributions. The fast-class term contributes \(0.020\), and the slow-class term contributes \(0.015\). These are likelihood contributions, not posterior probabilities that the subject belongs to each class.

This calculation assumes that the supplied \(L_{iF}\) and \(L_{iS}\) each use the full subject’s observation data and the appropriate random-effects integration. Weighting only a single observation while leaving the rest of the subject’s records outside the class-specific likelihood would not implement the stated model.

Several Subjects: Sum Within, Then Multiply

If subjects have independent latent class assignments, each subject gets a separate weighted sum. This remains true even though they share the same population prevalence and may share population parameters. The result is not the average of the class-specific likelihoods across the entire sample.

Worked Example: The Population Likelihood for Three Subjects

Consider a hypothetical dataset with three independent subjects and fast-class prevalence \(\pi=0.40\). Suppose the class-specific subject likelihoods, after integrating over random effects, are:

Subject\(L_{iF}\)\(L_{iS}\)
10.1200.030
20.0200.080
30.0500.010

For subject 1, the mixture contribution is \(0.40(0.120)+0.60(0.030)=0.048+0.018=0.066\). For subject 2, it is \(0.40(0.020)+0.60(0.080)=0.008+0.048=0.056\). For subject 3, it is \(0.40(0.050)+0.60(0.010)=0.020+0.006=0.026\).

Independence across subjects now gives:

$$ L=(0.066)(0.056)(0.026)=0.000096096. $$

Thus, \(0.000096096\) is the likelihood contribution for this dataset under the specified model and parameter values. The small numerical value is not itself evidence of poor fit: likelihood magnitudes depend on the scale and number of observations. Comparisons of likelihoods are meaningful when they use the same data and compatible likelihood definitions.

Justifying the Order of Operations

The distinction between \(\prod_i\{\pi L_{iF}+(1-\pi)L_{iS}\}\) and a single weighted sum of whole-sample likelihoods follows directly from the class-assignment assumption. With independent class assignments, the joint probability of a particular vector of classes factors across subjects. Summing over all possible class vectors therefore produces one two-term sum per subject.

$$ \begin{aligned} P(y_1,\ldots,y_N) &=\sum_{z_1,\ldots,z_N} \prod_{i=1}^{N} P(y_i\mid Z_i=z_i)P(Z_i=z_i)\\ &=\prod_{i=1}^{N} \left\{\sum_{z_i\in\{F,S\}}P(y_i\mid Z_i=z_i)P(Z_i=z_i)\right\}\\ &=\prod_{i=1}^{N}\left\{\pi L_{iF}+(1-\pi)L_{iS}\right\}. \end{aligned} $$

The second equality is valid because the sum over all combinations of independent subject classes factors into a product of sums. If instead a single latent class \(Z\) were shared by the entire sample, there would be only one class choice to sum over, yielding \(\pi\prod_iL_{iF}+(1-\pi)\prod_iL_{iS}\). That alternative encodes a different data-generating assumption.

Worked Example: Why a Single Whole-Sample Sum Is Different

Use the first two subjects from the previous example, with \(\pi=0.40\). Under independent subject classes, the likelihood is:

$$ \{0.40(0.120)+0.60(0.030)\} \{0.40(0.020)+0.60(0.080)\} =(0.066)(0.056)=0.003696. $$

If one incorrectly assumes that both subjects share one class, the calculation becomes:

$$ 0.40(0.120)(0.020)+0.60(0.030)(0.080) =0.000960+0.001440 =0.002400. $$

These results differ because the second expression excludes the possibilities that subject 1 is fast while subject 2 is slow, or vice versa. The independent-assignment model includes those possibilities; its product of sums expands to four terms, including both cross-class combinations. The shared-class model includes only the all-fast and all-slow combinations. The correct expression is determined by the model’s assumption about class membership, not by which numerical result seems preferable.

Computation, Diagnostics, and Limits

In practice, the main computational challenge is often evaluating each \(L_{ik}\), particularly when a subject has repeated observations and multiple random effects. Numerical integration or an approximation may be used, but the outer mixture structure remains the same: class-specific subject likelihoods are combined using prevalence weights, and the resulting subject contributions are multiplied. When optimizing, implementations often work with log likelihoods to avoid numerical underflow:

$$ \ell=\sum_{i=1}^{N}\log\left\{\pi L_{iF}+(1-\pi)L_{iS}\right\}. $$

For numerical stability, the weighted terms should be combined before taking the logarithm; computing the two logs separately and adding them would represent a product, not a mixture. Implementations should also ensure the weights are valid probabilities, with \(0<\pi<1\), and that each class-specific likelihood is evaluated on the same subject data under its own specified model.

Useful checks include verifying that each subject has both class contributions available, that the same prevalence convention is used throughout, and that a small test dataset reproduces the sum-then-product calculation by hand. A very small class-specific likelihood may be entirely possible, but unexpected zero values can indicate numerical underflow or a failed likelihood evaluation. If one class’s likelihood is effectively zero for nearly every subject, the fitted model may also be struggling to represent the data; the likelihood formula alone cannot diagnose the cause.

The two-class likelihood has important limits. It assumes the specified two classes adequately describe the latent heterogeneity and that membership probabilities and class-specific likelihoods are correctly formulated. It does not establish that there truly are two biological subpopulations, identify an individual’s class with certainty, or guarantee that class-specific parameters can be estimated reliably. Those questions require further modeling and diagnostic work.

Common Mistake: Assigning a Class Before Forming the Likelihood

A common error is to inspect the data, choose whichever class gives the larger \(L_{ik}\), and use only that class’s likelihood for subject \(i\). This replaces the model’s marginal contribution with a hard assignment and discards the alternative class contribution, as well as the prevalence weights. The correction is to use \(\pi L_{iF}+(1-\pi)L_{iS}\) for the likelihood whenever class membership is unobserved. A subject’s relative support for the classes may be considered separately, but it is not a substitute for the marginal likelihood.

Another frequent error is to multiply the fast-class likelihoods across subjects, multiply the slow-class likelihoods across subjects, and then mix those two products. That calculation is appropriate only when the model assigns one common latent class to the whole sample. Under independent subject-level classes, sum the weighted contributions within each subject and then multiply across subjects.

Key takeaway: In the two-class NLME model, integrate over random effects to obtain each class-specific subject likelihood, take the prevalence-weighted sum across possible classes for each subject, and multiply those subject contributions under independence.

Check Your Understanding

Use the definitions and assumptions above. Brief solutions follow the questions.

  1. If \(L_{iF}=0.10\), \(L_{iS}=0.04\), and \(\pi=0.30\), what is the subject’s mixture likelihood contribution?
  2. Why is a subject’s class-specific likelihood integrated over \(\eta_i\) in an NLME model?
  3. For two independent subjects, write the likelihood using their class-specific contributions and prevalence \(\pi\).
  4. When is \(\pi\prod_i L_{iF}+(1-\pi)\prod_i L_{iS}\) the appropriate form?

Solutions. (1) \(0.30(0.10)+0.70(0.04)=0.030+0.028=0.058\). (2) The random effect is unobserved, so its possible values are averaged according to its population density; this produces the marginal likelihood for the subject’s data under that class. (3) The likelihood is \(\{\pi L_{1F}+(1-\pi)L_{1S}\}\{\pi L_{2F}+(1-\pi)L_{2S}\}\), because each subject has an independent latent class. (4) It is appropriate when a single latent class is shared by all subjects, rather than when each subject has an independently drawn class.