我想使用R中的lmer运行具有嵌套和随机效果的线性混合效果模型,但是继续得到错误。两个问题:导致错误的原因以及如何修复模型以运行适当的分析?非常感谢!
实验设计:四个站点 - 每个站点有2种植物物种,每种植物物种有3种(总共6种)。加入基本上是植物种群,它们是特定植物物种所特有的。在每个地点,有两种处理:给予富氮肥料的植物和给予无氮肥料的植物。所有物种和所有种质都存在于每个地点。我根据需要收集了有关植物生长和根性状以及对数转换变量的数据。我还将登录(编码1 - 6),站点(编码1 - 4)和SoilN处理(编码1和2)设置为因子。所有响应变量都是连续的。
数据结构:
Species Accession ID Site SoilN LeafNo LogLeaf Height NodNo SBMg
1 MESA 4 250975.1 1 1 15 1.178977 18.1 3 0.0876
2 MESA 4 250975.4 1 1 12 1.082785 18.6 3 0.0896
3 MESA 4 250975.4 1 1 20 1.303196 22.4 20 0.1395
4 MESA 4 250975.5 1 1 8 0.908485 18.4 2 0.0727
5 MESA 4 250975.2 1 2 57 1.756636 33.5 23 0.5665
6 MESA 4 250975.2 1 2 60 1.778874 44.8 61 0.5394
模型:我想测试处理(SoilN),种类和加入对植物生长和根系性状的影响。我一直在运行两个模型 - 一个用于物种,一个用于加入。我想测试物种或种质与土壤N之间的相互作用,包括作为随机效应的位点,以及物种内的巢穴加入。我写了以下模型:
lf <- lmer(LogLeaf ~ SoilN * Species + (1|Species/Accession) + (1|Site), data=a)
lf2 <- lmer(LogLeaf ~ SoilN * Accession + (1|Species/Accession) + (1|Site), data=a)
输出:
lf <- lmer(LogLeaf ~ SoilN * Species + (1|Species/Accession) + (1|Site),
data = a)
Warning message:
In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?`
summary(lf)
Linear mixed model fit by REML
t-tests use Satterthwaite approximations to degrees of freedom
['lmerMod']
Formula: LogLeaf ~ SoilN * Species + (1 | Species/Accession) + (1 |
Site)
Data: a
REML criterion at convergence: 109.5
Scaled residuals:
Min 1Q Median 3Q Max
-4.9162 -0.2557 0.1309 0.5600 1.5150
Random effects:
Groups Name Variance Std.Dev.
Accession:Species (Intercept) 0.004266 0.06531
Site (Intercept) 0.046332 0.21525
Species (Intercept) 0.038957 0.19738
Residual 0.109152 0.33038
Number of obs: 140, groups: Accession:Species, 6; Site, 4; Species, 2
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 0.90231 0.23405 0.00000 3.855 1.0000
SoilN2 0.73319 0.07247 129.76000 10.117 <2e-16 ***
SpeciesTRPR -0.45583 0.29753 0.00000 -1.532 1.0000
SoilN2:SpeciesTRPR -0.26846 0.11621 132.12000 -2.310 0.0224 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) SoilN2 SpTRPR
SoilN2 -0.166
SpeciesTRPR -0.619 0.128
SlN2:SpTRPR 0.102 -0.620 -0.223
convergence code: 0
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?
anova(lf)
Analysis of Variance Table of type III with Satterthwaite
approximation for degrees of freedom
Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
SoilN 11.5037 11.5037 1 132.11 105.392 < 2e-16 ***
Species 0.4513 0.4513 1 0.00 4.135 0.99998
SoilN:Species 0.5825 0.5825 1 132.12 5.337 0.02243 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Warning message:
In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?`
对于加入模型(lf2),我收到以下警告:
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
其他说明:
如果我在站点内的物种中嵌入Accession,模型会运行,但我不确定这是分析数据的正确方法。
如果我没有在物种中嵌入Accession,但仍然包含Site和Accession作为随机效果,它也会运行。
我的数据集中确实有一些零,因为有些植物死了。我添加了数据以确定零是否导致问题,但仍然出现错误。