In R, I'm doing a post-hoc analysis on my data, specifically with emmeans with a negative binomial model. Specifically I'd like to know the significance between the different treatment groups I have (treatment) on any given week (warr).
My model is represented as such:
negbin <- glm.nb(flwrs ~ factor(treatment) * factor(warr), data = test)
Worth noting that my data file contains all observations and not just the average values.
Through a tutorial I found, I did the following to get emmeans
nagelkerke(negbin)
emm.z2.2 <- emmeans(negbin, ~treatment | warr, data = test)
emm.z2.2.p <- pairs(emm.z2.2, adjust = "tukey")
emm.z2.2.p
When trying to annote significance using compact letter display, I started with multcomp4 but soon realized that multcomp2 would fit better for a negative binomical model and I typed the following and get the subsequent error message:
cld <- multcompLetters2(negbiny, emm.z2.p, data = test)
Error in `[.data.frame`(data, , fm[[2]]) : undefined columns selected
I don't quite understand the errors, or how I can supply parameters that aren't already noted in the model formula or emmeans. Is it because the output for negbin
and emm.z2.2.p
look different and don't quite match up? How can I specify cld
further?
Any help is much appreciated!