I have this example where I'd like to have multiple comparisons across treatments. Here is the data:
data.1 <-read.csv(text = "
location,treat,response
loc1,T1,120
loc1,T2,60
loc1,T3,59
loc1,T4,10
loc2,T1,129
loc2,T2,55
loc2,T3,59
loc2,T4,8
loc3,T1,134
loc3,T2,60
loc3,T3,58
")
And this is what I did:
library(lme4)
library(lmerTest)
library(emmeans)
library(multcomp)
model.fit <- lmer(response ~ treat + (1|location), data = data.1)
model.fit.emmeans <- emmeans(model.fit, ~ treat,
options = list(estName = "response"))
pairs.comp.glht<-glht(model.fit, linfct=mcp(treat="Tukey"))
pairs.comp.glht.cld <-cld(pairs.comp.glht)
Running this pairs.comp.glht.cld
gave me the output I needed.
I am looking for the value of the minimum difference to call a difference and display a different letter. I am assuming the value should be in this object: pairs.comp.glht
or here pairs.comp.glht.cld
, but I cannot extract the value.
You can get a more detailed summary of the results with
summary(pairs.comp.glht)
#
# Simultaneous Tests for General Linear Hypotheses
#
# Multiple Comparisons of Means: Tukey Contrasts
#
#
# Fit: lmer(formula = response ~ treat + (1 | location), data = data.1)
#
# Linear Hypotheses:
# Estimate Std. Error z value Pr(>|z|)
# T2 - T1 == 0 -69.3333 3.3806 -20.509 <1e-08 ***
# T3 - T1 == 0 -69.0000 3.3806 -20.410 <1e-08 ***
# T4 - T1 == 0 -118.6667 3.7796 -31.396 <1e-08 ***
# T3 - T2 == 0 0.3333 3.3806 0.099 1
# T4 - T2 == 0 -49.3333 3.7796 -13.052 <1e-08 ***
# T4 - T3 == 0 -49.6667 3.7796 -13.141 <1e-08 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# (Adjusted p values reported -- single-step method)
Note that the standard errors vary so the minimum difference will also vary. For the first comparison, to get a two-tailed p-value of .05 you would need a difference of 1.96 * 3.3806 = +/-6.625976.