事后自定义对比-带poly()的glmmTMB

时间:2018-10-30 14:39:17

标签: r mixed-models posthoc

我需要弄清楚如何为具有多项式预测变量的glmmTMB模型运行一组自定义对比。我遵循了允许glhtglmmTMB模型一起使用的答案given here,但是我仍然失败了,似乎在两个阶段: 1)如何定义多项式预测变量的对比?我需要使用list()方法,因为我的实际模型非常复杂,并且我肯定会搞砸matrix方法 2)设置对比后-如何专门为glmmTMB运行对比?

library(contrast)
library(glmmTMB)

set.seed(1)
df <- structure(list(x = 1:20, y = c(4L, 7L, 11L, 12L, 23L, 21L, 42L, 
56L, 70L, 80L, 95L, 120L, 152L, 187L, 224L, 280L, 326L, 374L, 
438L, 500L), z = structure(c(2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 
1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L), .Label = c("a", 
"b"), class = "factor"), group = structure(c(1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
), class = "factor", .Label = "1")), class = "data.frame", row.names = c(NA, 
-20L))

#just a toy example with a linear model and no poly()
m <- lm(y ~ x * z, data = df)
contrast(m, 
        a = list(x = 1, z = "a"),
        b = list(x = 10, z = "b"))

# a (big) simplification of what I'm after:
m1 <- glmmTMB(y ~ poly(x, 3) * z + (1|group), data = df, family = poisson)
contrast(m1, 
        a = list(x = 1, z = "a"),
        b = list(x = 10, z = "b"))

编辑 另外,由于我的实际模型是零膨胀的,因此这种方法如何处理呢?我只对测试“响应”值(即零通货膨胀和计数组合)感兴趣。

0 个答案:

没有答案
相关问题