Fact-checked by Grok 2 weeks ago

Random effects model

In statistics, the random effects model is a for analyzing where certain factors or effects are treated as random variables drawn from a specific , typically , enabling inferences about a broader of possible levels rather than just the observed ones. This approach contrasts with fixed effects models by assuming that the random effects capture unexplained variability across groups or units, such as treatments sampled from a larger set, and is formally expressed in a basic one-way model as Y_{ij} = \mu + \tau_i + \epsilon_{ij}, where \tau_i \sim N(0, \sigma_\tau^2) represents the random effect for the i-th level and \epsilon_{ij} \sim N(0, \sigma^2) is the , with between \tau_i and \epsilon_{ij}. The total variance of observations is then \sigma_\tau^2 + \sigma^2, and a key is the coefficient \rho = \sigma_\tau^2 / (\sigma_\tau^2 + \sigma^2), which quantifies the proportion of total variance due to the random effects. Random effects models differ fundamentally from fixed effects models in their scope of inference and assumptions about the factors involved. In fixed effects models, the levels of a factor are considered exhaustive and specifically chosen by the researcher, limiting inferences to those particular levels and testing hypotheses about equality of means (e.g., H_0: \mu_i = \mu); random effects, however, treat levels as a random sample from a larger , broadening inferences to that population and testing whether the variance of the effects is zero (e.g., H_0: \sigma_\tau^2 = 0). This distinction arises because random effects account for hierarchical or clustered data structures, where observations within groups are correlated, adjusting standard errors for tests on other effects and preventing underestimation of variability. Random effects models are integral to linear mixed models (LMMs), which combine fixed effects—representing all possible levels of interest for direct inference, such as specific treatments—with random effects for sampled factors like blocks, replications, or locations to model additional variability. In LMMs, random effects are specified separately (e.g., via a random statement in software), and they adjust the standard errors for fixed effect tests, making the model suitable for experimental designs like split-plot or repeated measures where repeated effects over time require structures. Applications extend to fields like for analyzing field trials across varying locations, and in for where individual-specific effects are assumed uncorrelated with regressors. In meta-analysis, the random effects model assumes true effects vary across studies due to heterogeneity, incorporating between-study variance to provide more conservative estimates than fixed-effect alternatives.

Fundamentals

Definition and Qualitative Description

A random effects model is a statistical framework in which certain model parameters, such as intercepts or slopes, are treated as random variables drawn from a specified , enabling the incorporation of unobserved heterogeneity or variation across groups, individuals, or units in the data. This approach allows the model to account for clustering or in observations that arise from shared unmeasured factors, such as repeated measures on the same , rather than assuming all observations are independent. Qualitatively, random effects models provide an intuitive way to model data where the levels of a are viewed as a random sample from a broader , rather than fixed and exhaustive categories of . For instance, in studying effects across multiple , a random effects model treats school-specific deviations as draws from a , capturing natural variation due to unmeasured school characteristics like culture or resources, which induces correlation among students within the same school. In contrast, fixed effects would assume uniform parameters across all units, ignoring such group-level variability. This perspective shifts the focus from estimating specific effects for each level to estimating the overall variance in those effects, facilitating generalizations beyond the observed sample. Key assumptions underlying random effects models include that the random effects follow a with mean zero and constant variance, reflecting their role as deviations from the population mean without systematic bias. In models including fixed effects and covariates, the random effects are assumed to be of the covariates, ensuring that unobserved heterogeneity does not correlate with observed predictors and supporting unbiased estimation of fixed effects. The origins of random effects models trace back to the development of variance components analysis in the 1940s and 1950s, building on R.A. Fisher's foundational work in the on analysis of variance for agricultural experiments at Rothamsted Experimental Station, where he introduced methods to partition variance into components attributable to different sources. Frank Yates, collaborating with Fisher, extended these ideas in the 1930s through studies on sampling designs and yield estimation, laying groundwork for handling random variation in experimental data. This evolved into modern mixed-effects models through seminal contributions like the 1982 framework by Laird and Ware, which formalized random effects for longitudinal .

Comparison with Fixed Effects Models

