A linear mixed-effects model is of the form
y is the n-by-1 response vector, and n is the number of observations.
X is an n-by-p fixed-effects design matrix.
β is a p-by-1 fixed-effects vector.
Z is an n-by-q random-effects design matrix.
b is a q-by-1 random-effects vector.
ε is the n-by-1 observation error vector.
The random-effects vector, b, and the error vector, ε, are assumed to have the following independent prior distributions:
In this model, the parameters to estimate are the fixed-effects coefficients β, and the variance components θ and σ2. The two most commonly used approaches to parameter estimation in linear mixed-effects models are maximum likelihood and restricted maximum likelihood methods.
The maximum likelihood estimation includes both regression coefficients and the variance components, that is, both fixed-effects and random-effects terms in the likelihood function.
For a linear mixed-effects model defined above, the conditional response of the response variable y given β, b, θ, and σ2 is
The likelihood of y given β, θ, and σ2 is
Suppose Λ(θ) is the lower triangular Cholesky factor of D(θ) and Δ(θ) is the inverse of Λ(θ). Then,
for given β and θ. Then, the likelihood function is
P(y|β,θ,σ2) is first maximized with respect to β and σ2 for a given θ. Thus the optimized solutions and are obtained as functions of θ. Substituting these solutions into the likelihood function produces . This expression is called a profiled likelihood where β and σ2 have been profiled out. is a function of θ, and the algorithm then optimizes it with respect to θ. Once it finds the optimal estimate of θ, the estimates of β and σ2 are given by and .
The ML method treats β as fixed but unknown quantities when the variance components are estimated, but does not take into account the degrees of freedom lost by estimating the fixed effects. This causes ML estimates to be biased with smaller variances. However, one advantage of ML over REML is that it is possible to compare two models in terms of their fixed- and random-effects terms. On the other hand, if you use REML to estimate the parameters, you can only compare two models, that are nested in their random-effects terms, with the same fixed-effects design.
Restricted maximum likelihood estimation includes only the variance components, that is, the parameters that parameterize the random-effects terms in the linear mixed-effects model. β is estimated in a second step. Assuming a uniform improper prior distribution for β and integrating the likelihood P(y|β,θ,σ2) with respect to β results in the restricted likelihood P(y|θ,σ2). That is,
REML accounts for the degrees of freedom lost by estimating the fixed effects, and makes a less biased estimation of random effects variances. The estimates of θ and σ2 are invariant to the value of β and less sensitive to outliers in the data compared to ML estimates. However, if you use REML to estimate the parameters, you can only compare two models that have the identical fixed-effects design matrices and are nested in their random-effects terms.
 Pinherio, J. C., and D. M. Bates. Mixed-Effects Models in S and S-PLUS. Statistics and Computing Series, Springer, 2004.
 Hariharan, S. and J. H. Rogers. “Estimation Procedures for Hierarchical Linear Models.” Multilevel Modeling of Educational Data (A. A. Connell and D. B. McCoach, eds.). Charlotte, NC: Information Age Publishing, Inc., 2008.
 Raudenbush, S. W. and A. S. Bryk. Hierarchical Linear Models: Applications and Data Analysis Methods, 2nd ed. Thousand Oaks, CA: Sage Publications, 2002.
 Hox, J. Multilevel Analysis, Techniques and Applications. Lawrence Erlbaum Associates, Inc, 2002.
 Snidjers, T. and R. Bosker. Multilevel Analysis. Thousand Oaks, CA: Sage Publications, 1999.
 McCulloch, C.E., R. S. Shayle, and J. M. Neuhaus. Generalized, Linear, and Mixed Models. Wiley, 2008.