Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Degrees of Freedom in Mixed-Model Tests

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

Degrees of Freedom in Mixed-Model Tests

Learn how to select and interpret degrees-of-freedom approximations for fixed-effect tests in pseudobulk mixed models with limited donor replication.

Advanced 12 min read

What You'll Learn

  • Explain why mixed-model fixed-effect tests have uncertain variance estimates when donor numbers are small.
  • Calculate a Satterthwaite degrees-of-freedom approximation by matching variance estimates.
  • Distinguish Satterthwaite and Kenward–Roger tests from residual-df and large-sample normal tests.
  • Interpret how a test’s degrees of freedom affect its p-value and critical value.
  • Recognize when donor-level replication, rather than the number of pseudobulk rows, constrains inference.

Why Degrees of Freedom Matter

A fixed-effect estimate in a pseudobulk mixed model is typically reported with a standard error and a test statistic. With many independent donors, the test statistic may be well approximated by a standard normal distribution. With few donors, however, the variance components used to estimate that standard error are themselves uncertain. A reference distribution with finite degrees of freedom can better reflect this uncertainty, producing a different p-value or confidence interval from a normal approximation.

The key issue is not simply how many pseudobulk rows appear in the data table. Repeated pseudobulk samples from one donor are correlated, and the number of independent donors can be much smaller than the total number of rows. The introductory material on pseudobulk inference with few donors motivates that distinction; here the focus is how it enters fixed-effect tests through the choice of degrees of freedom.

Model and Test

Consider a gene-level response \(y_{ij}\), such as normalized log expression for donor \(i\) under condition or time point \(j\). A simple random-intercept model is

$$ y_{ij}=x_{ij}^{\mathsf T}\beta+b_i+\varepsilon_{ij}, \qquad b_i\sim N(0,\tau^2), \qquad \varepsilon_{ij}\sim N(0,\sigma^2). $$

Here \(x_{ij}\) is the fixed-effect design vector, \(\beta\) is the vector of fixed coefficients, \(b_i\) is a donor-specific random intercept, and \(\varepsilon_{ij}\) is residual error. The usual model assumptions include independent donors, random effects independent of residual errors, and the stated covariance structure being adequate. For small-sample t-based inference, the relevant response or contrast errors are also assumed sufficiently close to normal. More elaborate covariance structures change the variance calculation but not the central degrees-of-freedom issue.

Definition: For a fixed-effect contrast \(c^{\mathsf T}\beta\), the estimated contrast is \(c^{\mathsf T}\hat{\beta}\). Its estimated standard error is \(SE=\sqrt{\widehat{\mathrm{Var}}(c^{\mathsf T}\hat{\beta})}\). To test \(H_0:c^{\mathsf T}\beta=0\), the Wald statistic is \(t=c^{\mathsf T}\hat{\beta}/SE\). A degrees-of-freedom approximation selects a reference t or F distribution for this statistic; it does not change the contrast being tested.

A t reference distribution has heavier tails than the standard normal when its degrees of freedom are small. Thus, for the same observed \(t\), a small-df test generally has a larger two-sided p-value and a larger critical value. Degrees of freedom are an approximation to the uncertainty in the estimated variance, not a direct count of cells, genes, or observations.

Satterthwaite Approximation

The Satterthwaite method approximates the sampling distribution of an estimated contrast variance by matching its first two moments to a scaled chi-square distribution. The basic argument is clearest when a variance estimate is a sum of independent components. Suppose \(\hat v=\sum_k\hat v_k\), each component has expectation \(v_k\), and approximately \(\hat v_k\sim v_k\chi^2_{\nu_k}/\nu_k\). Then

$$ E(\hat v)=v=\sum_k v_k,\qquad \mathrm{Var}(\hat v)=\sum_k\frac{2v_k^2}{\nu_k}. $$

Approximate \(\hat v\) by \(v\chi^2_{\nu}/\nu\). This scaled chi-square has expectation \(v\) and variance \(2v^2/\nu\). Equating its variance to the variance of \(\hat v\) gives

$$ \frac{2v^2}{\nu}=\sum_k\frac{2v_k^2}{\nu_k} \quad\Longrightarrow\quad \nu=\frac{v^2}{\sum_k v_k^2/\nu_k}. $$

In a mixed model, the contrast variance depends on estimated variance components, and the exact distribution need not be a simple sum of independent terms. Software commonly uses a Satterthwaite approximation based on how the estimated contrast variance changes with those components and on the estimated covariance of the components. In a delta-method formulation, if \(g\) is the gradient of the contrast variance with respect to the variance components and \(\widehat{\mathrm{Cov}}(\hat{\theta})\) is their estimated covariance matrix, then an approximate variance for the estimated contrast variance is \(g^{\mathsf T}\widehat{\mathrm{Cov}}(\hat{\theta})g\). Matching moments yields

