I've seen similar questions posted elsewhere with no answer, so I thought I'd put this out into the CrossValidated universe.
I am attempting to do a Tukey's post-hoc test on a model that has an interaction. To do this, I have used the interaction()
function to create a new variable that combines my two main effects, Habitat (3 levels) and Detritus (2 levels) into one variable.
reg.invert$interaction <- interaction(reg.invert$Habitat, reg.invert$Detritus)
Thus, I have the following model:
model <- glmer (Species Richness ~ interaction + (1|Site)).
I have been trying to do this using glht()
function in the package multcomp
.
This is what I ran, with notes about the output:
inter.test1 <- glht(model, mcp(interaction = "Tukey"))
summary(inter.test1)
cld(inter.test1)
This resulted in 5 warnings that said
In RET$pfunction("adjusted", …) : Completion with error > abseps.
Why am I getting these warnings? Should I not use the results of cld()
, given these warnings? How can I avoid the warnings? In looking at the raw data, some of the letters seem a bit off, so I was wondering if I can trust this output.
I have also run the exact same model with a different response variable without any errors, and the extracted letters make sense.
I would be very grateful for any advice for how to successfully use Tukey's method in this model, as well as for how to extract letters to denote significant differences. Either suggestions for adjusting my code or for a new approach entirely would be fine.
Thanks for your help!
Edit: See below for what I hope is a reproducible example using my data…please bear with me- I've never made one of these before:
library(lme4)
library(multcomp)
####re-create my crazy dataframe:
new.data<-structure(list(Site = structure(c(13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L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L, 2L, 1L, 3L, 1L, 5L, 3L, 1L, 6L, 4L, 1L, 3L, 4L,
4L, 4L, 8L, 2L, 3L, 5L, 1L, 1L, 3L, 2L, 6L, 8L, 4L, 3L, 3L,
1L, 1L, 1L, 2L)), .Names = c("Site", "Habitat", "Detritus",
"Species.Number"), row.names = c(NA, -216L), class = "data.frame")
####analysis:
new.data$interaction<-interaction(new.data$Habitat,new.data$Detritus)
m6<-glmer(Species.Number~interaction + (1|Site), family = "poisson", data = new.data, control=glmerControl(optimizer="bobyqa", optCtrl = list(maxfun = 20000)))
inter.test1<-glht(m6, mcp(interaction="Tukey"))
plot(inter.test1)
summary(inter.test1)
cld(inter.test1, level=0.05)
Best Answer
I also cannot seem to figure out what the warning is trying to tell us but one alternative approach would be using the
emmeans()
function in theemmeans
package and then thecld()
function:If you want to see the mean estimates on the response scale, i.e. back-transformed from the log scale, you can add
type = response
:See also the very helpful emmeans vignettes.