Tutorials › Nonlinear Mixed-Effects Models (NLME) › Dependence in Repeated Categorical Outcomes

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

Dependence in Repeated Categorical Outcomes

Distinguish dependence caused by persistent subject-level heterogeneity from dependence on the previous categorical outcome, and interpret each model accordingly.

Advanced 11 min read

What You'll Learn

  • Explain how a shared subject random effect induces dependence between repeated categorical outcomes.
  • Derive the within-subject covariance implied by a binary random-intercept model.
  • Specify a first-order transition model and distinguish its lagged-outcome effect from a subject-specific effect.
  • Calculate joint and marginal probabilities under both modeling approaches.
  • Compare assumptions, interpretations, diagnostics, and limitations of random-effects and transition models.

Why Repeated Outcomes Can Be Dependent

When a categorical outcome is recorded repeatedly for the same person, animal, or experimental unit, the observations need not be independent. A subject may have a persistent tendency toward one response category, or the category at one occasion may directly help predict the category at the next. These are different explanations of dependence. Treating them as interchangeable can lead to a model whose coefficient answers a different scientific question from the one intended.

A random-effects model represents persistent, unobserved differences among subjects through a subject-level random effect. A transition model represents dependence on observed response history by including one or more earlier outcomes as predictors. Either can be useful, and a model may include both structures when justified, but their coefficients have different interpretations.

Definition: Let \(Y_{it}\) be the categorical outcome for subject \(i\) at occasion \(t\), where \(i=1,\ldots,n\) and \(t=1,\ldots,T_i\). A random-effects model makes the distribution of \(Y_{it}\) depend on a latent subject effect \(b_i\). A transition model makes the distribution of \(Y_{it}\) depend on one or more earlier observed outcomes, such as \(Y_{i,t-1}\). The former represents persistent latent heterogeneity; the latter represents dependence on observed response history.

Random-Effects Dependence

For a binary response, code \(Y_{it}=1\) for the event of interest and \(Y_{it}=0\) otherwise. One common random-intercept model is

$$ P(Y_{it}=1\mid b_i,x_{it})= \operatorname{logit}^{-1}(\beta_0+\beta_1 x_{it}+b_i), \qquad b_i\sim N(0,\omega^2). $$

Here \(x_{it}\) is a covariate, \(\beta_0\) and \(\beta_1\) are fixed effects, and \(b_i\) is shared across occasions for subject \(i\). A standard version assumes that, conditional on \(b_i\) and the modeled covariates, outcomes from different occasions are independent. The random effects are typically assumed independent across subjects and independent of the covariates. The chosen distribution for \(b_i\), commonly a mean-zero normal distribution, is part of the model and should be considered an assumption rather than a fact guaranteed by the data.

The coefficient \(\beta_1\) describes a change in the conditional log odds of the event for a one-unit increase in \(x_{it}\), holding the subject effect fixed. It is therefore a subject-specific, conditional effect. Because the logistic function is nonlinear, this conditional effect does not generally equal the effect calculated from probabilities averaged over the distribution of \(b_i\).

Even though observations are conditionally independent given \(b_i\), they are generally dependent after \(b_i\) is integrated out. For two binary outcomes at occasions \(s\) and \(t\), the law of total covariance gives

$$ \operatorname{Cov}(Y_{is},Y_{it}) = E\{\operatorname{Cov}(Y_{is},Y_{it}\mid b_i)\} + \operatorname{Cov}\{E(Y_{is}\mid b_i),E(Y_{it}\mid b_i)\}. $$

Under conditional independence, the first term is zero. If the occasions share the same covariate values and conditional event probability \(p(b_i)\), the second term is \(\operatorname{Var}\{p(b_i)\}\), which is nonnegative. Thus, variation in subjects' underlying response propensities induces positive marginal association between their repeated outcomes, even without a direct effect of one outcome on another.

Worked Example: Dependence From a Shared Random Intercept

Consider two hypothetical binary observations per subject, with no covariates and a random intercept that is \(+1\) with probability \(0.5\) and \(-1\) with probability \(0.5\). Conditional on the intercept, assume the two outcomes are independent, each with probability \(\operatorname{logit}^{-1}(b_i)\) of being 1. This two-point random-effect distribution is used here to make the integration transparent; it is not the normal random-effect assumption in the model above.

For \(b_i=1\), the event probability is \(p_+=1/(1+e^{-1})=0.7311\). For \(b_i=-1\), it is \(p_-=1/(1+e^1)=0.2689\). The marginal event probability at either occasion is

$$ P(Y_{it}=1)=0.5(0.7310586)+0.5(0.2689414)=0.5000. $$

