Mixed model
Part of a series on 
Regression analysis 

Models 
Estimation 
Background 

A mixed model, mixedeffects model or mixed errorcomponent model is a statistical model containing both fixed effects and random effects.^{[1]}^{[2]} These models are useful in a wide variety of disciplines in the physical, biological and social sciences. They are particularly useful in settings where repeated measurements are made on the same statistical units (longitudinal study), or where measurements are made on clusters of related statistical units.^{[2]} Mixed models are often preferred over traditional analysis of variance regression models because of their flexibility in dealing with missing values and uneven spacing of repeated measurements.^{[3]} The Mixed model analysis allows measurements to be explicitly modeled in a wider variety of correlation and variancecovariance structures.
This page will discuss mainly linear mixedeffects models (LMEM) rather than generalized linear mixed models or nonlinear mixedeffects models.^{[4]}
Qualitative Description
Linear mixed models (LMMs) are statistical models that incorporate fixed and random effects to accurately represent nonindependent data structures. LMM is an alternative to analysis of variance. Often, ANOVA assumes the independence of observations within each group, however, this assumption may not hold in nonindependent data, such as multilevel/hierarchical, longitudinal, or correlated datasets.
Nonindependent sets are ones in which the variability between outcomes is due to correlations within groups or between groups. Mixed models properly account for nest structures/hierarchical data structures where observations are influenced by their nested associations. For example, when studying education methods involving multiple schools, there are multiple levels of variables to consider. The individual level/lower level comprises individual students or teachers within the school. The observations obtained from this student/teacher is nested within their school. For example, Student A is a unit within the School A. The next higher level is the school. At the higher level, the school contains multiple individual students and teachers. The school level influences the observations obtained from the students and teachers. For Example, School A and School B are the higher levels each with its set of Student A and Student B respectively. This represents a hierarchical data scheme. A solution to modeling hierarchical data is using linear mixed models.
LMMs allow us to understand the important effects between and within levels while incorporating the corrections for standard errors for nonindependence embedded in the data structure.^{[4]}^{[5]}
The Fixed Effect
Fixed effects encapsulate the tendencies/trends that are consistent at the levels of primary interest. These effects are considered fixed because they are nonrandom and assumed to be constant for the population being studied.^{[5]} For example, when studying education a fixed effect could represent overall school level effects that are consistent across all schools.
While the hierarchy of the data set is typically obvious, the specific fixed effects that affect the average responses for all subjects must be specified. Some fixed effect coefficients are sufficient without corresponding random effects where as other fixed coefficients only represent an average where the individual units are random. These may be determined by incorporating random intercepts and slopes.^{[6]}^{[7]}^{[8]}
In most situations, several related models are considered and the model that best represents a universal model is adopted.
The Random Effect, ε
A key component of the mixed model is the incorporation of random effects with the fixed effect. Fixed effects are often fitted to represent the underlying model. In Linear mixed models, the true regression of the population is linear, β. The fixed data is fitted at the highest level. Random effects introduce statistical variability at different levels of the data hierarchy. These account for the unmeasured sources of variance that affect certain groups in the data. For example, the differences between student 1 and student 2 in the same class, or the differences between class 1 and class 2 in the same school. ^{[6]}^{[7]}^{[8]}
History and current status
Ronald Fisher introduced random effects models to study the correlations of trait values between relatives.^{[9]} In the 1950s, Charles Roy Henderson provided best linear unbiased estimates of fixed effects and best linear unbiased predictions of random effects.^{[10]}^{[11]}^{[12]}^{[13]} Subsequently, mixed modeling has become a major area of statistical research, including work on computation of maximum likelihood estimates, nonlinear mixed effects models, missing data in mixed effects models, and Bayesian estimation of mixed effects models. Mixed models are applied in many disciplines where multiple correlated measurements are made on each unit of interest. They are prominently used in research involving human and animal subjects in fields ranging from genetics to marketing, and have also been used in baseball ^{[14]} and industrial statistics.^{[15]} The mixed linear model association has improved the prevention of false positive associations. Populations are deeply interconnected and the relatedness structure of population dynamics is extremely difficult to model without the use of mixed models. Linear mixed models may not, however, be the only solution. LMM's have a constantresidual variance assumption that is sometimes violated when accounting or deeply associated continuous and binary traits.^{[16]}
Definition
In matrix notation a linear mixed model can be represented as
 [math]\displaystyle{ \boldsymbol{y} = X \boldsymbol{\beta} + Z \boldsymbol{u} + \boldsymbol{\epsilon} }[/math]
