簡體   English   中英

glmmTMB:因素交互的成對比較事后檢驗

[英]glmmTMB: Pairwise comparison post-hoc tests for factors interaction

在我的例子中:

# Packages
library(glmmTMB)
library(DHARMa)
library(multcomp)
library(lsmeans)
library(car)

# My data set
ds <- read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/temp_ger_ds.csv")
str(ds)
#'data.frame':  140 obs. of  4 variables:
# $ temp       : chr  "constante" "constante" "constante" "constante" ...
# $ generation : chr  "G0" "G0" "G0" "G0" ...
# $ development: int  22 24 22 27 27 24 25 26 27 18 ...

首先安裝ziGamma model:

mTCFd <- glmmTMB(development ~ temp * generation, data = ds,
               family = ziGamma(link = "log")) 
Anova(mTCFd,test="Chi")
# Analysis of Deviance Table (Type II Wald chisquare tests)
# Response: development
#                   Chisq Df Pr(>Chisq)    
# temp            198.413  1  < 2.2e-16 ***
# generation       18.347  4   0.001056 ** 
# temp:generation  31.250  4  2.723e-06 ***
# ---
# Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

使用 DHARMa 檢查調整:

plot(s1 <- simulateResiduals(mTCFd))

業力 看起來不錯

成對比較事后測試:

1) For temp:
lsm.TCFd.temp <- lsmeans(mTCFd, c("temp"))
cld(lsm.TCFd.temp, Letters=letters)
#  temp      lsmean     SE  df lower.CL upper.CL .group
#  constante   3.18 0.0082 129     3.17     3.20  a    
#  flutuante   3.37 0.0131 129     3.34     3.39   b  

2) For generation:
lsm.TCFd.gen <- lsmeans(mTCFd, c("generation"))
cld(lsm.TCFd.gen, Letters=letters)
#  generation lsmean     SE  df lower.CL upper.CL .group
#  G3           3.23 0.0159 129     3.20     3.26  a    
#  G1           3.27 0.0198 129     3.23     3.31  ab   
#  G0           3.27 0.0135 129     3.25     3.30  ab   
#  G4           3.29 0.0217 129     3.25     3.34  ab   
#  G2           3.31 0.0141 129     3.28     3.34   b   

3) For temp:generation interaction:
ds$temp_gen <- paste0(ds$temp,"_",ds$generation)
mTCFd.int <- glmmTMB(development ~ temp_gen, data = ds,
               family = ziGamma(link = "log")) 
lsm.TCFd.temp.gen <- lsmeans(mTCFd.int, c("temp_gen"))
cld(lsm.TCFd.temp.gen, Letters=letters)
#  temp_gen     lsmean     SE  df lower.CL upper.CL .group 
#  constante_G3   3.13 0.0180 129     3.09     3.16  a     
#  constante_G2   3.14 0.0180 129     3.11     3.18  ab    
#  constante_G0   3.19 0.0191 129     3.15     3.23  abc   
#  constante_G1   3.22 0.0180 129     3.18     3.25   bc   
#  constante_G4   3.23 0.0185 129     3.19     3.27    cd  
#  flutuante_G1   3.32 0.0352 129     3.25     3.39    cde 
#  flutuante_G3   3.34 0.0262 129     3.28     3.39      e 
#  flutuante_G0   3.36 0.0191 129     3.32     3.39      e 
#  flutuante_G4   3.36 0.0393 129     3.28     3.44     def
#  flutuante_G2   3.47 0.0218 129     3.43     3.52       f

好的,它可以工作,但我想知道是否可以直接與最終的 model ( mTCFd ) 進行成對比較,而無需新的交互 model 調整 ( mTCFd.int )。

請問,有什么幫助嗎?

您不需要調整另一個 model 而只需指定mTCFd因子的條件( c("temp","generation") )。

lsm.TCFd.temp <- lsmeans(mTCFd, c("temp","generation"))
cld(lsm.TCFd.temp, Letters=letters)
 temp      generation lsmean     SE  df lower.CL upper.CL .group 
 constante G3           3.13 0.0180 129     3.09     3.16  a     
 constante G2           3.14 0.0180 129     3.11     3.18  ab    
 constante G0           3.19 0.0191 129     3.15     3.23  abc   
 constante G1           3.22 0.0180 129     3.18     3.25   bc   
 constante G4           3.23 0.0185 129     3.19     3.27    cd  
 flutuante G1           3.32 0.0352 129     3.25     3.39    cde 
 flutuante G3           3.34 0.0262 129     3.28     3.39      e 
 flutuante G0           3.36 0.0191 129     3.32     3.39      e 
 flutuante G4           3.36 0.0393 129     3.28     3.44     def
 flutuante G2           3.47 0.0218 129     3.43     3.52       f

Results are given on the log (not the response) scale. 
Confidence level used: 0.95 
P value adjustment: tukey method for comparing a family of 10 estimates 
significance level used: alpha = 0.05 
NOTE: Compact letter displays can be misleading
      because they show NON-findings rather than findings.
      Consider using 'pairs()', 'pwpp()', or 'pwpm()' instead. 

雖然您似乎已經回答了自己的問題,但請在此處查看我過去對類似問題的回答,並在此處查看有關專門處理 2-way 交互 emmeans 的更多詳細信息。 基本上,您的答案可以擴展一點,這可能有用也可能沒有用,具體取決於您的研究問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM