广义线性混合模型:使用带有glmer()的estimateble()来生成系数的线性组合

时间:2015-12-09 00:25:02

标签: r logistic-regression binomial-coefficients

我有一个带有三向交互的广义线性混合模型,一个嵌套的随机变量和一个二项式响应变量:

modelB15=glmer(cbind(resistant, (total-resistant) )~
               time*inoc_source*inoc_resistance+
               (1|block/plot),
               family = binomial,
               data = B15)

生成系数的线性组合(对比矩阵)的相应矩阵是:

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)

然后我可以拉出向量来测试不同的假设,例如“时间1与时间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)

我想在库(gmodels)中使用estimateble()来对每个系数或系数组合的均值进行不同的比较:

estimable(modelB15, timeDiff, conf.int=.991) 

但是我收到以下错误消息:

Error in FUN(newX[, i], ...) : 'param' has no names and does not match number of coefficients of model. Unable to construct coefficient vector

estimateble()适用于glm,但是a)如何修改它以使用lmer()b)如果估计不能用于GLMM,其他哪些函数可以完成相同的任务?

我尝试了glmmPQL(),但它也无效。

this page中的作者试图完成类似的事情。

This page有点帮助。

1 个答案:

答案 0 :(得分:0)

if [ -t 0 ]; then # being run by a human, be extra verbose PS4=':$LINENO+' set -x else # being run by a daemon, be outright silent exec >/dev/null 2>&1 fi 不适用于estimable()

但是,glmer()包与广义线性混合模型兼容,并且可以通过成对比较生成LS均值。这使用户能够比较系数的组合,而不会产生混乱的矩阵。

Walter W. Stroup的

[Rethinking the analysis of non-normal data in plant and soil science]有一个很好的描述和补充文件包含有用的例子R代码