Tutorials › Nonlinear Mixed-Effects Models (NLME) › Class Prevalence and Individual Class Probabilities

Mixture and Latent Subpopulation Models · Tutorial 525 of 797

Class Prevalence and Individual Class Probabilities

Learn how class prevalence enters the two-class NLME likelihood and how subject-specific data update prior class probabilities.

Advanced 10 min read

What You'll Learn

  • Write the likelihood contribution when class membership is observed or latent.
  • Distinguish population class prevalence from an individual’s posterior class probability.
  • Calculate posterior fast- and slow-class probabilities using class-conditional likelihoods.
  • Interpret how an individual’s data update the prior class odds.
  • Recognize when class probabilities are uninformative or vulnerable to model misspecification.

From Population Prevalence to Individual Class Probability

A two-class model describes both how common each class is in the population and how well each class explains a particular subject’s data. These are different quantities. The class prevalence is a population-level probability, while a subject’s posterior class probability combines that prevalence with the evidence in the subject’s observations. A subject can therefore have a high posterior probability of belonging to a class that is relatively uncommon in the population, if that subject’s data fit that class much better.

The fast- and slow-clearance classes are treated as latent: each subject belongs to one class, but the class label is not directly observed. The class-specific model supplies a probability density for the subject’s data under each possible class. The likelihood must account for uncertainty about which class generated the data, rather than treating an unobserved label as known.

Definition: Let \(C_i\in\{F,S\}\) denote the latent class for subject \(i\), where \(F\) is fast clearance and \(S\) is slow clearance. Let \(\pi_F=P(C_i=F)\) be the population prevalence of the fast class and \(\pi_S=P(C_i=S)=1-\pi_F\) the prevalence of the slow class. For subject data \(y_i\), let \(f_F(y_i)\) and \(f_S(y_i)\) be the class-conditional probability densities, each evaluated under its class-specific model. The posterior probability of the fast class is \(P(C_i=F\mid y_i)\); the posterior probability of the slow class is defined analogously.

The class-conditional density is the probability model for the subject’s observed data given a class. In an NLME model, it generally accounts for the subject-level random effects as well as the observation model. In schematic form, if \(\eta_i\) denotes the random effects, then

$$ f_k(y_i)=\int p(y_i\mid \eta_i,C_i=k)\,p(\eta_i\mid C_i=k)\,d\eta_i,\qquad k\in\{F,S\}. $$

Thus, \(f_k(y_i)\) is not generally just the observation density at an estimated individual parameter value. It is the class-conditional likelihood contribution under the specified population model. For continuous data, \(f_k(y_i)\) is a density, not the probability of observing one exact value.

Likelihood Contributions for Class Prevalence

Assume that subjects’ class assignments are independent draws from the same population prevalence, and that subjects’ data are conditionally independent given their class and the model parameters. For a subject whose class is unobserved, there are two mutually exclusive ways to generate the data: the subject is fast with probability \(\pi_F\), or slow with probability \(1-\pi_F\). The law of total probability therefore gives the marginal density for that subject’s data:

$$ p(y_i)=\pi_F f_F(y_i)+(1-\pi_F)f_S(y_i). $$

This sum is the individual’s likelihood contribution. It is a weighted sum of class-conditional densities, not a choice of whichever class gives the larger density. Under independence across subjects, the likelihood for \(N\) subjects is the product of these contributions:

$$ L(\pi_F)=\prod_{i=1}^{N}\left\{\pi_F f_F(y_i)+(1-\pi_F)f_S(y_i)\right\}. $$

When the class-conditional model parameters are also estimated, the densities depend on those parameters as well, and the full likelihood is maximized over both prevalence and class-specific parameters. The expression above makes the prevalence contribution explicit while holding the class-conditional densities fixed.

Worked Example: Likelihood When Class Labels Are Observed

Suppose, hypothetically, that class labels are known for 10 subjects: 4 are in the fast class and 6 are in the slow class. Under independent class assignments with fast prevalence \(\pi_F\), write the class-label likelihood and find its maximum-likelihood estimate.

Each fast label contributes \(\pi_F\), and each slow label contributes \(1-\pi_F\). Thus

$$ L(\pi_F)=\pi_F^4(1-\pi_F)^6. $$

The log-likelihood is \(\ell(\pi_F)=4\log(\pi_F)+6\log(1-\pi_F)\). Differentiating and setting the derivative to zero gives

