You could do it using the emmeans
package.
Then simply do:
m_means <- emmeans(NegativeBinomalLatencyModel, ~ Resource)
#TO GET PAIRWISE COMPARISONS WITH DIFFERENCES INDICATED AS LETTERS
cld(m_means, Letters = letters)
The emmeans
package has a very good documentation (see link above).
Edit to address OPs comments:
If you want to plot the data, you can do it simply via the emmip()
function (from the emmeans
package). Have look at ?emmip
for details. Using your specific example a basic plot could be generated like this:
#BASIC PLOT
emmip(m_means, ~ Resource)
#BASIC PLOT WITH CONFIDENCE LIMITS
emmip(m_means, ~ Resource, CIs=T)
#BASIC PLOT WITH CONFIDENCE LIMITS ON THE RESPONSE SCALE
emmip(m_means, ~ Resource, CIs=T, type="response")
Another way of plotting can be achieved by simply using the plot()
function. For that have a look at ?plot.emmGrid
.
If you want more control, you can store the output of cld()
in an object such as this:
m_means_table <- cld(m_means, Letters = letters)
This can then be used in ggplot2
for example:
require(ggplot2)
ggplot(m_means_table, aes(x=Resource, y=emmean)) + geom_point() +
geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE))
If you want upper and lower confidence limits, you can simply replace emmean-SE
with asymp.LCL
and emmean+SE
with asymp.UCL
, respectively (from the m_means_table
object).
Also have a look at my answer on poisson
and glm.nb
models here:
poisson glm to observe whether effects of artificial light on the number of bat passes in each location were significant