Post hoc test in generalized linear mixed models: how to do it?

I am working with a mixed model (glmmadmb) in R for data counting. I have one random factor (locality) and one fixed factor (Habitat). The fixed rate has two levels and the random rate has seven levels. I want to make comparisons between two levels of a fixed factor in each of the seven levels of a random factor. But I don't know how to do this in R. I am very new to R. Can anyone help me? Many thanks.

This is my glmm formula for more disaggregated data:

    model<-glmmadmb(Species.abundance~Habitat(1|Locality:Habitat),
                    data=data,family='nbinom1')

      

I only tried this with Habitat, but it clearly doesn't account for the terrain:

    summary(glht(model,linfct=mcp(Habitat='Tukey')))

 Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts


Fit: glmmadmb(formula = Species.abundance ~ Habitat + (1 | Locality:Habitat), 
    data = data, family = "nbinom1")

Linear Hypotheses:
                     Estimate Std. Error z value Pr(>|z|)
Fynbos - Forest == 0  -0.2614     0.2010  -1.301    0.193
(Adjusted p values reported -- single-step method)

      

+3


source to share


1 answer


I would probably just do separate tests in each location and, if you like, make corrections for several comparisons. The functions from plyr

are handy, but not needed to do this, something like

library(plyr)
library(glmmADMB)
model.list <- dlply(data,"Locality",glmmadmb,
                    formula=Species.abundance~Habitat,
                    family="nbinom1")
p.vals <- laply(model.list,function(x) coef(summary(x))[2,"Pr(>|z|)"])
p.adjust(pvals)

      



(I can't guarantee that this actually works, since you haven't given a reproducible example, and I can't think of one ...)

0


source







All Articles