[R-sig-ME] Model approach for pairwise comparison post-hoc
Lenth, Russell V
ru@@e||-|enth @end|ng |rom u|ow@@edu
Wed Jul 27 18:10:18 CEST 2022
Just use
lsm.both <- lsmeans(mTCFd, c("temp", "generation"))
cld(lsm.both)
-----Original Message-----
Message: 1
Date: Wed, 27 Jul 2022 12:40:32 +0000 (UTC)
From: Alexandre Santos <alexandresantosbr using yahoo.com.br>
To: "r-sig-mixed-models using r-project.org"
<r-sig-mixed-models using r-project.org>
Subject: [R-sig-ME] Model approach for pairwise comparison post-hoc
Message-ID: <1309771597.2820689.1658925632725 using mail.yahoo.com>
Content-Type: text/plain; charset="utf-8"
In my example:
# Packages
library(glmmTMB)
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 ...
First fit the ziGamma model:
mTCFd <- glmmTMB(development ~ temp * generation + (1 | 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.412 1 < 2.2e-16 ***
# generation 18.346 4 0.001056 **
# temp:generation 31.250 4 2.723e-06 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Pairwise Comparison Post Hoc Tests:
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 128 3.17 3.20 a
# flutuante 3.37 0.0131 128 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 128 3.20 3.26 a
# G1 3.27 0.0198 128 3.23 3.31 ab
# G0 3.27 0.0135 128 3.25 3.30 ab
# G4 3.29 0.0217 128 3.25 3.34 ab
# G2 3.31 0.0141 128 3.28 3.34 b
3) For temp:generation interaction:
ds$temp_gen <- paste0(ds$temp,"_",ds$generation)
mTCFd.int <- glmmTMB(development ~ temp_gen + (1 | generation), 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 128 3.09 3.16 a
# constante_G2 3.14 0.0180 128 3.11 3.18 ab
# constante_G0 3.19 0.0191 128 3.15 3.23 abc
# constante_G1 3.22 0.0180 128 3.18 3.25 bc
# constante_G4 3.23 0.0185 128 3.19 3.27 cd
# flutuante_G1 3.32 0.0352 128 3.25 3.39 cde
# flutuante_G3 3.34 0.0262 128 3.28 3.39 e
# flutuante_G0 3.36 0.0191 128 3.32 3.39 e
# flutuante_G4 3.36 0.0393 128 3.28 3.44 def
# flutuante_G2 3.47 0.0218 128 3.43 3.52 f
Ok, it works, but I'd like to know if is possible for the pairwise comparison
directly with the final model (`mTCFd`) without a new interaction model adjustment (`mTCFd.int`).
This is because different models have different parameters and I'm interesting in the `mTCFd` adjustment.
Please, any help with it?
More information about the R-sig-mixed-models
mailing list