Random effects models differ from fixed effects models primarily in the scope of and the treatment of . In fixed effects models, the levels of a are considered fixed and of specific interest to the researcher, with inferences limited to those levels; hypotheses typically test the equality of means across levels (e.g., H_0: \mu_i = \mu). Random effects models, however, treat the levels as a random sample from a larger , allowing inferences about the variance of effects (e.g., H_0: \sigma_\tau^2 = 0) and enabling beyond the observed levels. This distinction is particularly relevant in hierarchical or clustered data, where random effects account for correlation within groups, adjusting estimates and standard errors accordingly. In applications like analysis in , fixed effects can control for unobserved time-invariant heterogeneity that may correlate with covariates, while random effects assume exogeneity (no such correlation) for efficiency and the ability to estimate time-invariant effects; the Hausman test can help select between them. However, in general statistical contexts such as ANOVA or linear mixed models, the focus remains on the inferential scope rather than bias correction.

Mathematical Formulation

Basic Model Structure

The random effects model, also known as a linear mixed-effects model, is formulated as a hierarchical that incorporates both fixed and random effects to account for variation across groups or clusters in the data. In its basic scalar form for the j-th observation within the i-th group, the model is expressed as y_{ij} = X_{ij} \beta + Z_{ij} b_i + \epsilon_{ij}, where y_{ij} is the response variable, X_{ij} \beta represents the fixed effects contribution with \beta as the vector of fixed-effect parameters, Z_{ij} b_i captures the random effects for group i with b_i \sim N(0, G) denoting the random effects vector assumed to follow a with mean zero and G, and \epsilon_{ij} \sim N(0, R) is the residual error term with R. This structure allows the model to handle clustered data by treating group-specific deviations b_i as random draws from a , thereby generalizing fixed effects approaches to induce dependence within groups. The model adopts a two-stage hierarchical interpretation. In the first stage, the conditional distribution of the response given the random effects is specified as y_{ij} | b_i \sim N(X_{ij} \beta + Z_{ij} b_i, R), modeling the within-group variability around the group-specific mean. The second stage then specifies the distribution of the random effects themselves as b_i \sim N(0, G), which introduces between-group variability and ensures that observations within the same group i are correlated through the shared b_i term, with the covariance between y_{ij} and y_{ik} (for j \neq k) arising from \text{Cov}(Z_{ij} b_i, Z_{ik} b_i) = Z_{ij} G Z_{ik}^T. This hierarchical setup facilitates inference about the fixed effects \beta while borrowing strength across groups via the random effects distribution. In matrix notation, the full model for the stacked response vector \mathbf{y} across all groups is \mathbf{y} = X \beta + Z \mathbf{b} + \epsilon, where \mathbf{y} is the n \times 1 response vector, X is the n \times p fixed-effects design matrix, Z is the n \times q random-effects design matrix, \mathbf{b} \sim N(0, \Sigma_b) is the stacked q \times 1 random effects vector with covariance \Sigma_b = \text{blockdiag}(G_1, \dots, G_m) for m groups, and \epsilon \sim N(0, \Sigma_\epsilon) with \Sigma_\epsilon = \text{blockdiag}(R_1, \dots, R_m). The resulting marginal covariance structure of \mathbf{y} is V = Z \Sigma_b Z^T + \Sigma_\epsilon, which captures the total variability as a combination of random effects and residual components, leading to a marginal normal distribution \mathbf{y} \sim N(X \beta, V). Key assumptions underlying this model include the normality of both the random effects \mathbf{b} and the residuals \epsilon, independence between \mathbf{b} and \epsilon, and, under the common conditional independence assumption, homoscedasticity within groups such that R = \sigma^2 I (implying equal residual variances and no additional autocorrelation beyond that induced by the random effects). These assumptions ensure that the induced correlations are solely attributable to the shared random effects within groups, enabling valid likelihood-based inference.

Variance Components

