Tutorials › Nonlinear Mixed-Effects Models (NLME) › Likelihood Contributions for Non-Continuous NLME Outcomes

Categorical, Count and Time-to-Event Responses · Tutorial 418 of 797

Likelihood Contributions for Non-Continuous NLME Outcomes

Build conditional likelihood contributions for four non-continuous outcome types, then marginalize correctly over each subject’s random effects.

Advanced 9 min read

What You'll Learn

  • Write Bernoulli contributions for binary observations and category-probability contributions for ordinal observations.
  • Express a count observation’s contribution using its conditional probability mass function.
  • Construct an event-time contribution for an observed event or right censoring.
  • Distinguish an individual’s likelihood conditional on random effects from the marginal likelihood.
  • Explain why repeated observations are combined before integrating over a subject’s random effects.
  • Identify assumptions and common errors that can invalidate a likelihood contribution.

From an Observation to a Likelihood Contribution

In an NLME model, an outcome distribution is specified conditional on a subject’s random effects. For a non-continuous outcome, the contribution from an observation is usually a probability or a probability mass, rather than a continuous-response density. With repeated observations, the subject’s likelihood is built from the joint conditional contribution and then averaged over the random-effects distribution. Keeping those two steps in the right order is essential: observations from the same subject share the same random effects.

Definition: Let \(Y_{ij}\) be the response for subject \(i\) at occasion \(j\), and let \(b_i\) be that subject’s random-effects vector, with density \(g(b_i;\Omega)\). The conditional likelihood contribution is the probability, probability mass, or density of the observed response data given \(b_i\) and the model parameters. The marginal likelihood contribution for subject \(i\) is the conditional contribution integrated over the random-effects distribution.

Write the subject’s observed data as \(y_i=(y_{i1},\ldots,y_{in_i})\). If responses are conditionally independent given \(b_i\) and the model parameters, their conditional likelihood contribution is

$$ L_i(b_i)=\prod_{j=1}^{n_i} p(y_{ij}\mid b_i;\theta), \qquad L_i(\theta,\Omega)=\int L_i(b_i)g(b_i;\Omega)\,db_i . $$

Here, \(\theta\) denotes the response-model parameters and \(\Omega\) describes the random-effects distribution. The integral is over the full random-effects vector. For a single observation, the product contains one term. For repeated observations, it is the product for the whole subject that is integrated. Conditional independence is a modeling assumption, not a property guaranteed by the data format; if responses remain dependent given \(b_i\), the joint conditional distribution must replace the product.

Why Integration Comes After Combining Repeated Data

A random effect is shared by a subject’s observations. Given its value, observations may be conditionally independent; before its value is known, they are generally dependent through that shared effect. The marginal likelihood must therefore average the joint conditional contribution over possible random effects.

Justification: By the law of total probability, the marginal probability of a subject’s response vector is its conditional probability given \(b_i\), averaged over all possible values of \(b_i\). Under conditional independence, that conditional probability is the product of the occasion-specific probabilities: $$ P(y_i)=\int P(y_i\mid b_i)g(b_i;\Omega)\,db_i =\int \left\{\prod_{j=1}^{n_i}p(y_{ij}\mid b_i;\theta)\right\}g(b_i;\Omega)\,db_i. $$ In general, this is not equal to the product of the separately averaged probabilities, \(\prod_j\int p(y_{ij}\mid b_i;\theta)g(b_i;\Omega)\,db_i\). The latter would treat each observation as if it had an independently redrawn random effect.

Worked Example: Two Binary Responses From One Subject

Suppose, hypothetically, that a subject’s random effect takes values \(b=-1\) and \(b=1\), each with probability \(0.5\). For two conditionally independent binary observations, suppose the probabilities of a positive response are:

  • At \(b=-1\), \(P(Y_{i1}=1\mid b)=0.2\) and \(P(Y_{i2}=1\mid b)=0.3\).
  • At \(b=1\), \(P(Y_{i1}=1\mid b)=0.8\) and \(P(Y_{i2}=1\mid b)=0.7\).

Both observed responses are positive. At \(b=-1\), the conditional contribution is \(0.2(0.3)=0.06\); at \(b=1\), it is \(0.8(0.7)=0.56\). Thus the marginal likelihood contribution is

$$ L_i=0.5(0.06)+0.5(0.56)=0.31. $$

