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
withinSpecies
withinSite
, although I'm not sure that's a correct way to analyze the data. - It also runs if I don't nest
Accession
withinSpecies
, but still includeSite
andAccession
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.
Species
as both a fixed effect and a random effect. TryLogLeaf ~ SoilN * Species + (1|Site/Accession)
. $\endgroup$LogLeaf ~ SoilN * Species + (1|Site)
orLogLeaf ~ SoilN * Accession + (1|Site)
. Only Site is random. $\endgroup$LogLeaf ~ SoilN * Accession + (1 + SoilN + Accession|Site)
$\endgroup$