# 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.

305 questions
Filter by
Sorted by
Tagged with
85k views

### 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 ...
47k views

### 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 ...
18k views

### Why do lme and aov return different results for repeated measures ANOVA in R?

I am trying to move from using the ez package to lme for repeated measures ANOVA (as I hope I will be able to use custom ...
156k views

### 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 ...
130k views

### 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 ...
15k views

### Comparing non nested models with AIC

Say we have to GLMMs mod1 <- glmer(y ~ x + A + (1|g), data = dat) mod2 <- glmer(y ~ x + B + (1|g), data = dat) These models are not nested in the usual ...
5k views

### What to do with random effects correlation that equals 1 or -1?

Not so uncommon occurrence when dealing with complex maximal mixed models (estimating all possible random effects for given data and model) is perfect (+1 or -1) or nearly perfect correlation among ...
17k views

### Why do I get zero variance of a random effect in my mixed model, despite some variation in the data?

We’ve run a mixed effects logistic regression using the following syntax; ...
52k views

### 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 ...
19k views

### Have I correctly specified my model in lmer?

I have scoured lots of help sites and am still confused about how to specify more complicated nested terms in a mixed model as well. I am also confused as the use of ...
19k views

### How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?

I have a repeated-measures experiment where the dependent variable is a percentage, and I have multiple factors as independent variables. I'd like to use glmer from ...
46k views

### 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 ...
7k views

### 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 "...
17k views

### Fitting a binomial GLMM (glmer) to a response variable that is a proportion or fraction

I'm hoping somebody can help with what I think is a relatively simple question, and I think I know the answer but without confirmation it has become something I just can't be certain of. I have some ...
76k views

### 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 ...
3k views

### Does it make sense for a fixed effect to be nested within a random one, or how to code repeated measures in R (aov and lmer)?

I have been looking through this overview of lm/lmer R formulas by @conjugateprior and got confused by the following entry: Now assume A is random, but B is fixed and B is nested within A. ...
8k views

### How to fit a mixed model with response variable between 0 and 1?

I am trying to use lme4::glmer() to fit a binomial generalized mixed model (GLMM) with dependent variable that is not binary, but a continuous variable between zero ...
5k views

### What is the lme4::lmer equivalent of a three-way repeated measures ANOVA?

My question is based on this response which showed which lme4::lmer model corresponds to a two-way repeated measures ANOVA: ...
10k views

### Interpreting the regression output from a mixed model when interactions between categorical variables are included

I have a question about my use of a mixed model/lmer. The basic model is this: lmer(DV ~ group * condition + (1|pptid), data= df) Group and condition are both ...
29k views

### Repeated measures ANOVA with lme/lmer in R for two within-subject factors

I'm trying to use lme from the nlme package to replicate results from aov for repeated ...
31k views

### REML or ML to compare two mixed effects models with differing fixed effects, but with the same random effect?

Background: Note: My dataset and r-code are included below text I wish to use AIC to compare two mixed effects models generated using the lme4 package in R. Each model has one fixed effect and one ...
8k views

### Calculating $R^2$ in mixed models using Nakagawa & Schielzeth's (2013) R2glmm method

I have been reading about calculating $R^2$ values in mixed models and after reading the R-sig FAQ, other posts on this forum (I would link a few but I don't have enough reputation) and several other ...
9k views

### Comparing mixed-effects and fixed-effects models (testing significance of random effects)

Given three variables, y and x, which are positive continuous, and z, which is categorical, ...
74k views

### 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 ...
40k views

### How to get an “overall” p-value and effect size for a categorical factor in a mixed model (lme4)?

I would like to get a p-value and an effect size of an independent categorical variable (with several levels) -- that is "overall" and not for each level separately, as is the normal output from ...
18k views

### Example reports for mixed-model analysis using lmer in biology, psychology and medicine?

As the general consensus seems to be to use mixed-models via lmer() in R instead of classical ANOVA (for the often cited reasons, like unbalanced designs, crossed ...
24k views

### Sample size calculation for mixed models

I am wondering if there are any methods for calculating sample size in mixed models? I'm using lmer in R to fit the models (I have random slopes and intercepts).
15k views

### How do I fit a multilevel model for over-dispersed poisson outcomes?

I want to fit a multilevel GLMM with a Poisson distribution (with over-dispersion) using R. At the moment I am using lme4 but I noticed that recently the ...
26k views

### How do I interpret the 'correlations of fixed effects' in my glmer output?

I have the following output: ...
2k views

### Equivalence between a repeated measures anova model and a mixed model: lmer vs lme, and compound symmetry

I have some trouble obtaining equivalent results between an aov between-within repeated measures model and an lmer mixed model. ...
9k views

### Random effect equal to 0 in generalized linear mixed model [duplicate]

Sorry if I'm missing something very obvious here but I am new to mixed effect modelling. I am trying to model a binomial presence/absence response as a function of percentages of habitat within the ...
34k views

### Dealing with singular fit in mixed models

Let's say we have a model ...
1k views

### Equivalent to Welch's t-test in GLS framework

How can Welch's t-test be expressed as a generalized least squares model? A standard independent samples t-test (where it is assumed that the samples being compared are drawn from populations with ...
2k views

### How can I test for differences in variation between groups in a mixed model (lme4)?

I would like to test for differences in variation, not in means, between two sites. By looking at a boxplot of my data I see that bird song in one site look much more variable in length than in ...
13k views

### Formula symbols for mixed model using lme4 [duplicate]

I often confuse symbols :, |, / and * in the ...
8k views

### Intraclass correlation (ICC) for an interaction?

Suppose I have some measurement for each subject at each site. Two variables, subject and site, are of interest in terms of computing intraclass correlation (ICC) values. Typically I would use ...
18k views

### How to assess the fit of a binomial GLMM fitted with lme4 (> 1.0)?

I have a GLMM with a binomial distribution and a logit link function and I have the feeling that an important aspect of the data is not well represented in the model. To test this, I would like to ...
11k views

### Understanding the variance of random effects in lmer() models

I'm having trouble understanding the output of my lmer() model. It is a simple model of an outcome variable (Support) with varying State intercepts / State random ...
27k views

### 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 ...
9k views

### Can AIC compare across different types of model?

I'm using AIC (Akaike's Information Criterion) to compare non-linear models in R. Is it valid to compare the AICs of different types of model? Specifically, I'm comparing a model fitted by glm versus ...
638 views

### Equivalence of (0 + factor|group) and (1|group) + (1|group:factor) random effect specifications in case of compound symmetry

Douglas Bates states that the following models are equivalent "if the variance-covariance matrix for the vector-valued random effects has a special form, called compound symmetry" (slide 91 in this ...
52k views

### 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. ...
15k views

### Unbalanced mixed effect ANOVA for repeated measures

I have data from patients treated with 2 different kinds of treatments during surgery. I need to analyze its effect on heart rate. The heart rate measurement is taken every 15 minutes. Given that ...
45k views

### “Model failed to converge” warning in lmer()

With the following dataset, I wanted to see if the response (effect) changes with regard to sites, season, duration, and their interactions. Some online forums on statistics suggested me to go on with ...
12k views

### Paired t-test as a special case of linear mixed-effect modeling

We know that a paired t-test is just a special case of one-way repeated-measures (or within-subject) ANOVA as well as linear mixed-effect model, which can be demonstrated with lme() function the nlme ...
11k views

### REML vs ML stepAIC

I feel overwhelmed after attempting to dig into the literature on how to run my mixed model analysis following it up with using AIC to select the best model or models. I do not think my data is that ...
10k views

### Are degrees of freedom in lmerTest::anova correct? They are very different from RM-ANOVA

I am analyzing the results of a reaction time experiment in R. I ran a repeated measures ANOVA (1 within-subject factor with 2 levels and 1 between-subject factor with 2 levels). I ran a similar ...
5k views

### Questions about specifying linear mixed models in R for repeated measures data with additional nesting structure

Data Structure ...