$$ \frac{d\ell}{d\pi_F}=\frac{4}{\pi_F}-\frac{6}{1-\pi_F}=0 \quad\Longrightarrow\quad 4(1-\pi_F)=6\pi_F \quad\Longrightarrow\quad \widehat{\pi}_F=0.400. $$

The estimated prevalence is 40%, and the slow-class prevalence is \(1-0.400=0.600\), or 60%. This calculation applies because the labels were observed. When labels are latent, simply counting subjects assigned to their most likely class does not give this observed-label likelihood.

With latent labels, each subject contributes a mixture term instead. Taking logs gives a sum of log mixture contributions, which is convenient for expressing the objective being maximized:

$$ \ell(\pi_F)=\sum_{i=1}^{N}\log\left\{\pi_F f_F(y_i)+(1-\pi_F)f_S(y_i)\right\}. $$

A short derivative illustrates why latent membership does not reduce to a simple count. Holding the class-conditional densities fixed, the score for \(\pi_F\) is

$$ \frac{d\ell}{d\pi_F} =\sum_{i=1}^{N} \frac{f_F(y_i)-f_S(y_i)} {\pi_F f_F(y_i)+(1-\pi_F)f_S(y_i)}. $$

Each subject influences the prevalence estimate according to the relative support their data provide for the two classes. If \(f_F(y_i)=f_S(y_i)\), that subject’s contribution to this derivative is zero: their data do not distinguish the classes. In contrast, a strong difference between the two densities can make that subject informative about prevalence. The derivative also shows that the latent-class likelihood is not the observed-label likelihood with guessed labels substituted in.

Worked Example: Evaluating a Latent-Class Likelihood

Consider two hypothetical subjects and suppose the fitted class-conditional densities, in the same units, are \(f_F(y_1)=0.120\), \(f_S(y_1)=0.040\), \(f_F(y_2)=0.030\), and \(f_S(y_2)=0.090\). Evaluate their joint likelihood contribution at a proposed fast-class prevalence of \(\pi_F=0.400\).

For subject 1, the mixture contribution is

$$ 0.400(0.120)+0.600(0.040)=0.048+0.024=0.072. $$

For subject 2, it is

$$ 0.400(0.030)+0.600(0.090)=0.012+0.054=0.066. $$

By conditional independence across subjects, the joint likelihood contribution is their product:

$$ L(0.400)=0.072(0.066)=0.004752. $$

This is the likelihood value at the proposed prevalence, not a probability that \(\pi_F=0.400\). Estimating prevalence requires evaluating the likelihood over candidate prevalence values (and, in a fitted NLME model, jointly considering the class-conditional model parameters).

Bayes’ Rule for an Individual Subject

The prior probability that a subject belongs to the fast class is \(\pi_F\). After observing \(y_i\), Bayes’ rule updates that prior using the class-conditional density. The denominator is the marginal density of the data, which sums the contributions from both possible classes:

$$ P(C_i=F\mid y_i) =\frac{P(C_i=F)f_F(y_i)}{p(y_i)} =\frac{\pi_F f_F(y_i)} {\pi_F f_F(y_i)+(1-\pi_F)f_S(y_i)}. $$

Likewise, the posterior probability of the slow class is

$$ P(C_i=S\mid y_i) =\frac{(1-\pi_F)f_S(y_i)} {\pi_F f_F(y_i)+(1-\pi_F)f_S(y_i)} =1-P(C_i=F\mid y_i). $$

The two posterior probabilities sum to one because the model allows exactly these two classes. The posterior odds make the roles of prevalence and data particularly clear:

$$ \frac{P(C_i=F\mid y_i)}{P(C_i=S\mid y_i)} = \frac{\pi_F}{1-\pi_F} \frac{f_F(y_i)}{f_S(y_i)}. $$

The first ratio is the prior odds of fast versus slow class membership. The second is the likelihood ratio contributed by the subject’s data. When the data fit both classes equally well, the likelihood ratio is one and the posterior odds equal the prior odds. When the fast-class density is larger, the data shift the odds toward fast membership; they do not, by themselves, prove that the subject belongs to that class.

Worked Example: Updating a Subject’s Class Probability

Suppose, hypothetically, the estimated fast-class prevalence is \(\pi_F=0.300\). For one subject, the class-conditional densities evaluated at the observed data are \(f_F(y_i)=0.080\) and \(f_S(y_i)=0.020\). Calculate the posterior probability of fast-class membership.

The fast-class part of the marginal density is \(0.300(0.080)=0.024\), and the slow-class part is \(0.700(0.020)=0.014\). The total marginal density is therefore \(0.024+0.014=0.038\). Bayes’ rule gives

