【问题标题】:Nesting success (binomial glmm) in r在 r 中嵌套成功(二项式 glmm)
【发布时间】:2015-06-15 09:01:11
【问题描述】:

我在 R 中使用 glmer() 运行 GLMM:

glmer(survive ~ fyear + site + fyear * site.x + (1|fyear),
family = binomial(link = logexp(shaffer.sub$exposure)),
data = shaffer.sub)

根据巢是否成功,生存是 0 或 1。 Here你可以看到数据是什么样子的:

structure(list(id = structure(1:7, .Label = c("1", "2", "3", 
"4", "5", "6", "7"), class = "factor"), year.x = structure(c(1L, 
1L, 2L, 3L, 3L, 3L, 3L), .Label = c("1994", "1995", "1999"), class = "factor"), 
    survive = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 1L), .Label = c("0", 
    "1"), class = "factor"), fyear = structure(c(1L, 1L, 2L, 
    3L, 3L, 3L, 3L), .Label = c("1994", "1995", "1999"), class = "factor"), 
    site.x = structure(c(1L, 2L, 1L, 1L, 1L, 2L, 1L), .Label = c("N", 
    "S"), class = "factor")), .Names = c("id", "year.x", "survive", 
"fyear", "site.x"), row.names = c(NA, -7L), class = "data.frame")

但我收到此警告消息:

*Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.0299425 (tol = 0.001, component 12)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model is nearly unidentifiable: large eigenvalue ratio
 - Rescale variables?*

有人告诉我,我不应该在同一模型上使用相同的随机因子作为固定效应。

最后,我想要一个可以看到年份、站点和交互年份的输出:站点效果。就像在 ANOVA 表中一样(这可能吗?我一直在尝试使用 summary(aov(model)) 但这不起作用;anova(model) 也不行。

aov() 命令出现此错误:

*Error in summary`(aov(syearXsite))` : 
  error in evaluating the argument 'object' in selecting a method for function 'summary': Error in if (fixed.only) { : argument is not interpretable as logical*

如何查看这些变量对生存的影响?

【问题讨论】:

  • 感谢 alexforrence!

标签: r anova mixed-models


【解决方案1】:

告诉您不要使用分类输入变量 (fyear) 作为固定效应和随机效应的人是正确的。很难确切知道要推荐什么,这取决于您在数据集中拥有的年数和站点(是您链接到所有数据的数据(我希望不是),或者只是前几行?你有多少年、多少个站点和多少个总观测值?)

如果您想将年份视为随机并将站点视为固定(如果您只有两个站点(N 与 S 如您的数据所示)和相当长的几年,例如超过 5 个,这将是明智的) 那么你可以适应:

g1 <- glmer(survive~site.x+(site.x|fyear),
      family=binomial(link=logexp(shaffer.sub$exposure)),
      data=shaffer.sub)

我不知道 site 与 site.x 是什么:我只在您的数据 sn-p 中看到 site.x。

要获取信息,请尝试summary(g1)。 (这只会为您提供随机效应的方差,而不是固定效应;GLMM 不会以与 ANOVA 相同的“方差解释”模式运行,特别是因为不同术语解释的方差通常不会 em> 加起来就是总方差。)

【讨论】:

  • 您好,Ben,我有 11 年的时间和数百年的观察经验。我的数据集总共有 4742 个观测点和 2 个站点(北部和南部)。我也对作为固定效应的年份感兴趣。没错,它是site=site.x,它来自我链接输出生存时的输出。有没有办法从这个模型中得到年份、站点和交互年份*站点的效果?非常感谢!
  • 模型完美!但我想那是不可能获得互动 yearXsite 的。我理解的截距是年份(p-value=|z|)(截距)4.6105 0.5134 8.981
猜你喜欢
  • 2020-10-09
  • 1970-01-01
  • 2019-10-09
  • 1970-01-01
  • 2022-01-02
  • 2018-12-28
  • 2021-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多