In the random effects model, the total variance of the observed response variable y is decomposed into two primary components: the between-group variance attributable to the random effects, denoted \sigma_b^2, and the within-group variance, denoted \sigma_\epsilon^2. This partitioning is expressed as \sigma_y^2 = \sigma_b^2 + \sigma_\epsilon^2, where \sigma_y^2 represents the marginal variance of y. This decomposition highlights how unobserved heterogeneity across groups contributes to the overall variability in the data, separate from measurement error or other . A key metric derived from this decomposition is the intraclass correlation coefficient (), defined as \rho = \frac{\sigma_b^2}{\sigma_b^2 + \sigma_\epsilon^2}. The ICC quantifies the proportion of total variance explained by the random effects or grouping structure, ranging from 0 (no clustering) to 1 (complete clustering). Values of \rho close to 0 suggest that observations within groups are nearly independent, while higher values indicate stronger dependence due to shared random effects. Conceptually, variance components are estimated by partitioning the into between-group and within-group portions, akin to analysis of variance (ANOVA) procedures, where expected mean squares inform the components under normality assumptions. This approach provides a foundation for interpreting heterogeneity, though detailed estimation techniques are addressed elsewhere. A large \sigma_b^2 relative to \sigma_\epsilon^2 signals substantial unobserved heterogeneity among groups, justifying the inclusion of random effects to account for clustering. In balanced designs with equal group sizes, components are readily identifiable from the ANOVA table; however, unbalanced designs introduce complexities, as varying group sizes affect the of sums of squares and can complicate the separation of variance sources.

Estimation and Inference

Maximum Likelihood Methods

In random effects models, (MLE) involves maximizing the with respect to the fixed effects parameters \beta and the variance-covariance parameters \Sigma, treating the random effects as parameters. To obtain a tractable form, the is constructed by integrating out the random effects b, yielding L(\beta, \Sigma | y) = \int L(y | \beta, b, \Sigma) f(b | \Sigma) \, db, where L(y | \beta, b, \Sigma) is the conditional likelihood of the observed y given \beta, b, and \Sigma, and f(b | \Sigma) is the density of the random effects. Under normality assumptions for both the random effects and residuals, this integration results in a multivariate marginal distribution for the data: y \sim N(X\beta, V), where V = Z G Z^T + R incorporates the variance components from the random effects design matrix Z, G, and residual R. The -likelihood function is then \ell(\beta, \Sigma) = -\frac{1}{2} \left[ n \log(2\pi) + \log|V| + (y - X\beta)^T V^{-1} (y - X\beta) \right], where n is the sample size. Computing this requires evaluating the and of V, which poses numerical challenges for large datasets due to the high dimensionality and potential ill-conditioning of V. Optimization proceeds iteratively, often using the algorithm to handle the implicitly. The algorithm alternates between an step, computing expected values of the random effects given current estimates, and a maximization step, updating \beta via the estimator \hat{\beta} = (X^T V^{-1} X)^{-1} X^T V^{-1} y and profiling the likelihood for \Sigma to obtain variance component estimates. Under correct model specification and suitable regularity conditions, such as increasing sample size with fixed dimensionality of random effects, the MLEs are consistent and asymptotically normal, with \sqrt{n} (\hat{\beta} - \beta) \to N(0, (X^T V^{-1} X / n)^{-1}) and similar results for \Sigma. However, in small samples, the MLE tends to underestimate variance components due to the incidental parameters problem.

Restricted Maximum Likelihood (REML)

Restricted maximum likelihood (REML) is an estimation method for variance components in random effects models that maximizes the likelihood of a transformed set of contrasts in the data, which are orthogonal to the fixed effects. This approach focuses on the residuals after accounting for fixed effects, providing an unbiased estimate of the variance parameters by effectively removing the influence of the fixed effect estimators from the likelihood function. Introduced by Patterson and Thompson in 1971, REML is particularly valuable in balanced designs where it yields estimators equivalent to those from analysis of variance for variance components. The REML likelihood can be expressed in relation to the maximum likelihood (MLE) as
L_{\text{REML}} = L_{\text{MLE}} \times |X^T V^{-1} X|^{-p/2},
where p is the number of fixed effects, X is the for fixed effects, and V is the variance-covariance matrix depending on the variance components. This adjustment penalizes the likelihood for the degrees of freedom lost in estimating the fixed effects \beta, ensuring that the variance estimates, such as \sigma^2, are unbiased even in small samples.
Compared to MLE, REML offers key advantages by reducing downward in variance component estimates; for instance, the of the MLE for \sigma^2 is (n - p)/n \cdot \sigma^2, whereas REML corrects this to match the unbiased sample variance in simple cases. This bias correction makes REML the preferred method for testing on variance components, as it provides more reliable errors and intervals for random effects variances. The estimation procedure for REML mirrors that of MLE, involving iterative optimization techniques such as or Newton-Raphson algorithms to maximize the adjusted log-likelihood, often using transformed data contrasts w = A'y where A spans the null space of X^T. In practice, software implements this by profiling out the fixed effects and optimizing over variance parameters alone. For large samples, REML estimators are asymptotically equivalent to MLE, converging to the same values as the number of observations increases. Despite its benefits, REML has limitations, including a lack of invariance to reparameterization of the model, which can affect the properties of estimates under different formulations. Additionally, it can be computationally more intensive than MLE in unbalanced designs due to the need to handle the X^T V^{-1} X explicitly during iterations.

