lmer模型中的无效分组因子规范 [英] invalid grouping factor specification in lmer model
问题描述
我正在尝试使用lmer函数运行混合效果模型.我的实验包括使用某些相同的个体在不同温度下的代谢率(一些缺失的数据).文本文件的结构如下所示:
I am attempting to run a mixed effects model using the lmer function. My experiment included metabolic rates at different temperatures using some of the same individuals (some missing data). The structure of the textfile looks like this:
> str(data.by.animal)
'data.frame': 18 obs. of 17 variables:
$ animal: Factor w/ 18 levels "08_03","08_07",..: 17 6 5 10 15 14 11 12 16 9 ...
$ temp : int 2 0 -2 -4 -6 -8 -10 -12 -14 -16 ...
$ X2 : num 0.0129 0.0176 0.0132 NA 0.0144 0.0133 0.0101
当我运行脚本[model_1 <- lmer(X2 + X0 + X.2 + X.4 + X.6 + X.8 + X.10 + X.12 + X.14 + X.16 + X.18 + X.20 + X.22 + X.24 + X.26 ~ temp + (1 | animal), data.by.animal)]
时,我得到以下信息:[Error in FUN(X[[1L]], ...) : Invalid grouping factor specification, animal]
尽管咨询了"R书"和此处的其他答案,但我仍然对哪里出了问题感到迷茫.
When I run the script [model_1 <- lmer(X2 + X0 + X.2 + X.4 + X.6 + X.8 + X.10 + X.12 + X.14 + X.16 + X.18 + X.20 + X.22 + X.24 + X.26 ~ temp + (1 | animal), data.by.animal)]
I get the following: [Error in FUN(X[[1L]], ...) : Invalid grouping factor specification, animal]
and despite consulting "The R Book" and other answers here, I'm still at a loss as to where I'm going wrong.
推荐答案
在使用lmer时,我也遇到了此问题.当我检查数据时,我发现几个变量的值为NA(由重新缩放产生).排除这些变量后,问题得以解决.
I also encountered with this problem when using lmer. When I check my data, I found values of several variables were NA (resulted from rescaling). After excluding those variables, the problem was solved.
这篇关于lmer模型中的无效分组因子规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!