Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Conditional And Marginal Effects In Count Mixed Models

Differential Expression With Pseudobulk and Mixed Models · Tutorial 519 of 700

Conditional And Marginal Effects In Count Mixed Models

Learn when a conditional fold change differs from a population-average fold change in a log-link count mixed model, and how to calculate and interpret each.

Advanced 11 min read

What You'll Learn

  • Define conditional and population-average condition effects for count mixed models.
  • Derive marginal means by integrating over Gaussian donor random effects.
  • Calculate how random-intercept variance and random-slope covariance affect marginal fold changes.
  • Distinguish the average of donor-specific fold changes from the ratio of marginal means.
  • Check modeling assumptions and recognize diagnostics that can reveal poor fit.
  • Compare mixed-model condition effects with a population-averaged alternative.

Why Two Fold Changes Can Both Be Correct

A log-link count mixed model can describe a condition effect for a donor with specified random effects, or an effect averaged over the distribution of donors. These are different summaries when donors vary in their condition responses. The fixed condition coefficient alone gives the fold change at random effects equal to zero; it does not generally give the ratio of the population-average expected counts.

This distinction matters when reporting differential expression from donor-level pseudobulk counts. A donor-specific effect may answer how the expected count changes within a donor, conditional on that donor's latent characteristics. A population-average effect instead compares expected counts averaged across the donor population. Neither is universally preferable: the target should match the scientific question.

Model and Definitions

Consider a count \(Y_{ij}\) for donor \(i\) under condition \(j\), with a binary condition indicator \(x_{ij}\) equal to 0 or 1 and exposure \(d_{ij}\), such as a library-size scaling factor. A log-link mixed model specifies the conditional mean given donor random effects:

$$ E(Y_{ij}\mid b_{0i},b_{1i}) = d_{ij}\exp(\beta_0+\beta_1x_{ij}+b_{0i}+b_{1i}x_{ij}). $$

Here \(\beta_0\) is the fixed intercept, \(\beta_1\) is the fixed condition effect, \(b_{0i}\) is a donor-specific random intercept, and \(b_{1i}\) is a donor-specific random condition slope. The usual random-effects assumption for the derivations below is that

$$ \begin{pmatrix}b_{0i}\\b_{1i}\end{pmatrix} \sim N\left( \begin{pmatrix}0\\0\end{pmatrix}, \begin{pmatrix}\tau_{00}&\tau_{01}\\\tau_{01}&\tau_{11}\end{pmatrix} \right), $$

independently across donors. The covariance matrix must be positive semidefinite. The count distribution can, for example, be Poisson or negative binomial conditional on the random effects; the mean calculations below require the stated conditional mean and random-effects distribution, not a particular conditional variance model.

Definition: The conditional fold change for donor \(i\) is the ratio of that donor's expected count under condition 1 to the expected count under condition 0, holding the donor's random effects fixed. The population-average fold change is the ratio of the expected counts under the two conditions after averaging each condition-specific mean over the random-effects distribution. The average conditional fold change is the mean of the donor-specific ratios over that distribution; it is not generally the population-average fold change.

When the two conditions have the same exposure for a donor, the conditional fold change is \(\exp(\beta_1+b_{1i})\). The random intercept cancels because it affects both condition means equally. If exposures differ, the count ratio also includes \(d_{i1}/d_{i0}\); that exposure ratio is not itself a condition effect.

Integrating Over Donor Effects

For a normally distributed random variable \(Z\) with mean 0 and variance \(v\), its moment-generating function gives \(E[\exp(Z)]=\exp(v/2)\). Applying this identity to the random effects yields the two marginal condition means when exposure is held equal at \(d\):

$$ E(Y\mid x=0)=d\exp(\beta_0+\tau_{00}/2), \qquad E(Y\mid x=1)=d\exp\{\beta_0+\beta_1+(\tau_{00}+2\tau_{01}+\tau_{11})/2\}. $$

The first variance term is the variance of \(b_{0i}\); the second is the variance of \(b_{0i}+b_{1i}\), namely \(\tau_{00}+2\tau_{01}+\tau_{11}\). Dividing the second marginal mean by the first gives the population-average fold change. Separately, averaging the conditional fold change requires only the marginal distribution of the random slope.

$$ \frac{E(Y\mid x=1)}{E(Y\mid x=0)} =\exp(\beta_1+\tau_{01}+\tau_{11}/2), \qquad E\{\exp(\beta_1+b_{1i})\} =\exp(\beta_1+\tau_{11}/2). $$

Thus, random-slope variance raises the average conditional fold change above \(\exp(\beta_1)\), while the population-average ratio also depends on intercept-slope covariance. The fixed-effect fold change \(\exp(\beta_1)\) is the conditional ratio for a donor with \(b_{1i}=0\), and also the median conditional ratio under the centered normal random-slope assumption. It is not generally either of the two averages just defined.

Worked Examples

Worked Example: Random Intercepts Only

Suppose a model has \(\beta_1=\log(1.5)\), a random intercept variance \(\tau_{00}=0.36\), and no random slope. Assume equal exposure across conditions. What is the population-average fold change?

The baseline marginal mean is \(d\exp(\beta_0+0.36/2)=d\exp(\beta_0+0.18)\). The condition-1 marginal mean is \(d\exp(\beta_0+\log(1.5)+0.18)\). Therefore,

$$ \frac{d\exp(\beta_0+\log(1.5)+0.18)} {d\exp(\beta_0+0.18)} =\exp\{\log(1.5)\}=1.5. $$

The expected count is 1.5 times as large under condition 1 as under condition 0, on average across donors. Random-intercept heterogeneity increases both marginal means by the same factor and cancels in their ratio. This result depends on the absence of a random condition slope.

Worked Example: Random Slopes and Covariance