Examples and Applications

Simple Example

To illustrate the random effects model, consider a simulated consisting of test scores for 3 students in each of 5 classrooms, where scores are clustered by classroom.Mixed-Effects Models in S and S-PLUS (Pinheiro and Bates, 2000) The data are generated to reflect a with an overall level and variation both within and between classrooms, as follows:
ClassroomStudent 1Student 2Student 3Group Mean
166687068
268707270
367697169
471737573
568707270
Overall Mean70
The basic random effects model applied here is y_{ij} = \beta_0 + b_i + [\epsilon_{ij}](/page/Epsilon), where y_{ij} is the for student j in i, \beta_0 is the fixed overall intercept, b_i \sim N(0, \sigma_b^2) captures the random classroom effect, and \epsilon_{ij} \sim N(0, \sigma_\epsilon^2) is the residual error, with i = 1, \dots, 5 and j = 1, 2, 3.Mixed-Effects Models in S and S-PLUS (Pinheiro and Bates, 2000) Fitting the model using (REML) yields the estimates \hat{\beta_0} = 70, \hat{\sigma}_b^2 \approx 2.2, and \hat{\sigma}_\epsilon^2 \approx 4.0.Mixed-Effects Models in S and S-PLUS (Pinheiro and Bates, 2000) The coefficient (ICC), which measures the proportion of total variance attributable to the random classroom effects, is given by \hat{\rho} = \frac{\hat{\sigma}_b^2}{\hat{\sigma}_b^2 + \hat{\sigma}_\epsilon^2} \approx 0.36.Mixed-Effects Models in S and S-PLUS (Pinheiro and Bates, 2000) This indicates that approximately 36% of the variability in test scores is explained by differences between classrooms, highlighting the importance of accounting for clustering. Individual classroom effects b_i are predicted using best linear unbiased predictors (BLUPs), which shrink the observed group means toward the overall mean \hat{\beta_0}, with shrinkage factor \lambda_i = \frac{\hat{\sigma}_b^2}{\hat{\sigma}_b^2 + \hat{\sigma}_\epsilon^2 / n_i} \approx 0.62 (where n_i = 3).Mixed-Effects Models in S and S-PLUS (Pinheiro and Bates, 2000) The BLUPs are thus \hat{b}_i = \lambda_i (\bar{y}_i - \hat{\beta_0}), resulting in predicted intercepts \hat{\beta_0} + \hat{b}_i of approximately 68.8, 70.0, 69.6, 71.9, and 70.0, respectively. These shrunk estimates reduce error compared to using raw group means, as the random effects borrows strength across classrooms to stabilize estimates for small groups. To highlight efficiency gains, compare the fixed effects approach (treating classroom effects as fixed parameters) with the random effects BLUPs. In the , classroom-specific intercepts are simply the group means (68, 70, 69, 73, 70), estimated without shrinkage and using 5 parameters for the effects alone.Mixed-Effects Models in S and S-PLUS (Pinheiro and Bates, 2000) The random effects model, by contrast, estimates a single variance component \sigma_b^2 instead, leading to more efficient predictions via shrinkage—particularly beneficial with limited data per group—as the for the b_i is lower under the random effects assumption.Mixed-Effects Models in S and S-PLUS (Pinheiro and Bates, 2000)
ClassroomFixed Effect Estimate (Group Mean)Random Effect BLUP (Predicted Intercept)
16868.8
27070.0
36969.6
47371.9
57070.0

