I have a generalized linear mixed model with a three way interaction, a nested random variable, and a binomial response variable :
modelB15=glmer(cbind(resistant, (total-resistant) )~
time*inoc_source*inoc_resistance+
(1|block/plot),
family = binomial,
data = B15)
the corresponding matrix to generate linear combinations of coefficients (a contrast matrix) is:
time1_sourceHY_mix = c(1,0,0,0,0,0,0,0,0,0,0,0)
time2_sourceHY_mix = c(1,1,0,0,0,0,0,0,0,0,0,0)
time1_sourceNV_mix = c(1,0,1,0,0,0,0,0,0,0,0,0)
time1_sourceHY_negative = c(1,0,0,1,0,0,0,0,0,0,0,0)
time1_sourceHY_positive = c(1,0,0,0,1,0,0,0,0,0,0,0)
time1_sourceNV_negative = c(1,0,1,1,0,1,0,0,0,0,0,0)
time1_sourceNV_positive = c(1,0,1,0,1,0,1,0,0,0,0,0)
time2_sourceNV_mix = c(1,1,1,0,0,0,0,1,0,0,0,0)
time2_sourceHY_negative = c(1,1,0,1,0,0,0,0,1,0,0,0)
time2_sourceHY_positive = c(1,1,0,0,1,0,0,0,0,1,0,0)
time2_sourceNV_negative = c(1,1,1,1,0,1,0,1,1,0,1,0)
time2_sourceNV_positive = c(1,1,1,0,1,0,1,1,0,1,0,1)
I then can pull up the vectors to test different hypotheses, such as "is time 1 different from time 2"?
time_HYpositive = time2_sourceHY_negative-time1_sourceHY_positive
time_HYnegative = time2_sourceHY_negative-time1_sourceHY_negative
time_HYmix = time2_sourceHY_mix-time1_sourceHY_mix
time_NVpositive = time2_sourceNV_negative-time1_sourceNV_positive
time_NVnegative = time2_sourceNV_negative-time1_sourceNV_negative
time_NVmix = time2_sourceNV_mix-time1_sourceNV_mix
timeDiff=rbind(time_HYpositive, time_HYnegative, time_HYmix,
time_NVpositive,time_NVnegative,time_NVmix)
I want to use estimable() in library(gmodels) to make different comparisons between means for each coefficient or combination of coefficients:
estimable(modelB15, timeDiff, conf.int=.991)
but I get the following error message:
Error in FUN(newX[, i], ...) : 'param' has no names and does not match number of coefficients of model. Unable to construct coefficient vector
estimable() works great with a glm, but a) how can it be modified to work with lmer() b) if estimable won't work with a GLMM, what other functions could accomplish the same task?
I have tried glmmPQL()
, it doesn't work either.
The author in this page is trying to accomplish a similar thing.
This page was a bit helpful.