$$ P(C_i=F\mid y_i)=\frac{0.024}{0.038}=0.6316. $$

The posterior probability of the slow class is \(1-0.6316=0.3684\). The subject’s data shift the probability toward the fast class: the prior fast probability was 0.300, and the observed data are four times as dense under the fast model as under the slow model, since \(0.080/0.020=4\). The result is still an uncertain assignment, not a definitive classification.

Assumptions, Diagnostics, and Common Pitfalls

The formulas rely on a defined two-class model. In particular, the prevalence is common across subjects in this formulation, class assignments are independent draws with probabilities \(\pi_F\) and \(1-\pi_F\), and each class-conditional density is correctly specified for the data being evaluated. The class-conditional densities must be comparable evaluations of the same subject’s data under the two alternatives. If observations are dependent across subjects or class prevalence varies with subject characteristics, this simple likelihood needs a different structure.

A posterior probability is only as reliable as the prevalence and the class-conditional models used to calculate it. Useful checks include verifying that the two class-conditional densities are evaluated on the same data and scale, confirming that each posterior probability lies between zero and one and the two sum to one, and examining whether assignments are driven by genuine differences between class fits or by numerical instability. If the class-conditional densities are nearly equal for most subjects, posterior probabilities will remain near the population prevalence: the data provide little individual-level separation. Very extreme probabilities warrant attention too, particularly if they arise from a few influential observations or implausibly small densities under one class.

A frequent mistake is to calculate each subject’s posterior probability, assign them to whichever class has the larger probability, and then treat those assignments as observed labels when estimating prevalence. This discards uncertainty. For example, probabilities of 0.51 and 0.99 both yield a fast-class label under that rule, even though the evidence for those labels differs substantially. The likelihood for latent classes retains both possibilities through the weighted sum \(\pi_F f_F(y_i)+(1-\pi_F)f_S(y_i)\).

QuantityWhat it representsHow the data enter
\(\pi_F\)Population prevalence of the fast classEstimated from the likelihood across subjects
\(f_F(y_i)\), \(f_S(y_i)\)Subject \(i\)’s data density under each classDetermined by the class-conditional NLME models
\(P(C_i=F\mid y_i)\)Subject \(i\)’s posterior fast-class probabilityCombines prevalence with the subject’s relative class fit

The main alternative is available when class membership is genuinely observed: use the class-label likelihood, as in the first worked example. That is not interchangeable with latent membership. Another tempting alternative is a hard assignment based on the larger class-conditional density alone. This ignores prevalence; the appropriate comparison is between the weighted terms \(\pi_F f_F(y_i)\) and \((1-\pi_F)f_S(y_i)\), and even choosing the larger weighted term is only a summary of the posterior, not a replacement for the mixture likelihood. Finally, if both class densities are almost identical, the data may contain little information about prevalence. A numerically computed prevalence in that situation should not be mistaken for strong evidence of two distinguishable subpopulations.

Key takeaway: For latent class membership, a subject contributes a prevalence-weighted sum of class-conditional densities to the likelihood. Bayes’ rule converts those same weighted contributions into posterior class probabilities. Prevalence describes the population; posterior probabilities describe the evidence about a particular subject under the fitted model.

Check Your Understanding

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

  1. Suppose \(\pi_F=0.250\), \(f_F(y_i)=0.060\), and \(f_S(y_i)=0.030\). What is \(P(C_i=F\mid y_i)\)?
  2. For one subject, suppose \(f_F(y_i)=f_S(y_i)\). What is the posterior fast-class probability, and why?
  3. Three subjects have observed class labels: one fast and two slow. Write the class-label likelihood and its maximum-likelihood estimate of \(\pi_F\).
  4. Explain why assigning every subject to the class with the larger posterior probability and counting those assignments does not reproduce the latent-class likelihood.

Solutions. (1) The weighted fast contribution is \(0.250(0.060)=0.015\); the weighted slow contribution is \(0.750(0.030)=0.0225\). Thus \(P(C_i=F\mid y_i)=0.015/(0.015+0.0225)=0.400\). (2) Equal densities give a likelihood ratio of one, so the data do not alter the prior odds; the posterior fast probability remains \(\pi_F\). (3) The likelihood is \(L(\pi_F)=\pi_F(1-\pi_F)^2\), maximized at \(\widehat{\pi}_F=1/3\), the observed fast fraction. (4) Hard assignments discard differences in uncertainty, such as the distinction between posterior probabilities 0.51 and 0.99. The latent likelihood instead retains both classes in each subject’s weighted-sum contribution.