Broader Applications

Random effects models find extensive application in analyzing longitudinal data, where growth curve modeling accommodates repeated measures over time while accounting for individual variability. In clinical trials, for instance, these models track patient outcomes such as or symptom severity, incorporating random slopes to capture heterogeneous trajectories across participants. This approach, building on the seminal two-stage random-effects framework, enables inference on both population-level trends and subject-specific deviations. In hierarchical or multilevel settings, random effects models address nested data structures prevalent in fields like and . For , they model student performance nested within schools, allowing random intercepts for school-specific effects and random slopes for varying impacts of predictors like . Similarly, in ecology, observations clustered within sites—such as species abundance in multiple plots—can be analyzed using extensions like the three-level model y_{ijk} = \beta + u_j + v_{jk} + \epsilon_{ijk}, where u_j represents site-level random effects, v_{jk} plot-level effects, and \epsilon_{ijk} residual variation. These formulations enhance precision by partitioning variance across levels, outperforming single-level analyses in clustered designs. In , random effects models underpin analysis for firm-level studies, effectively handling unobserved heterogeneity that fixed effects might overlook, such as time-invariant firm characteristics influencing productivity. They are also integral to , where random effects pool effect sizes from diverse studies, assuming true effects vary due to methodological or contextual differences, as seen in synthesizing impacts across regions. Implementations of random effects models are widely available in statistical software, including the lme4 package in for fitting linear mixed-effects models and PROC MIXED in for handling complex variance structures. Recent advancements post-2020, particularly in Bayesian frameworks, have extended these models to complex hierarchies by incorporating priors for regularization and scalable inference, improving handling of high-dimensional data in applications like multi-omics risk prediction. Despite their versatility, random effects models face practical limitations, including in high-dimensional settings where numerous random effects inflate variance estimates without sufficient data. To mitigate this, diagnostics such as Q-Q plots are essential for verifying of residuals and random effects, ensuring model assumptions hold and guiding refinements like variance component testing.

