Questions tagged [lme4-nlme]

lme4 and nlme are R packages used for fitting linear, generalized linear and nonlinear mixed effects models. For general questions about mixed models use [mixed-model] tag.

lme4 and nlme are R packages used for fitting linear, generalized linear and nonlinear mixed-effects models. For further information check Bates (June 25, 2010), Bates et al (2014), and Pinheiro and Bates (2000).

For questions asking about mixed effects models in general please use tag.


Bates, D. (June 25, 2010). lme4: Mixed-effects modeling with R. (unpublished)

Bates, D., Mächler, M., Bolker, B., & Walker, S. (2014). Fitting linear mixed-effects models using lme4. arXiv preprint arXiv:1406.5823.

Pinheiro, J.C., and Bates, D.M. (2000). Mixed-Effects Models in S and S-PLUS. Springer.

2903 questions
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.…
107
votes
4 answers

What is rank deficiency, and how to deal with it?

Fitting a logistic regression using lme4 ends with Error in mer_finalize(ans) : Downdated X'X is not positive definite. A likely cause of this error is apparently rank deficiency. What is rank deficiency, and how should I address it?
Jack Tanner
  • 4,552
  • 3
  • 27
  • 39
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
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
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
42
votes
2 answers

How can I test whether a random effect is significant?

I am trying to understand when to use a random effect and when it is unnecessary. Ive been told a rule of thumb is if you have 4 or more groups/individuals which I do (15 individual moose). Some of those moose were experimented on 2 or 3 times for…
Kerry
  • 1,129
  • 3
  • 14
  • 20
42
votes
2 answers

How trustworthy are the confidence intervals for lmer objects through effects package?

Effects package provides a very fast and convenient way for plotting linear mixed effect model results obtained through lme4 package. The effect function calculates confidence intervals (CIs) very quickly, but how trustworthy are these confidence…
Mikko
  • 1,172
  • 2
  • 19
  • 31
41
votes
2 answers

Mixed Effects Model with Nesting

I have data collected from an experiment organized as follows: Two sites, each with 30 trees. 15 are treated, 15 are control at each site. From each tree, we sample three pieces of the stem, and three pieces of the roots, so 6 level 1 samples per…
Erik
  • 455
  • 1
  • 6
  • 6
39
votes
3 answers

What is compound symmetry in plain english?

I recently realized that a mixed-model with only subject as a random factor and the other factors as fixed factors is equivalent to an ANOVA when setting the correlational structure of the mixed model to compound symmetry. Therefore I would like to…
Henrik
  • 13,314
  • 9
  • 63
  • 123
38
votes
1 answer

Why does glmer not achieve the maximum likelihood (as verified by applying further generic optimization)?

Numerically deriving the MLEs of GLMM is difficult and, in practice, I know, we should not use brute force optimization (e.g., using optim in a simple way). But for my own educational purpose, I want to try it to make sure I correctly understand the…
quibble
  • 1,167
  • 10
  • 17
1
2 3
99 100