$$ df \ \approx\ \frac{2\hat v^2} {g^{\mathsf T}\widehat{\mathrm{Cov}}(\hat{\theta})g}, $$

where \(\hat v\) is the estimated variance of the contrast. This explains why the degrees of freedom can be non-integer and can differ across contrasts in the same fitted model: different contrasts depend differently on uncertain variance components.

Worked Example: Testing a Condition Effect With Satterthwaite Degrees of Freedom

Suppose a hypothetical pseudobulk mixed-model analysis estimates a condition effect of \(0.350\) log2-expression units, with \(SE=0.1414\) log2-expression units and Satterthwaite \(df=9.677\). Test \(H_0:\beta_{\mathrm{condition}}=0\) against a two-sided alternative at \(\alpha=0.05\). Assume the model fit is usable, the contrast and standard error are calculated on the stated scale, and the approximate t reference distribution is appropriate.

The observed statistic is

$$ t=\frac{0.350}{0.1414}=2.4752. $$

Using a t distribution with \(9.677\) degrees of freedom, the two-sided p-value is \(2P(T_{9.677}\geq 2.4752)\approx 0.03354\). Since \(0.03354<0.05\), reject \(H_0\) at the 5% level. The estimated condition contrast is positive; this test provides evidence against a zero contrast under the model and its assumptions. It does not establish that condition caused the difference.

For comparison, the standard-normal two-sided p-value for \(2.4752\) is about \(0.0133\), much smaller. Using the normal reference would understate the tail probability here because it does not account for the finite-df uncertainty represented by the t approximation.

How Common Strategies Differ

StrategyWhat it doesImportant qualification
SatterthwaiteApproximates the degrees of freedom for a particular contrast by moment matching.Often contrast-specific; relies on an approximation to variance-estimation uncertainty.
Kenward–RogerAdjusts the estimated fixed-effect covariance matrix for small-sample bias and uses an approximate finite-df test, often an adjusted F test.Can improve small-sample calibration under its model assumptions, but is not an exact correction or a guarantee of valid inference.
Residual df, such as \(N-p\)Uses the number of rows \(N\) minus the number of fixed-effect coefficients \(p\).May count repeated rows as if they supplied independent information about a contrast.
Normal or large-sample testCompares the Wald statistic with a standard normal distribution, or an analogous large-sample chi-square distribution.Can be reasonable with substantial independent replication; may be anti-conservative with few donors.

Kenward–Roger and Satterthwaite are commonly used for Gaussian linear mixed models, but their results need not match. Kenward–Roger modifies the estimated covariance of fixed effects as well as the reference distribution; Satterthwaite focuses on approximating the degrees of freedom. Neither method repairs a misspecified covariance structure, confounding, or too little independent replication. For models fitted with a non-Gaussian response, the available small-sample procedures and their justification depend on the model and software; one should not assume that a Gaussian mixed-model correction transfers automatically.

Worked Example: Moment Matching for a Contrast Variance

Suppose a hypothetical contrast variance estimate can be approximated as the sum of two independent variance components. Their estimated contributions to the variance are \(v_1=0.0100\) with \(\nu_1=4\) degrees of freedom and \(v_2=0.0025\) with \(\nu_2=20\). Assume the scaled-chi-square approximation for each component is reasonable. The total estimated variance is

$$ \hat v=0.0100+0.0025=0.0125. $$

Using the Satterthwaite moment-matching formula,

$$ df\approx \frac{(0.0125)^2}{(0.0100)^2/4+(0.0025)^2/20} =\frac{0.00015625}{0.00002500+0.0000003125} =6.173. $$

The first component contributes most of the uncertainty, and it has only 4 degrees of freedom; accordingly, the combined approximation is much closer to 4 than to 20. If the estimated contrast is \(0.300\) units, its standard error is \(\sqrt{0.0125}=0.1118\) units and its Wald statistic is \(0.300/0.1118=2.683\). The resulting test should use the approximate \(df=6.173\), not the sum \(4+20\): adding component degrees of freedom would ignore their unequal contributions to the variance.

Donor-Level Replication and a Paired Example

A particularly clear benchmark is a paired design in which each donor contributes one pseudobulk observation under each of two conditions. If donor differences are independent and normally distributed with a common variance, testing the mean difference is a one-sample t test on the donor-level differences. With \(D\) complete donors, its degrees of freedom are exactly \(D-1\) under those assumptions. A random-intercept model for the same balanced two-condition design expresses the pairing differently, but the within-donor contrast is still the information that identifies the condition effect.