References

  1. [1]
    6: Random Effects and Introduction to Mixed Models - STAT ONLINE
    On the other hand, if the levels of the treatment are a sample from a larger population of possible levels, then the treatment is called a random effect.6.1 - Random Effects · 6.8 - Try It! · Exercise 1
  2. [2]
    [PDF] Linear Mixed Models with Random Effects - UGA Griffin campus
    Linear mixed models model fixed, random, and repeated effects. Random effects, like replications, adjust standard errors for tests on fixed effects.
  3. [3]
    Fixed-Effect vs Random-Effects Models for Meta-Analysis - NIH
    The random-effects model assumes that the true effect could vary from study to study due to the differences (heterogeneity) among studies. For example, the ...Figure 1 · Figure 2 · Figure 3
  4. [4]
    13.1 - Random Effects Models | STAT 503
    Random effects models involve randomly selected factors, where both error and treatment effects are random, and the factor is a random sample from a larger ...Missing: definition | Show results with:definition
  5. [5]
    None
    ### Summary of Introduction to Random Effects Models for Longitudinal Data
  6. [6]
    [PDF] VARIANCE COMPONENTS - Cornell eCommons
    The origin of analysis of variance of what we now called fixed effects models is well known to be with R.A. Fisher during his years at Rothamsted. Experimental ...
  7. [7]
    Random-Effects Models for Longitudinal Data - jstor
    Models for the analysis of longitudinal data must recogrlize the relationship between serial observations on the same unit. Multivariate models with general ...
  8. [8]
    Panel Data Using R: Fixed-effects and Random-effects
    May 26, 2023 · Panel data (also known as longitudinal or cross-sectional time-series data) refers to data for n different entities at different time periods.Fixed-Effects Or... · Random-Effects · Panel Data
  9. [9]
    [PDF] Panel Data 4: Fixed Effects vs Random Effects Models
    Mar 20, 2018 · Random effects models will estimate the effects of time-invariant variables, but the estimates may be biased because we are not controlling for ...Missing: definition | Show results with:definition<|control11|><|separator|>
  10. [10]
    Maximum Likelihood Approaches to Variance Component ...
    Abstract. Recent developments promise to increase greatly the popularity of maximum likelihood (ml) as a technique for estimating variance components.
  11. [11]
    Random-effects models for longitudinal data - PubMed
    Models for the analysis of longitudinal data must recognize the relationship between serial observations on the same unit.
  12. [12]
    Maximum likelihood estimation of random effects models
    Breusch, Trevor S., 1987. "Maximum likelihood estimation of random effects models," Journal of Econometrics, Elsevier, vol. 36(3), pages 383-389, November.Missing: seminal | Show results with:seminal
  13. [13]
    Computation of variance components using the em algorithm
    Laird, and Rubin (1977) noted that both maximum likelihood (ML) and restricted ML (REML) estimators of variance components in the mixed model analysis oi ...
  14. [14]
    [PDF] REML Estimation of Variance Components - Statistics & Data Science
    Consider the General Linear Model y = Xβ + , where ∼ N(0,Σ) and Σ is an n × n positive definite variance matrix that depends on unknown parameters that are ...
  15. [15]
    [PDF] A Tutorial on Restricted Maximum Likelihood Estimation in Linear ...
    Oct 12, 2015 · Restricted maximum likelihood (ReML) is an estimation procedure that produces unbiased estimates for variance components of a linear model.Missing: seminal paper
  16. [16]
    [PDF] Closed-form REML estimators and sample size determination ... - arXiv
    ... REML estimator is smaller than that E(ˆσ2 j,ml) − σ2 j = −(q + j − 1)σ2 j /nj of the ML estimator. The bias is not invariant to reparameterization. In REML ...
  17. [17]
    Twelve Frequently Asked Questions About Growth Curve Modeling
    Growth curve models are analytic methods for studying between-person differences in within-person change, used in developmental sciences.
  18. [18]
    [PDF] Random-Effects Models for Longitudinal Data
    Random-Effects Models for Longitudinal Data. Author(s): Nan M. Laird and James H. Ware. Source: Biometrics , Dec., 1982, Vol. 38, No. 4 (Dec., 1982), pp. 963 ...
  19. [19]
    Fundamentals of Hierarchical Linear and Multilevel Modeling
    An example would be a study of employee performance score by education, controlling for gender. Most models for analysis of variance, regression, and GLM are ...
  20. [20]
    [PDF] Generalized linear mixed models: a practical guide for ecology and ...
    Generalized linear mixed models (GLMMs) provide a more flexible approach for analyzing nonnormal data when random effects are pre- sent. The explosion of ...
  21. [21]
    Students Are Rarely Independent - CBE—Life Sciences Education
    Aug 24, 2018 · This paper illustrates why and how to implement random effects in multilevel modeling. It also provides resources to promote implementation of analyses that ...
  22. [22]
    [PDF] Panel Data: Fixed and Random Effects - Kurt Schmidheiny
    Nov 21, 2024 · This handout introduces the two basic models for the analysis of panel data, the fixed effects model and the random effects model, and presents.Missing: meta- | Show results with:meta-
  23. [23]
    [PDF] lmer for SAS PROC MIXED Users
    The lmer function from the lme4 package for R is used to fit linear mixed- effects models. It is similar in scope to the SAS procedure PROC MIXED de-.
  24. [24]
    Bayesian linear mixed model with multiple random effects for ...
    Oct 26, 2023 · We proposed a two-step Bayesian linear mixed model framework (TBLMM) for risk prediction analysis on multi-omics data.Bayesian Linear Mixed Model... · 2 Materials And Methods · 3 Simulation Study
  25. [25]
    Bayesian Compressed Mixed-Effects Models - arXiv
    Jul 22, 2025 · Empirically, the CME model outperforms existing approaches in terms of predictive accuracy, interval coverage, and fixed-effects selection ...
  26. [26]
    A graphical approach to assess the goodness-of-fit of random ... - NIH
    A limitation of normal QQ plots is that the data analyst must conduct a separate analysis for each random effect in the model.Missing: overfitting | Show results with:overfitting