r - r.squaredGLMM() 错误

标签 r lme4

我正在构建 GLMM(使用“lme4”R 包的 glmer()),有时在估计 R2 值时会出错(使用“MuMIn”包中的 r.squaredGLMM())。

我尝试拟合的模型与这个相似:

library(lme4)
lmA <- glmer(x~y+(1|w)+(1|w/k), data = data1, family = binomial(link="logit"))

然后,为了估计 R2,我使用:

library(MuMIn)
r.squaredGLMM(lmA)

我明白了:

 The result is correct only if all data used by the model has not changed since model was fitted. Error in .rsqGLMM(fam = family(x),
 varFx = var(fxpred), varRe = varRe,  :    'names' attribute [2] must be the same length as the vector [0]

你知道为什么会出现这个错误吗?例如,如果我只使用一个随机因子(在本例中为 (1|w)),则不会出现此错误。

这是我的数据集:

data1 <- 
structure(list(w = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 
1L, 2L, 1L), .Label = c("CA", "CB"), class = "factor"), k = structure(c(4L, 
4L, 3L, 3L, 3L, 4L, 1L, 3L, 2L, 3L, 2L), .Label = c("CAF01-CAM01", 
"CAM01", "CBF01-CBM01", "CBM01"), class = "factor"), x = c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L), y = c(-0.034973549, 
0.671720643, 4.557044729, 5.347170897, 2.634240583, -0.555740207, 
4.118277809, 2.599825716, 0.95853864, 4.327804344, 0.057331718
)), .Names = c("w", "k", "x", "y"), class = "data.frame", row.names = c(NA, 
-11L))

有什么想法吗?

最佳答案

这是一个错误 fixed版本 >= 1.15.8(即将在 CRAN 上,目前在 R-Forge 上)。

关于r - r.squaredGLMM() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38163689/

相关文章:

r - 获取与值匹配的 data.table 列的索引

r - 使用 glmer 提取随机效应分量的标准偏差

r - 带有用户定义链接函数的 glmer 给出错误 : (maxstephalfit) PIRLS step-halvings failed to reduce deviance

R:将字符添加到字符串中的特定位置,正则表达式语法有问题

r - 与 R 中的日期模糊连接

r - 如何从 lme4 中仅提取公式的随机效应部分

lme4 - 如何处理公式中指定的随机效应项?

R:具有连续变量和分类变量的 GLMM 交互图 (lme4)

r - 将脚本与 .GlobalEnv : Source script that source scripts 分开

r - 如何将包含多个文件的 Shiny 应用程序转换为易于共享和可重现的 Shiny 示例?