where
 [math]\displaystyle{ \boldsymbol{y} }[/math] is a known vector of observations, with mean [math]\displaystyle{ E(\boldsymbol{y}) = X \boldsymbol{\beta} }[/math];
 [math]\displaystyle{ \boldsymbol{\beta} }[/math] is an unknown vector of fixed effects;
 [math]\displaystyle{ \boldsymbol{u} }[/math] is an unknown vector of random effects, with mean [math]\displaystyle{ E(\boldsymbol{u})=\boldsymbol{0} }[/math] and variance–covariance matrix [math]\displaystyle{ \operatorname{var}(\boldsymbol{u})=G }[/math];
 [math]\displaystyle{ \boldsymbol{\epsilon} }[/math] is an unknown vector of random errors, with mean [math]\displaystyle{ E(\boldsymbol{\epsilon})=\boldsymbol{0} }[/math] and variance [math]\displaystyle{ \operatorname{var}(\boldsymbol{\epsilon})=R }[/math];
 [math]\displaystyle{ X }[/math] is the known design matrix for the fixed effects relating the observations [math]\displaystyle{ \boldsymbol{y} }[/math] to [math]\displaystyle{ \boldsymbol{\beta} }[/math], respectively
 [math]\displaystyle{ Z }[/math] is the known design matrix for the random effects relating the observations [math]\displaystyle{ \boldsymbol{y} }[/math] to [math]\displaystyle{ \boldsymbol{u} }[/math], respectively.
Estimation
The joint density of [math]\displaystyle{ \boldsymbol{y} }[/math] and [math]\displaystyle{ \boldsymbol{u} }[/math] can be written as: [math]\displaystyle{ f(\boldsymbol{y},\boldsymbol{u}) = f(\boldsymbol{y}  \boldsymbol{u}) \, f(\boldsymbol{u}) }[/math]. Assuming normality, [math]\displaystyle{ \boldsymbol{u} \sim \mathcal{N}(\boldsymbol{0},G) }[/math], [math]\displaystyle{ \boldsymbol{\epsilon} \sim \mathcal{N}(\boldsymbol{0},R) }[/math] and [math]\displaystyle{ \mathrm{Cov}(\boldsymbol{u},\boldsymbol{\epsilon})=\boldsymbol{0} }[/math], and maximizing the joint density over [math]\displaystyle{ \boldsymbol{\beta} }[/math] and [math]\displaystyle{ \boldsymbol{u} }[/math], gives Henderson's "mixed model equations" (MME) for linear mixed models:^{[10]}^{[12]}^{[17]}
 [math]\displaystyle{ \begin{pmatrix} X'R^{1}X & X'R^{1}Z \\ Z'R^{1}X & Z'R^{1}Z + G^{1} \end{pmatrix} \begin{pmatrix} \hat{\boldsymbol{\beta}} \\ \hat{\boldsymbol{u}} \end{pmatrix} = \begin{pmatrix} X'R^{1}\boldsymbol{y} \\ Z'R^{1}\boldsymbol{y} \end{pmatrix} }[/math]