Suppose \(\beta_1=\log(2)\), \(\tau_{00}=0.25\), \(\tau_{01}=0.04\), and \(\tau_{11}=0.09\). The covariance matrix is valid because its determinant is \(0.25(0.09)-0.04^2=0.0209>0\), and its diagonal entries are positive. Assume equal exposure.

The fixed-effect fold change for a donor with random slope zero is \(\exp\{\log(2)\}=2\). The population-average fold change is

$$ \exp(\log(2)+0.04+0.09/2) =2\exp(0.085) \approx 2.177. $$

The average conditional fold change is different:

$$ E\{\exp(\log(2)+b_{1i})\} =2\exp(0.09/2) =2\exp(0.045) \approx 2.092. $$

The difference arises because \(\tau_{01}=0.04\) contributes to the ratio of marginal means but not to the average of the conditional ratios. The two quantities answer distinct averaging questions.

Worked Example: Marginal Expected Counts

Suppose the condition-0 mean for a donor with both random effects equal to zero is 10 counts at the exposure of interest. Let \(\beta_1=\log(1.4)\), \(\tau_{00}=0.16\), \(\tau_{01}=0.02\), and \(\tau_{11}=0.04\). These variances and covariance are valid: \(0.16(0.04)-0.02^2=0.006>0\). Find the marginal expected count in each condition and their ratio.

A conditional baseline mean of 10 corresponds to \(\exp(\beta_0)d=10\). Averaging across random effects gives

$$ E(Y\mid x=0)=10\exp(0.16/2) =10\exp(0.08)\approx 10.83. $$

For condition 1, the variance of the sum of random effects is \(0.16+2(0.02)+0.04=0.24\). Therefore,

$$ E(Y\mid x=1)=10(1.4)\exp(0.24/2) =14\exp(0.12)\approx 15.78. $$

The ratio is \(15.78/10.83\approx1.457\), with small differences possible from rounding. Directly, the ratio is \(1.4\exp(0.02+0.04/2)=1.4\exp(0.04)\approx1.457\). It is about a 45.7% higher population-average expected count under condition 1, not a causal claim unless the study design and assumptions support a causal interpretation.

Assumptions, Diagnostics, and Alternatives

These formulas rely on a correctly specified log-link conditional mean, centered Gaussian random effects with finite variances, and the same target donor distribution under both conditions. A paired design may naturally give the same donor distribution in both conditions. For independent groups, the interpretation requires that the random-effects distribution represents the intended comparable population; different donor compositions can otherwise affect the comparison. The equal-exposure formulas also require matching exposure, or an explicit adjustment for exposure.

The normality assumption matters because the exponential of a random effect is being averaged. If the random-slope distribution is not normal, the moment-generating-function formulas may not apply; the relevant expectation must be calculated under the actual distribution or estimated numerically. Even with normal random effects, estimates near a singular covariance matrix can make marginal effects unstable. Convergence and singularity checks, fitted-mean checks, dispersion diagnostics, and influence checks are useful when assessing whether the fitted model is adequate.

A conditional mixed model and a population-averaged approach are alternatives, not interchangeable labels for the same coefficient. A generalized estimating equation (GEE) with a log link targets a population-average mean relationship under its assumptions; a mixed model specifies donor-specific random effects and obtains marginal means by integrating over their distribution. A mixed-model marginal contrast can be derived as above, whereas \(\exp(\beta_1)\) from the mixed model is conditional. The choice depends on the estimand, design, and modeling assumptions.

  • Misreading the fixed effect: “\(\exp(\beta_1)\) is the population-average fold change.” This is generally false with random slopes. It is the conditional ratio at random slope zero.
  • Averaging the wrong quantity: Averaging donor-specific fold changes is not the same as dividing the two average counts. Calculate the condition-specific marginal means first when the target is their ratio.
  • Ignoring covariance: Random-intercept/slope covariance affects the marginal ratio through \(\tau_{01}\). It does not affect the average conditional ratio.
  • Overstating interpretation: A model-based contrast is an association unless the design and assumptions justify a causal interpretation.
Key takeaway: With a log link and Gaussian random intercepts and slopes, the population-average fold change is \(\exp(\beta_1+\tau_{01}+\tau_{11}/2)\), while the average conditional fold change is \(\exp(\beta_1+\tau_{11}/2)\). State which effect is being reported and why it matches the scientific target.

Check Your Understanding

Try each question, then check the solutions below.

  1. With a random intercept only, equal exposure, and \(\beta_1=\log(1.25)\), what is the population-average fold change, regardless of the random-intercept variance?
  2. Suppose \(\beta_1=\log(1.5)\), \(\tau_{01}=-0.03\), and \(\tau_{11}=0.08\). Calculate the population-average fold change and the average conditional fold change.
  3. For a donor with \(b_{1i}=0.2\), \(\beta_1=\log(1.8)\), and equal exposure, calculate the conditional fold change.
  4. In one sentence, explain why an intercept-slope covariance can change a ratio of marginal means but not the average conditional fold change.

Solutions. (1) The random-intercept factor cancels, so the ratio is \(\exp\{\log(1.25)\}=1.25\). (2) The marginal ratio is \(1.5\exp(-0.03+0.08/2)=1.5\exp(0.01)\approx1.515\). The average conditional ratio is \(1.5\exp(0.08/2)=1.5\exp(0.04)\approx1.561\). (3) The donor-specific ratio is \(\exp\{\log(1.8)+0.2\}=1.8\exp(0.2)\approx2.199\). (4) The marginal means separately average \(b_{0i}\) and \(b_{0i}+b_{1i}\), so their ratio depends on covariance, whereas the conditional ratio cancels \(b_{0i}\) before averaging and depends only on the random-slope distribution.

Clinical Biostats