Random Effects & Mixed Models
A fixed-effect analysis compares the particular levels under study. A random-effect analysis treats observed levels as draws from a population and asks how much variation that population contributes. The distinction comes from the sampling plan and inferential goal, not whether the factor is numeric or categorical.
One Random Factor¶
For groups and observations per group,
where are independent group effects and all residuals are independent of them. The mean of the group-effect distribution is zero; the realized group effects need not sum to zero.
The marginal variance is . Two distinct observations in the same group share , so their covariance is . Consequently,
is the intraclass correlation. It measures within-group similarity and the between-group fraction of marginal variance in this model.
Expected Mean Squares¶
The balanced ANOVA arithmetic is unchanged from a one-way fixed model. Its interpretation changes:
| Source | df | Expected mean square |
|---|---|---|
| Groups | ||
| Error |
Thus the normal-model test of uses with df. The alternative is positive variance, so use the upper tail.
Method-of-moments estimates are
Why the group mean square contains a factor of n
A group mean has variance . The between-group mean square is times the sample variance of the independent group means. Its expectation is therefore .
For an illustrative experiment with , , and , the estimates are , , and .
A negative moment estimate can occur when . It does not imply a negative population variance. Report the estimation issue and use an appropriate nonnegative estimation method, such as constrained REML, when fitting the model; simply truncating at zero changes the estimator.
Two Crossed Random Factors¶
For levels of A, levels of B, and replicates per cell,
Assume mutually independent zero-mean normal effects with variances respectively.
| Source | df | Expected mean square | Denominator for testing its variance component |
|---|---|---|---|
| A | |||
| B | |||
| AB | |||
| Error | , |
For example, under , and estimate the same quantity. Comparing A with would leave interaction variation in the numerator only. Normality and the balanced orthogonal design supply the independent scaled chi-square distributions needed for these exact F tests; matching expectations alone is not sufficient in arbitrary models.
Subtracting expected mean squares gives
Covariance Depends on What Is Shared¶
Let . Distinct observations sharing only A have covariance ; sharing only B gives ; sharing the same cell gives . Divide the appropriate covariance by for the correlation. A single interaction variance fraction is not, by itself, the same-cell correlation.
A Fixed, B Random: Restricted Mixed Model¶
Replace by fixed constants , with . In the restricted mixed model, require
Here is the covariance-scale parameter; it is not the variance of a single constrained interaction. Different B groups are independent, and and residuals are independent of the interactions.
Derive the negative covariance
Since and , subtracting the group mean gives variance . For distinct , the covariance is .
The expected mean squares become
| Null hypothesis | F statistic | Numerator / denominator df |
|---|---|---|
| All | / | |
| / | ||
| / |
The interaction cancels when averaging across all fixed A levels within a B level. That is why it is absent from . It does not cancel from contrasts between A levels, which explains the interaction denominator for testing A.
For this restricted model, . There is no to estimate because A has fixed effects.
Do Not Mix Model Conventions¶
An unrestricted mixed model uses independent without the sum-to-zero restriction. Then includes , and the B test uses . The comparison of mixed-model conventions explains this distinction. Identify the assumptions used by a software fit before choosing an ANOVA denominator.
Practical Limits¶
These simple tables assume a balanced design, common residual variance, independent random components, and sufficient replication. With , interaction and residual variance cannot be separated by the usual cell replication. Missing cells or unequal group sizes generally require a model-based mixed-effects analysis rather than these plug-in formulas.
For a one-way model, . More observations per group reduce residual uncertainty, but adding independent groups is needed to reduce the group component effectively. Treating all observations as independent ignores this distinction.