Worked Example: Why Row Count Does Not Set the Paired-Test Degrees of Freedom

Consider hypothetical log2-expression differences (condition B minus condition A) for six independent donors: \(0.0, 0.1, 0.2, 0.3, 0.4,\) and \(0.8\) log2 units. Assume the six donor differences are independent and approximately normal with a common variance, and there are no missing pairs. The mean difference is

$$ \bar{x}=\frac{0.0+0.1+0.2+0.3+0.4+0.8}{6}=0.300. $$

The sum of squared deviations from \(0.300\) is \(0.400\), so the sample variance is \(s^2=0.400/(6-1)=0.0800\) square log2 units. Thus \(SE=s/\sqrt{6}=\sqrt{0.0800/6}=0.1155\) log2 units, and

$$ t=\frac{0.300}{\sqrt{0.0800/6}}=2.598,\qquad df=6-1=5. $$

At a two-sided 5% level, the \(t_5\) critical value is approximately \(2.571\). Since \(|2.598|>2.571\), this paired t test rejects a zero mean difference at that level. There are 12 pseudobulk rows, but only six independent donor-level differences. Treating the rows as independent replicates would not preserve the pairing and would overstate the independent information.

Diagnostics, Limitations, and Common Mistakes

Degrees of freedom are part of the inferential method, so their value should be inspected and reported alongside the test statistic and p-value. In software, check which method was requested, whether the reported degrees of freedom are contrast-specific, and whether the fitting procedure actually returned the requested approximation. Different software defaults can produce different tests from the same fitted model. When Satterthwaite and Kenward–Roger give notably different results, that discrepancy signals sensitivity to small-sample variance estimation; it is not a reason to select whichever p-value is preferred.

  • Using total rows as independent replication. Repeated rows within a donor are correlated under the model. Identify the independent sampling units and use a model that represents the repeated structure.
  • Assuming \(N-p\) is always the right df. That quantity is familiar from simple linear regression, but a mixed model estimates covariance components as well. It does not generally capture the uncertainty of a mixed-model contrast variance.
  • Assuming fractional degrees of freedom are an error. Moment matching can produce non-integer values; the t distribution is defined for positive real degrees of freedom.
  • Treating the approximation as a remedy for poor design. No degrees-of-freedom method creates donor replication. Very few donors, strong imbalance, boundary variance estimates, or a poorly supported covariance model can make inference fragile.
  • Reporting a p-value without its test specification. State the contrast, test statistic, degrees-of-freedom method and value, and p-value. This makes clear whether the result used a finite-df approximation or a large-sample reference.

The appropriate strategy depends on the model, design, and software implementation. For a Gaussian mixed model with a small number of independent donors, a validated Satterthwaite or Kenward–Roger procedure is often preferable to an unqualified normal approximation. In a simple paired design, donor-level differences provide a transparent reference analysis. In every case, the assumptions behind the chosen reference distribution matter: normality of the relevant errors, independent donors, and a plausible covariance structure cannot be replaced by a degrees-of-freedom calculation.

Key takeaway: In small-sample mixed-model tests, degrees of freedom represent uncertainty in estimating the contrast variance. They are not automatically the number of pseudobulk rows minus the number of coefficients. Choose and report a defensible approximation, and interpret it in light of the independent donor replication.

Check Your Understanding

Try each question, then check the solutions below.

  1. A fixed-effect estimate is \(0.24\) with \(SE=0.12\). What is its Wald statistic, and what additional information is needed to obtain a finite-df two-sided p-value?
  2. Why can a Satterthwaite degrees-of-freedom estimate be non-integer and vary between contrasts?
  3. In the moment-matching example, which variance component contributes more to the denominator, and why does that affect the approximate degrees of freedom?
  4. A paired study has 9 complete donors and two pseudobulk rows per donor. Under the normal paired-difference assumptions, what are the degrees of freedom for the paired t test?
  5. Why does a Kenward–Roger or Satterthwaite adjustment not solve a design with too few independent donors?

Solutions. (1) \(t=0.24/0.12=2.00\). A finite-df p-value also requires the reference degrees of freedom and the specified one- or two-sided alternative. (2) Moment matching need not yield an integer, and each contrast can depend differently on the estimated variance components. (3) The first component contributes \(0.0100^2/4=0.00002500\), compared with \(0.0025^2/20=0.0000003125\) for the second; its larger contribution and lower component df reduce the effective df. (4) \(9-1=8\), because the paired test uses nine independent donor differences. (5) The adjustment approximates uncertainty under a fitted model; it cannot add independent observations or make weakly supported variance estimates precise.

Clinical Biostats