The probability that both outcomes equal 1 is the average of the two conditional joint probabilities:

$$ P(Y_{i1}=1,Y_{i2}=1) =0.5(0.7310586^2)+0.5(0.2689414^2) \approx 0.3033881 \approx 0.3034. $$

Since each marginal mean is 0.5, the covariance is \(0.3033881-(0.5)(0.5)=0.0533881\), or approximately \(0.0534\). The marginal variance of each binary outcome is \(0.5(1-0.5)=0.25\), so their correlation is \(0.0533881/0.25\approx0.2136\). The dependence arises because both observations share the same latent subject effect; it is not evidence that the first outcome directly caused the second.

Transition Dependence

A first-order transition model specifies the current outcome distribution conditional on the immediately preceding outcome and covariates. For a binary response, one form is

$$ \operatorname{logit}P(Y_{it}=1\mid Y_{i,t-1},x_{it}) =\gamma_0+\gamma_1Y_{i,t-1}+\gamma_2x_{it}, \qquad t\geq 2. $$

The coefficient \(\gamma_1\) describes how the log odds at occasion \(t\) differ when the previous recorded outcome is 1 rather than 0, at fixed current covariates. It is a conditional transition effect. It does not, by itself, represent a stable subject propensity, and it is not automatically a causal effect of changing the previous outcome. The model also needs a distribution for the first outcome, such as a separate regression for \(Y_{i1}\), because there is no observed \(Y_{i0}\) in the sequence.

The first-order Markov assumption is that, conditional on the current covariates and the immediately previous response, earlier outcomes add no further information about the current response: \(P(Y_{it}\mid Y_{i1},\ldots,Y_{i,t-1},x_{it})=P(Y_{it}\mid Y_{i,t-1},x_{it})\). This is a substantive restriction. If earlier response history still predicts the current category after accounting for \(Y_{i,t-1}\), a first-order transition model may be inadequate.

Worked Example: Interpreting a Binary Transition

Suppose a hypothetical transition model at a fixed covariate value gives \(P(Y_{it}=1\mid Y_{i,t-1}=1)=0.70\) and \(P(Y_{it}=1\mid Y_{i,t-1}=0)=0.20\). Suppose also that the first outcome has \(P(Y_{i1}=1)=0.40\). These probabilities define the example; they are not estimates from an actual study.

The probability of two consecutive positive outcomes is \(P(Y_{i1}=1,Y_{i2}=1)=0.40(0.70)=0.28\). For the second occasion's marginal probability, average over the first outcome:

$$ P(Y_{i2}=1) =P(Y_{i1}=1)(0.70)+P(Y_{i1}=0)(0.20) =(0.40)(0.70)+(0.60)(0.20)=0.40. $$

The covariance is therefore \(0.28-(0.40)(0.40)=0.12\). Both marginal variances equal \(0.40(0.60)=0.24\), giving correlation \(0.12/0.24=0.500\). In this example the association is represented by the higher chance of a positive outcome following a positive outcome. Unlike the random-intercept example, the transition probabilities are explicitly indexed by the prior observed response.

The transition log-odds contrast between previous outcome 1 and 0 is \(\log\{(0.70/0.30)/(0.20/0.80)\}=\log(9.333)\approx2.234\). Thus, at the stated covariate value, the odds of a positive current outcome are about 9.33 times as large following a positive prior outcome. This conditional odds ratio is not the same quantity as the marginal correlation just calculated.

Nominal Outcomes and Transition Probabilities

For a nominal response with \(K\) categories, a transition model can specify a probability for each current category conditional on the previous category. Each row of the transition matrix corresponds to a previous category, and each column to a current category. Every entry is nonnegative and each row sums to 1. Covariates can be added by modeling these conditional probabilities, for example with a multinomial logit specification. The key interpretive feature remains: probabilities are conditioned on response history.

Worked Example: A Three-Category Transition Matrix

Suppose a hypothetical response has categories A, B, and C. Its initial category probabilities are \(P(Y_{i1}=A)=0.50\), \(P(Y_{i1}=B)=0.30\), and \(P(Y_{i1}=C)=0.20\). The transition matrix is

$$ \begin{array}{c|ccc} & Y_{it}=A & Y_{it}=B & Y_{it}=C\\ Y_{i,t-1}=A & 0.70 & 0.20 & 0.10\\ Y_{i,t-1}=B & 0.20 & 0.60 & 0.20\\ Y_{i,t-1}=C & 0.10 & 0.30 & 0.60 \end{array} $$