The solutions to the MME, [math]\displaystyle{ \textstyle\hat{\boldsymbol{\beta}} }[/math] and [math]\displaystyle{ \textstyle\hat{\boldsymbol{u}} }[/math] are best linear unbiased estimates and predictors for [math]\displaystyle{ \boldsymbol{\beta} }[/math] and [math]\displaystyle{ \boldsymbol{u} }[/math], respectively. This is a consequence of the Gauss–Markov theorem when the conditional variance of the outcome is not scalable to the identity matrix. When the conditional variance is known, then the inverse variance weighted least squares estimate is best linear unbiased estimates. However, the conditional variance is rarely, if ever, known. So it is desirable to jointly estimate the variance and weighted parameter estimates when solving MMEs.
One method used to fit such mixed models is that of the expectation–maximization algorithm (EM) where the variance components are treated as unobserved nuisance parameters in the joint likelihood.^{[18]} Currently, this is the method implemented in statistical software such as Python (statsmodels package) and SAS (proc mixed), and as initial step only in R's nlme package lme(). The solution to the mixed model equations is a maximum likelihood estimate when the distribution of the errors is normal.^{[19]}^{[20]}
There are several other methods to fit mixed models, including using an MEM initially, and then NewtonRaphson (used by R package nlme^{[21]}'s lme()), penalized least squares to get a profiled log likelihood only depending on the (lowdimensional) variancecovariance parameters of [math]\displaystyle{ \boldsymbol{u} }[/math], i.e., its cov matrix [math]\displaystyle{ \boldsymbol{G} }[/math], and then modern direct optimization for that reduced objective function (used by R's lme4^{[22]} package lmer() and the Julia package MixedModels.jl) and direct optimization of the likelihood (used by e.g. R's glmmTMB). Notably, while the canonical form proposed by Henderson is useful for theory, many popular software packages use a different formulation for numerical computation in order to take advantage of sparse matrix methods (e.g. lme4 and MixedModels.jl).
See also
 Nonlinear mixedeffects model
 Fixed effects model
 Generalized linear mixed model
 Linear regression
 Mixeddesign analysis of variance
 Multilevel model
 Random effects model
 Repeated measures design
 Empirical Bayes method
References
 ↑ Baltagi, Badi H. (2008). Econometric Analysis of Panel Data (Fourth ed.). New York: Wiley. pp. 54–55. ISBN 9780470518861.
 ↑ ^{2.0} ^{2.1} Gomes, Dylan G.E. (20 January 2022). "Should I use fixed effects or random effects when I have fewer than five levels of a grouping factor in a mixedeffects model?". PeerJ 10: e12794. doi:10.7717/peerj.12794. PMID 35116198.
 ↑ Yang, Jian; Zaitlen, NA; Goddard, ME; Visscher, PM; Prince, AL (29 January 2014). "Advantages and pitfalls in the application of mixedmodel association methods". Nat Genet 46 (2): 100–106. doi:10.1038/ng.2876. PMID 24473328.
 ↑ ^{4.0} ^{4.1} Seltman, Howard (2016). Experimental Design and Analysis. 1. pp. 357–378. https://www.stat.cmu.edu/~hseltman/309/Book/.
 ↑ ^{5.0} ^{5.1} "Introduction to Linear Mixed Models". Advanced Research Computing Statistical Methods and Data Analytics. UCLA Statistical Consulting Group. 2021. https://stats.oarc.ucla.edu/other/multpkg/introductiontolinearmixedmodels/.
 ↑ ^{6.0} ^{6.1} Kreft & de Leeuw, J.. Introducing multilevel modeling. London:Sage.
 ↑ ^{7.0} ^{7.1} Raudenbush, Bryk, S.W, A.S (2002). Hierarchical Linear Models: Applications and Data Analysis Methods. Thousand Oaks, CA: Sage.
 ↑ ^{8.0} ^{8.1} Snijders, Bosker, T.A.B, R.J (2012). Multilevel analysis: An introduction to basic and advanced multilevel modeling. 2nd edition. London:Sage.
 ↑ Fisher, RA (1918). "The correlation between relatives on the supposition of Mendelian inheritance". Transactions of the Royal Society of Edinburgh 52 (2): 399–433. doi:10.1017/S0080456800012163. https://zenodo.org/record/1428666.
 ↑ ^{10.0} ^{10.1} Robinson, G.K. (1991). "That BLUP is a Good Thing: The Estimation of Random Effects". Statistical Science 6 (1): 15–32. doi:10.1214/ss/1177011926.
 ↑ C. R. Henderson; Oscar Kempthorne; S. R. Searle; C. M. von Krosigk (1959). "The Estimation of Environmental and Genetic Trends from Records Subject to Culling". Biometrics (International Biometric Society) 15 (2): 192–218. doi:10.2307/2527669.
 ↑ ^{12.0} ^{12.1} L. Dale Van Vleck. "Charles Roy Henderson, April 1, 1911 – March 14, 1989". United States National Academy of Sciences. http://books.nap.edu/html/biomems/chenderson.pdf.
 ↑ McLean, Robert A.; Sanders, William L.; Stroup, Walter W. (1991). "A Unified Approach to Mixed Linear Models". The American Statistician (American Statistical Association) 45 (1): 54–64. doi:10.2307/2685241.
 ↑ Anderson, R.J (2016). ""MLB analytics guru who could be the next Nate Silver has a revolutionary new stat"". http://www.cbssports.com/mlb/news/mlbanalyticsguruwhocouldbethenextnatesilverhasarevolutionarynewstat/.
 ↑ Obenchain, Lilly, Bob, Eli (1993). "Data Analysis and Information Visualization". MWSUG. https://www.lexjansen.com/mwsug/1993/MWSUG93035.pdf.
 ↑ Chen, H; Wang, C; Conomos, MP; Stilp, AM; Li, Z; Sofer, T; Szpiro, AA; Chen, W et al. (7 April 2016). "Control for Population Structure and Relatedness for Binary Traits in Genetic Association Studies via Logistic Mixed Models". Am J Hum Genet 98 (4): 653–666. doi:10.1016/j.ajhg.2016.02.012. PMID 27018471.
 ↑ Henderson, C R (1973). "Sire evaluation and genetic trends". Journal of Animal Science (American Society of Animal Science) 1973: 10–41. doi:10.1093/ansci/1973.Symposium.10. http://www.journalofanimalscience.org/content/1973/Symposium/10.full.pdf. Retrieved 17 August 2014.
 ↑ Lindstrom, ML; Bates, DM (1988). "Newton–Raphson and EM algorithms for linear mixedeffects models for repeatedmeasures data". Journal of the American Statistical Association 83 (404): 1014–1021. doi:10.1080/01621459.1988.10478693.
 ↑ Laird, Nan M.; Ware, James H. (1982). "RandomEffects Models for Longitudinal Data". Biometrics (International Biometric Society) 38 (4): 963–974. doi:10.2307/2529876. PMID 7168798.
 ↑ Fitzmaurice, Garrett M.; Laird, Nan M.; Ware, James H. (2004). Applied Longitudinal Analysis. John Wiley & Sons. pp. 326–328.
 ↑ Pinheiro, J; Bates, DM (2006). Mixedeffects models in S and SPLUS. Statistics and Computing. New York: Springer Science & Business Media. doi:10.1007/b98882. ISBN 0387989579.
 ↑ Bates, D.; Maechler, M.; Bolker, B.; Walker, S. (2015). "Fitting Linear MixedEffects Models Using lme4". Journal of Statistical Software 67 (1). doi:10.18637/jss.v067.i01.
Further reading
 Gałecki, Andrzej; Burzykowski, Tomasz (2013). Linear MixedEffects Models Using R: A StepbyStep Approach. New York: Springer. ISBN 9781461439004.
 Milliken, G. A.; Johnson, D. E. (1992). Analysis of Messy Data: Vol. I. Designed Experiments. New York: Chapman & Hall.
 West, B. T.; Welch, K. B.; Galecki, A. T. (2007). Linear Mixed Models: A Practical Guide Using Statistical Software. New York: Chapman & Hall/CRC.
Original source: https://en.wikipedia.org/wiki/Mixed model.
Read more 