I want to run a linear mixed effects model with nested and random effects using lmer in R, but continue getting errors. Two questions: what is causing the errors and how can I fix my model to run the appropriate analyses? Thanks so much!

**Experimental design:** Four sites- each site has 2 plant species and 3 accessions for each plant species (6 accessions total). At each site, there are two treatments: plants given nitrogen enriched fertilizer and plants given nitrogen free fertilizer. I collected data on plant growth and root traits and log-transformed variables as needed. I also set Accession (coded 1 – 6), Site (coded 1 – 4), and SoilN treatment (coded 1 and 2) as factors. All response variables are continuous.

**Data structure:**

**Model:** I want to test the effects of treatment (SoilN), Species, and Accession on plant growth and root traits. I have been running two models- one for species and one for accession. I would like to test an interaction between species or accession and soil N, include site as a random effect, and nest accession within species. I wrote the following models:

`lf <- lmer(LogLeaf ~ SoilN * Species + (1|Species/Accession) + (1|Site), data=a) lf2 <- lmer(LogLeaf ~ SoilN * Accession + (1|Species/Accession) + (1|Site), data=a) `

**Output:**

For the accession model (lf2), I get the following warnings:

`> lf2 <- lmer(LogLeaf ~ SoilN * Accession + (1|Species/Accession) + (1|Site), data = a) Warning messages: 1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : unable to evaluate scaled gradient 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge: degenerate Hessian with 1 negative eigenvalues > summary(lf2) Error in calculation of the Satterthwaite's approximation. The output of lme4 package is returned summary from lme4 is returned some computational error has occurred in lmerTest > anova(lf2) Error in calculation of the Satterthwaite's approximation. The output of lme4 package is returned anova from lme4 is returned some computational error has occurred in lmerTest Analysis of Variance Table Df Sum Sq Mean Sq F value SoilN 1 13.4357 13.4357 121.8414 Accession 5 0.3728 0.0746 0.6761 SoilN:Accession 5 0.8892 0.1778 1.6127 Warning messages: 1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : unable to evaluate scaled gradient 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge: degenerate Hessian with 1 negative eigenvalues `

**Other notes:**

- The model runs if I nest
`Accession`

within`Species`

within`Site`

, although I'm not sure that's a correct way to analyze the data. - It also runs if I don't nest
`Accession`

within`Species`

, but still include`Site`

and`Accession`

as random effects. - I do have some zeros in my data set because some of the plant died. I added data to determine whether the zeros were causing the issue, but continued to get errors.

**Contents**hide

#### Best Answer

Please read the R GLMM FAQ: http://glmm.wikidot.com/faq especially the section on "should I treat factor xxx as fixed or random?" or the email thread: https://stat.ethz.ch/pipermail/r-sig-mixed-models/2010q2/003710.html

If I understand your data correctly, you have only 2 species, so estimating a random variance for species is problematic at best. You have 6 total accessions (3+3), which is about the minimum for 1 variance component.

### Similar Posts:

- Solved – difference in results of mixed effects model in nlme and lme4 package
- Solved – After trying various optimzers, model simplification running more iterations, when fitting GLMMs, R still produces warning messages
- Solved – After trying various optimzers, model simplification running more iterations, when fitting GLMMs, R still produces warning messages
- Solved – Lmer failue to converge in random slope linear mixed model
- Solved – Problem fitting glmer model with factor and numeric predictors