Skip to content

Multiple Comparisons for (multicomp - glht) for glm negative binomial (glm.nb)

2 messages · lara harrup (IAH-P), Achim Zeileis

#
On Sun, 22 Mar 2009, lara harrup (IAH-P) wrote:

            
Yes, it does, because zeroinfl() (and hurdle()) both return models with 
the usual extractor methods (coef, vcov, et al). The only nuisance is that 
you can't use the mcp() interface because it will be confused about the 
two parts of the model (count vs. zero-inflation part) which might both 
contain the same variables. What you have to do is set up your contrast 
matrix by hand. An example using the NMES1988 data from the "AER" package 
is included below.

hth,
Z

## packages
library("pscl")
library("multcomp")

## data
data("NMES1988", package = "AER")
nmes <- NMES1988[, c(1, 6:8)]

## models
fm_pois <- glm(visits ~ ., data = nmes, family = poisson)
fm_nbin <- glm.nb(visits ~ ., data = nmes)
fm_zinb <- zeroinfl(visits ~ . | ., data = nmes, dist = "negbin")

## generalized linear hypotheses
glht_pois <- glht(fm_pois, linfct = mcp(health = "Tukey"))
glht_nbin <- glht(fm_nbin, linfct = mcp(health = "Tukey"))

## compute contrasts "by hand" for ZINB
nr <- length(levels(nmes$health))
contr <- matrix(0, nrow = nr, ncol = length(coef(fm_zinb)))
colnames(contr) <- names(coef(fm_nbin))
rownames(contr) <- paste(levels(nmes$health)[c(2, 3, 3)], 
levels(nmes$health)[c(1, 1, 2)], sep = " - ")
contr[,3:4] <- contrMat(numeric(nrow(contr)), type = "Tukey")[,-2]
glht_zinb <- glht(fm_zinb, linfct = contr)

## multiple comparisons
summary(glht_pois)
summary(glht_nbin)
summary(glht_zinb)