The marginal probability of a positive response at either occasion is \(0.5(0.2)+0.5(0.8)=0.5\) for the first and \(0.5(0.3)+0.5(0.7)=0.5\) for the second. Multiplying those marginal probabilities gives \(0.25\), not \(0.31\). That multiplication is incorrect for this shared-random-effect model: it averages over the random effect separately for each observation instead of once for the subject’s response vector.

Binary and Ordinal Outcomes

For a binary response \(Y_{ij}\in\{0,1\}\), let \(p_{ij}(b_i)\) denote the conditional probability of response 1. Its Bernoulli contribution is

$$ p(y_{ij}\mid b_i)=p_{ij}(b_i)^{y_{ij}}\{1-p_{ij}(b_i)\}^{1-y_{ij}}. $$

This expression gives \(p_{ij}(b_i)\) when \(y_{ij}=1\), and \(1-p_{ij}(b_i)\) when \(y_{ij}=0\). The probability \(p_{ij}(b_i)\) is conditional on the subject’s random effects; it is not automatically the population-average probability. The model that determines this probability is a separate specification.

For an ordinal response with ordered categories \(1,\ldots,K\), let \(\pi_{ijk}(b_i)\) be the conditional probability of category \(k\), where \(\pi_{ijk}(b_i)\geq 0\) and \(\sum_{k=1}^{K}\pi_{ijk}(b_i)=1\). If the observed category is \(y_{ij}=k\), its likelihood contribution is \(\pi_{ijk}(b_i)\). It is not the probability of being in category \(k\) or higher unless the observation has specifically been recorded as that cumulative event.

Worked Example: An Ordinal Observation

Suppose, hypothetically, an ordinal response has three ordered categories. At two equally likely random-effect values, the conditional category probabilities are \((0.2,0.5,0.3)\) and \((0.1,0.3,0.6)\), respectively. The observed response is category 2.

The conditional contributions are \(0.5\) and \(0.3\). Averaging them over the two random-effect values gives

$$ L_i=0.5(0.5)+0.5(0.3)=0.40. $$

The marginal probability of observing category 2 is therefore \(0.40\). Each set of conditional probabilities sums to one, as required. If the observation instead recorded only whether the response was category 2 or higher, the conditional probability would be the sum of the relevant category probabilities; that is a different recorded outcome and must be represented accordingly.

Count Outcomes

For a count \(Y_{ij}\in\{0,1,2,\ldots\}\), the contribution is the conditional probability mass assigned to the observed count. In general, write it as \(q(y_{ij}\mid b_i;\theta)\), with the probabilities over all possible counts summing to one. The same marginalization rule applies: multiply the conditional contributions across a subject’s observations when conditional independence is assumed, then integrate over \(b_i\).

Worked Example: A Count Contribution

For a numerical illustration, suppose hypothetically that a single count has a Poisson distribution conditional on \(b_i\), with conditional mean \(\lambda(b_i)\). The random effect has two equally likely values, giving means of 1 and 3 events per observation period. The observed count is 2. The conditional mass for count 2 at mean \(\lambda\) is \(e^{-\lambda}\lambda^2/2!\). Therefore,

$$ L_i =0.5\left(\frac{e^{-1}1^2}{2}\right) +0.5\left(\frac{e^{-3}3^2}{2}\right) =0.5(0.1839)+0.5(0.2240) =0.2040. $$

This is a marginal probability mass for observing a count of 2 under the stated two-point random-effects distribution. It is not a density, and the calculation illustrates a particular conditional count distribution rather than prescribing one for every count outcome.

Right-Censored Event Times

Let \(T_i\) be an event time, with conditional density \(f(t\mid b_i)\) and conditional survival function \(S(t\mid b_i)=P(T_i>t\mid b_i)\). For right-censored data, the observed time is \(t_i=\min(T_i,C_i)\), where \(C_i\) is the censoring time. Let \(\delta_i=1\) if the event was observed and \(\delta_i=0\) if the observation was right-censored. Assuming censoring is independent of the event time conditional on the modeled information, the event-time contribution is

$$ L_i(b_i)=f(t_i\mid b_i)^{\delta_i}S(t_i\mid b_i)^{1-\delta_i}. $$

An observed event contributes its density at the event time; a right-censored observation contributes the probability that the event time exceeds the censoring time. An event-time density has units inverse to time, while a survival probability is dimensionless. If the censoring mechanism is informative or has parameters that are part of the target likelihood, it cannot simply be omitted; it may need to be modeled jointly.

Worked Example: Event Observed Versus Right-Censored

Suppose hypothetically that, conditional on a fixed random-effect value, an event time in days has an exponential distribution with rate \(\lambda=0.3\) per day. Its density is \(f(t)=\lambda e^{-\lambda t}\), and its survival function is \(S(t)=e^{-\lambda t}\).

