运行glm的posthoc分析时出错

问题描述 投票:1回答:1

我正在尝试对我的治疗进行posthoc比较,但是在运行glht时我一直收到这个错误:“modelparm.default(model,...)中的错误:系数和协方差矩阵的维度不匹配”。

有没有更好的方法进行多个成对比较?我也尝试过使用emmeans我不确定这是不是正确的方法。

这是我数据的一个子集:

mydata <- read.table(header=TRUE, text="
treatment    total.bites   hours   rep
                     A  10  3.1  a1
                     A  1   3.2  a2
                     A  1024   3.22 a3
                     B  0   3.13 a1
                     B  16  3.15 a2
                     B  1305  3.24 a3
                     C  0   3.13 a1
                     C  0  3.26 a2
                     C  0   3.11 a3
                     D  2  3.25 a1
                     D  0   3.17 a2 
                     D  3   3.21 a3
                     ")
mC4 <- glmmTMB(total.bites~treatment + offset(log(hours)) +(1|rep), ziformula=~0, family=nbinom1, data=mydata)
summary(mC4)
summary(glht(mC4, mcp(treatment = "Tukey")))
r glm lm posthoc tukey
1个回答
0
投票

正如你已经提到过emmeans你可以做到的

library(emmeans)
pairs(emmeans(mC4, "treatment"))
#contrast estimate       SE df t.ratio p.value
#A - B       0.323 8.94e-01  6  0.361  0.9824
#A - C      20.930 1.51e+04  6  0.001  1.0000
#A - D       0.892 9.05e-01  6  0.985  0.7631
#B - C      20.607 1.51e+04  6  0.001  1.0000
#B - D       0.569 9.92e-01  6  0.573  0.9365
#C - D     -20.038 1.51e+04  6 -0.001  1.0000
#
#Results are given on the log (not the response) scale.
#P value adjustment: tukey method for comparing a family of 4 estimates

在这里,我们对treatment进行条件化并描述所有成对比较,使用Tukey方法校正多个假设检验。

© www.soinside.com 2019 - 2024. All rights reserved.