Each row sums to 1. For example, given category B at the previous occasion, the next outcome is A, B, or C with probabilities 0.20, 0.60, and 0.20. The marginal probability of B at the second occasion averages over the three possible first categories:

$$ P(Y_{i2}=B)=(0.50)(0.20)+(0.30)(0.60)+(0.20)(0.30) =0.10+0.18+0.06=0.34. $$

The probability of the specific sequence A, then B, then C is the initial probability of A multiplied by the transition probability from A to B and then from B to C: \(0.50(0.20)(0.20)=0.020\). This product follows from the first-order transition factorization. It would not follow from a model that instead assumes conditional independence given a shared random effect.

Choosing and Assessing the Dependence Structure

The distinction is primarily scientific, not just computational. A random-effects model asks whether subjects differ persistently in their response propensities after accounting for covariates. A transition model asks whether the current category depends on the observed recent category. They can imply similar observed correlations in some settings, but similar correlations do not make their parameters interchangeable.

FeatureRandom-effects modelTransition model
Source of dependenceShared latent subject effectEarlier observed response(s)
Conditional statementOutcomes are modeled given subject effect and covariatesCurrent outcome is modeled given prior outcome(s) and covariates
Main interpretationSubject-specific covariate effect, conditional on the random effectConditional change in current response distribution across prior categories
Typical limitationResults can depend on random-effect distribution and structureRequires an initial-outcome model and a defensible history order

Several checks help identify a poorly chosen dependence structure. For a random-effects model, inspect whether estimated subject heterogeneity is supported by the repeated data, whether the assumed random-effect distribution is plausible, and whether residual association remains across occasions after conditioning on the fitted effects and covariates. For a transition model, examine whether response history beyond the chosen lag still carries information, whether transition probabilities are adequately represented across covariate patterns, and whether sparse transitions make parameters unstable. In either approach, consider the actual observation schedule, missing outcomes, and whether the recorded prior response is the scientifically relevant history.

A transition model that omits important stable subject differences may attribute their persistence to the lagged response. Conversely, a random-intercept model may fail to capture short-term state dependence if the previous response has an additional role. Including both random effects and lagged outcomes is possible, but requires care: a prior outcome may be associated with the latent subject effect, so a simple conditional interpretation or standard likelihood factorization may not resolve all modeling concerns. The combined model must state its assumptions and estimation target clearly.

A population-averaged model is another possible approach when the target is a marginal mean or population-level association rather than a subject-specific or history-conditional effect. It does not automatically explain the source of dependence in the same way as either model above. The appropriate choice depends on the scientific question, the design, and whether the aim is subject-specific inference, transition prediction, or population-average description.

Common pitfall: Seeing positive within-subject association and concluding that the previous response caused the current response. A shared random effect can produce positive association even when outcomes are independent conditional on that effect. A transition coefficient instead describes conditional association with the prior recorded outcome; interpreting it causally requires additional design and assumptions. Choose and describe the dependence structure rather than assigning a causal meaning to correlation alone.
Key takeaway: Random effects represent persistent latent heterogeneity; transition terms represent dependence on observed response history. Their conditional probabilities, assumptions, and coefficients answer different questions, even when both models can account for repeated-outcome association.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In a random-intercept binary model, what assumption makes repeated outcomes conditionally independent, and why can they still be marginally dependent?
  2. A transition model gives \(P(Y_t=1\mid Y_{t-1}=1)=0.60\) and \(P(Y_t=1\mid Y_{t-1}=0)=0.30\). What do these probabilities compare?
  3. With initial probabilities \(P(Y_1=1)=0.25\), \(P(Y_1=0)=0.75\), and transitions \(P(Y_2=1\mid Y_1=1)=0.80\), \(P(Y_2=1\mid Y_1=0)=0.20\), calculate \(P(Y_2=1)\).
  4. Why does a transition model require an additional specification for the first observation?
  5. Does a positive association between repeated outcomes establish that one outcome caused the next? Explain.

Solutions. (1) The model assumes conditional independence given the subject effect and covariates. Integrating out the shared effect can induce marginal association because subjects with effects producing larger event probabilities tend to have positive outcomes at multiple occasions. (2) They compare the current event probability conditional on the previous response being 1 versus 0, at the modeled covariate values; they do not alone establish causation. (3) \(P(Y_2=1)=(0.25)(0.80)+(0.75)(0.20)=0.20+0.15=0.35\). (4) There is no prior observed response for the first occasion, so its distribution must be modeled or otherwise specified. (5) No. Shared latent heterogeneity can induce association, and a transition coefficient is conditional association unless additional causal assumptions are justified.