0
$\begingroup$

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:

enter image description here

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:

enter image description here

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:

  1. 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.
  2. It also runs if I don't nest Accession within Species, but still include Site and Accession as random effects.
  3. 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.
$\endgroup$
  • $\begingroup$ You cannot have Species as both a fixed effect and a random effect. Try LogLeaf ~ SoilN * Species + (1|Site/Accession). $\endgroup$ – amoeba May 26 '17 at 15:14
  • $\begingroup$ But I also don't quite understand what "Accession" is. You said you want to test it -- so it should be a fixed factor probably, not a random one? What does "Accession" mean? Does it have 3 meaningful levels or 6? $\endgroup$ – amoeba May 26 '17 at 15:16
  • $\begingroup$ Wait, I googled it and it seems that "accession" is something like a subspecies. Then you can have LogLeaf ~ SoilN * Species + (1|Site) or LogLeaf ~ SoilN * Accession + (1|Site). Only Site is random. $\endgroup$ – amoeba May 26 '17 at 15:20
  • $\begingroup$ Working on this currently. First, just making everything is coded directly. A few questions: What are "accessions"? Are the same 2 species found at every single plot? Are the "accessions" within species unique to that species? $\endgroup$ – Mark White May 26 '17 at 15:31
  • $\begingroup$ @amoeba it isn't the case that a fixed effect can't also be random. An effect can be split into the fixed part (i.e., the average coefficient) and the random part (i.e., the variance around that average coefficient). The problem here is that OP is using a cluster variable also as an independent variable. We also want to make sure that the effect of accession and treatment differ by site, so I would specify this model: LogLeaf ~ SoilN * Accession + (1 + SoilN + Accession|Site) $\endgroup$ – Mark White May 26 '17 at 15:35
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.