Questions tagged [mixed-model]

Mixed (aka multilevel or hierarchical) models are linear models that include both fixed effects and random effects. They are used to model longitudinal or nested data.

Overview

Mixed models are linear models that include both fixed effects and random effects*. They are used to model longitudinal or nested data; such data do not have independent errors and mixed models can account for the arising correlations. Mixed models are also known as multilevel or hierarchical linear models.

A classic example is the estimation of test scores of students: if test scores are correlated within classes, schools, districts, etc., mixed models allow the modeler to simultaneously estimate the differences between individual students and between the groups to which they belong (with the possibility of including covariates at all levels).

In a mixed model, study units are thought of as sampled from a population; the fixed effects are estimates of the population average effect, whereas the random effects are specific to the study units. In matrix form, a mixed effects model might be: $$ \bf Y=X\boldsymbol\beta + Zb + \boldsymbol\varepsilon $$ where $\bf X$ is the design matrix, $\boldsymbol\beta$ is a vector of the population average effects, $\bf Z$ is a subset of the columns of $\bf X$, $\bf b$ is a vector of the unit specific deviations from the population effects, and $\boldsymbol \varepsilon$ is a vector of random errors.

* Note that here we follow terminology used in statistics, social sciences, and biostatistics; similar terminology ("fixed effects", "random effects") is also used in econometrics, but the meaning is different.

References

StatsExchangers often recommend the following resources for learning more about mixed models:

Software packages

Mixed models are available in the following statistical packages:

  • lme4 and nlme for R
  • PROC MIXED and GLIMMIX for SAS
  • MLwiN
  • xtreg, xtmixed, xtlogit, xtmelogit, xtmepoisson, and other xt* commands; user-contributed package GLLAMM for Stata
  • Mplus
  • HLM
5314 questions
372
votes
9 answers

What is the difference between fixed effect, random effect and mixed effect models?

In simple terms, how would you explain (perhaps with simple examples) the difference between fixed effect, random effect and mixed effect models?
Andrew
  • 5,478
  • 5
  • 21
  • 21
197
votes
3 answers

R's lmer cheat sheet

There's a lot of discussion going on on this forum about the proper way to specify various hierarchical models using lmer. I thought it would be great to have all the information in one place. A couple of questions to start: How to specify multiple…
149
votes
1 answer

Crossed vs nested random effects: how do they differ and how are they specified correctly in lme4?

Here is how I have understood nested vs. crossed random effects: Nested random effects occur when a lower level factor appears only within a particular level of an upper level factor. For example, pupils within classes at a fixed point in time.…
102
votes
2 answers

How scared should we be about convergence warnings in lme4

If we a re fitting a glmer we may get a warning that tells us the model is finding a hard time to converge...e.g. >Warning message: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| =…
user1322296
  • 1,485
  • 3
  • 12
  • 16
95
votes
4 answers

How to choose nlme or lme4 R library for mixed effects models?

I have fit a few mixed effects models (particularly longitudinal models) using lme4 in R but would like to really master the models and the code that goes with them. However, before diving in with both feet (and buying some books) I want to be sure…
Chris Beeley
  • 5,465
  • 5
  • 36
  • 40
87
votes
3 answers

What is "restricted maximum likelihood" and when should it be used?

I have read in the abstract of this paper that: "The maximum likelihood (ML) procedure of Hartley aud Rao is modified by adapting a transformation from Patterson and Thompson which partitions the likelihood render normality into two parts, one…
Joe King
  • 3,024
  • 6
  • 32
  • 58
81
votes
11 answers

How to obtain the p-value (check significance) of an effect in a lme4 mixed model?

I use lme4 in R to fit the mixed model lmer(value~status+(1|experiment))) where value is continuous, status and experiment are factors, and I get Linear mixed model fit by REML Formula: value ~ status + (1 | experiment) AIC BIC logLik…
ECII
  • 1,791
  • 2
  • 17
  • 25
78
votes
3 answers

When to use generalized estimating equations vs. mixed effects models?

I have been quite happily using mixed effects models for a while now with longitudinal data. I wish I could fit AR relationships in lmer (I think I'm right that I can't do this?) but I don't think it's desperately important so I don't worry too…
Chris Beeley
  • 5,465
  • 5
  • 36
  • 40
74
votes
5 answers

Unified view on shrinkage: what is the relation (if any) between Stein's paradox, ridge regression, and random effects in mixed models?

Consider the following three phenomena. Stein's paradox: given some data from multivariate normal distribution in $\mathbb R^n, \: n\ge 3$, sample mean is not a very good estimator of the true mean. One can obtain an estimation with lower mean…
amoeba
  • 93,463
  • 28
  • 275
  • 317
62
votes
3 answers

Questions about how random effects are specified in lmer

I recently measured how the meaning of a new word is acquired over repeated exposures (practice: day 1 to day 10) by measuring ERPs (EEGs) when the word was viewed in different contexts. I also controlled properties of the context, for instance, its…
alwin hoff
  • 621
  • 1
  • 6
  • 3
61
votes
5 answers

How exactly does a "random effects model" in econometrics relate to mixed models outside of econometrics?

I used to think that "random effects model" in econometrics corresponds to a "mixed model with random intercept" outside of econometrics, but now I am not sure. Does it? Econometrics uses terms like "fixed effects" and "random effects" somewhat…
amoeba
  • 93,463
  • 28
  • 275
  • 317
55
votes
2 answers

Prediction interval for lmer() mixed effects model in R

I want to get a prediction interval around a prediction from a lmer() model. I have found some discussion about this: http://rstudio-pubs-static.s3.amazonaws.com/24365_2803ab8299934e888a60e7b16113f619.html http://glmm.wikidot.com/faq but they seem…
hossibley
  • 797
  • 2
  • 8
  • 10
52
votes
2 answers

Using lmer for repeated-measures linear mixed-effect model

EDIT 2: I originally thought I needed to run a two-factor ANOVA with repeated measures on one factor, but I now think a linear mixed-effect model will work better for my data. I think I nearly know what needs to happen, but am still confused by few…
phosphorelated
  • 743
  • 2
  • 7
  • 9
46
votes
1 answer

Negative values for AIC in General Mixed Model

I'm trying to select the best model by the AIC in the General Mixed Model test. The best model is the model with the lowest AIC, but all my AIC's are negative! So is the biggest negative AIC the lowest value? Or is the smallest negative AIC the…
43
votes
5 answers

Negative values for AICc (corrected Akaike Information Criterion)

I have calculated AIC and AICc to compare two general linear mixed models; The AICs are positive with model 1 having a lower AIC than model 2. However, the values for AICc are both negative (model 1 is still < model 2). Is it valid to use and…
Freya Harrison
  • 3,212
  • 4
  • 25
  • 31
1
2 3
99 100