For an event observed at day 2, the contribution is the density

$$ f(2)=0.3e^{-0.3(2)}=0.3e^{-0.6}=0.1646\ \text{day}^{-1}. $$

For a subject right-censored at day 2, the contribution is instead

$$ S(2)=e^{-0.3(2)}=e^{-0.6}=0.5488. $$

The two contributions differ because an observed event says that the event occurred at a particular time, whereas censoring at day 2 says only that the event had not occurred by then. The rate and distribution in this example are conditional on the stated random-effect value; for a marginal contribution, the relevant conditional likelihood must also be integrated over the random-effects distribution.

Assumptions, Diagnostics, and Alternatives

Before using these contributions, check that the outcome’s support and recording process match the likelihood. Binary data must record one of the two modeled outcomes; ordinal category probabilities must form a valid distribution; count probabilities must cover the observed counts; and event-time records must correctly distinguish observed events from censoring. Check that repeated observations are assigned to the correct subject and that the assumed conditional dependence structure is plausible. A product of occasion-specific probabilities is justified only under conditional independence.

In practice, the integral over random effects may not have a closed-form expression. Numerical integration methods approximate it, but the target remains the same integral of the subject-level conditional likelihood. A useful diagnostic is to compare likelihood calculations or estimates under more accurate integration settings: material changes suggest that the approximation may be inadequate. Also inspect whether fitted probabilities are valid, whether the model assigns appreciable likelihood to observed categories and counts, and whether event and censoring records have been coded consistently. These checks do not prove a model is correct, but they can expose data or computation errors.

There are several tempting alternatives to the marginal likelihood, but they answer different questions or make different assumptions:

CalculationWhat it representsKey caution
Conditional likelihood at a specified \(b_i\)The likelihood for a subject if that random-effect value were knownIt is not the population-level contribution when \(b_i\) is unobserved.
Product of marginal occasion probabilitiesA product that averages each occasion separatelyIt generally discards dependence induced by a shared subject-level random effect.
Marginal likelihood integrating the subject’s joint contributionThe likelihood contribution for the observed subject under the random-effects modelIts integral may require numerical approximation.

A further limitation is that a correct likelihood contribution does not guarantee a correct model. The chosen conditional outcome distribution, random-effects distribution, dependence assumptions, and censoring assumptions all matter. If any are misspecified, maximizing the resulting marginal likelihood does not repair the misspecification. The likelihood should be read as a statement of how the observed data are assumed to arise, not just as an algebraic expression.

Common Mistakes

  • Integrating separately for each occasion. This treats a shared random effect as if it were independently redrawn each time. Combine the subject’s conditional contributions first, then integrate once over that subject’s random-effects distribution.
  • Using the probability of the wrong event. An ordinal category observation contributes that category’s probability, while a cumulative response contributes a sum of category probabilities. Match the likelihood to what was actually recorded.
  • Treating censoring as an observed event. A right-censored time contributes survival beyond the censoring time, not an event-time density at that time.
  • Calling every contribution a probability. A continuous event observed at an exact time contributes a density, which has units. A count or category contributes a probability mass.
  • Assuming conditional independence without justification. If dependence remains after conditioning on the random effects, use a suitable joint conditional distribution instead of multiplying marginal occasion terms.

Check Your Understanding

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

  1. A subject has two binary responses. Given the subject’s random effect, their conditional probabilities are 0.4 and 0.5, and the responses are conditionally independent. What is their conditional contribution if both are 1?
  2. A three-category ordinal response has conditional probabilities \((0.1,0.6,0.3)\). What is the contribution when category 3 is observed?
  3. A right-censored event time is recorded at 5 days. Which event-time term contributes, the density or survival function, and what does it represent?
  4. Why is the product of separately integrated occasion probabilities generally not the marginal likelihood for repeated outcomes sharing a random effect?

Solutions. (1) The conditional contribution is \(0.4(0.5)=0.20\), using conditional independence. (2) The contribution is \(0.3\), the probability of the observed category, not the cumulative probability of categories 2 and 3. (3) The contribution is \(S(5\mid b_i)\), the conditional probability that the event time exceeds 5 days; the subject-level marginal contribution integrates the appropriate conditional contribution over the random-effects distribution. (4) The shared random effect couples the repeated outcomes after it is averaged out. The correct marginal contribution is the integral of their joint conditional contribution, not a product that averages over a separate random effect for each occasion.