Introduction to Linear Mixed Model

Author: Anoop JoseClinical SAS Programmer at Genpro Research

In clinical trials, usually, we take multiple measurements from a subject at different time points. In the case of repeated measures or longitudinal data, multiple observations are collected from the same subject. The individual is a cluster in which multiple observations are grouped. Observations from the same cluster are like each other rather than the observations from different clusters. The linear regression model cannot be applied in this situation, because it assumes that the observations are independent. What is an alternative when the independent assumption is violated?

Linear Mixed Model or Linear Mixed Effect Model (LMM) is an extension of the simple linear models to allow both fixed and random effects and is a method for analysing data that are non-independent, multilevel/hierarchical, longitudinal, or correlated. Mixed-effects models are statistical models used to describe relations between a response variable and some covariates in data that are grouped according to one or more classification factors. Linear models may contain fixed effects (parameters associated with an entire population or with certain repeatable levels of experimental factors), and random effects (which are correlated with individual units drawn at random from a population). A linear model that incorporates both fixed and random effects is called a mixed-effects model.

There are multiple ways to deal with hierarchical data. One such method is to aggregate data analysis which yields consistent effect estimates and standard errors. Another approach is analysing data from one unit at a time, i.e. fitting regression models. It yields many models, and one doesn’t take advantage of the information from other groups. But in both the above approaches, as the estimates from each model are not based on data very much, the accuracy is reduced. In contrast, the focus of mixed models is that they incorporate fixed and random effects. While fixed effects estimates give information about the relationship between a set of independent variables and the response, random effects are used in modeling the random variation in the dependent variable at different levels, clusters or subjects within a population.

Fixed effect model 

Fixed effect model is also known as covariance model, within the estimator model, least square dummy variable model, and individual dummy variable model. In a fixed effect model, model parameters are fixed or non-random quantities. Fixed effect model refers to regression models in which the group means are fixed (non-random) as opposed to a random effect model. Fixed effects are variables that are constant across individuals that are variables like age, gender, ethnicity those change at a constant rate over time. Fixed effect models are designed to study the causes of changes with a person. Fixed variables are assumed to be measured without measurement error and are used in a study that contains all or most of the variable’s values in the population (example: gender, race, age…).


Where ϵ~N(0, 𝜎2I)

Y= observed values

𝜶 = fixed effects

X= Matrix of predictor variable

Random effect model

In statistics, a random effect model is also called variants component model and is a statistical model with model parameters are random variables. It is a kind of hierarchical linear model which assumes that data being analysed are drawn from a hierarchy of different population whose difference relates to that hierarchy. This is opposite to fixed effect model i.e. the variables are random and unpredictable.

Random effect models are different statistical models of regression and ANOVA which assume that an independent variable is random. In general, it is used if the levels of the independent variable are thought to be a small subset of the possible values which one wishes to generalize and will probably produce larger standard errors.  Random effect models take into account the difference between individual effects i.e. if the effect across the studies are heterogeneous then the random effect models are used because which include random term within the model.

The logic behind the random effect model is that unlike the fixed effect model the variation across entities is assumed to be random and independent with the predictor or independent variable included in the model.


Y=Zβ+ ϵ

Y is the column vector of a response variable,

Z is the design matrix for the random effects

ϵ is the error term which is normally distributed with mean zero and variance σ2, β is the parameter of the model which is random.

For example, we could say that β is distributed as a random normal variate with mean μ and dispersion matrix σ2I, or in equation form: β∼N (μ,σ2I).σ2I, or i

Linear mixed models

The mixed model extends the fixed effects model by including random effects, random coefficients and/or covariance terms in the residual variance matrix. In this section, the general notation will be given, and in the following three sections, the specific forms of the covariance matrices for each type of mixed model will be specified.

Extending our fixed effects model to incorporate random effects (or coefficients), the mixed model may be specified as

For a model fitting, p fixed effects parameters and q random effects (or coefficients) parameters, where random effects are assumed to follow a distribution, whereas fixed effects are regarded as fixed constants. The model can be expressed in matrix notation as.

Where Y is an n×1 column vector, the outcome variable; X is a n×p matrix of the P predictor variables;  is a p×1 column vector of the fixed-effects regression coefficients (the s); Z is the n×q design matrix for the q random effects (the random compliment to the fixed X); β is a q×1 vector of the random effects (the random compliment to the fixed ); and ϵ is an n×1 column vector of the residuals, that part of Y that is not explained by the model .

Assumptions of linear mixed model:

The explanatory variables are related linearly to the response.

  • The errors have constant variance.
  • The errors are independent.
  • The errors are normally distributed.

Wish to know more about Linear Mixed Model ?, Don’t worry we will get into it in detail in the upcoming blogs. Meanwhile, feel free to share your thoughts on this blog by emailing us at

Leave a Reply

Your email address will not be published. Required fields are marked *