找不到适合混合效果的计数数据的良好模型-ZINB还是其他?


12

我有一个关于单蜂丰度的非常小的数据集,我无法进行分析。它是计数数据,几乎所有计数都在一种处理中,而大多数零在另一种处理中。还有两个非常高的值(六个站点中的两个站点中的每个站点),因此计数分布的尾巴非常长。我正在R中工作。我使用了两个不同的软件包:lme4和glmmADMB。

泊松混合模型不适合:当不拟合随机效应时模型过于分散(glm模型),而当拟合随机效应时模型分散不充分(glmer模型)。我不明白为什么会这样。实验设计要求嵌套随机效应,因此我需要将它们包括在内。泊松对数正态误差分布不会提高拟合度。我使用glmer.nb尝试了负二项式误差分布,但无法拟合它–达到了迭代极限,即使使用glmerControl(tolPwrss = 1e-3)更改了公差。

因为很多零是由于我根本看不到蜜蜂(它们通常是微小的黑色物体)而造成的,所以我接下来尝试了零膨胀模型。ZIP不太适合。ZINB是迄今为止最好的模型拟合,但是我仍然对模型拟合不太满意。我不知道下一步该怎么做。我确实尝试了跨栏模型,但无法将截断分布拟合到非零结果–我认为是因为在控制处理中有很多零(错误消息是“ Model.frame.default(formula = s.bee〜tmt + lu +:可变长度不同(发现为“治疗”)”)。

另外,我认为我所包含的交互对我的数据做了一些奇怪的事情,因为系数很小,尽管当我比较bbmle软件包中使用AICctab的模型时包含交互的模型是最好的。

我包括一些R脚本,这些脚本几乎可以重现我的数据集。变量如下:

d = Julian日期,df = Julian日期(作为因子),d.sq = df平方(蜜蜂数量增加,然后整个夏天下降),st =站点,s.bee =蜜蜂数量,tmt =处理,lu =土地利用类型,hab =周围景观中半自然栖息地的百分比,ba =边界地区的圆形田地。

非常感谢收到关于如何获得良好模型拟合的任何建议(替代误差分布,不同类型的模型等)!

谢谢。

d <- c(80,  80,  121, 121, 180, 180, 86,  86,  116, 116, 144, 144, 74,  74, 143, 143, 163, 163, 71, 71,106, 106, 135, 135, 162, 162, 185, 185, 83,  83,  111, 111, 133, 133, 175, 175, 85,  85,  112, 112,137, 137, 168, 168, 186, 186, 64,  64,  95,  95,  127, 127, 156, 156, 175, 175, 91,  91, 119, 119,120, 120, 148, 148, 56, 56)
df <- as.factor(d)
d.sq <- d^2
st <- factor(rep(c("A", "B", "C", "D", "E", "F"), c(6,12,18,10,14,6)))
s.bee <- c(1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,4,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,3,0,0,0,0,5,0,0,2,0,50,0,10,0,4,0,47,3)
tmt <- factor(c("AF","C","C","AF","AF","C","AF","C","AF","C","C","AF","AF","C","AF","C","AF","C","AF","C",
"C","AF","AF","C","AF","C","C","AF","AF","C","AF","C","AF","C","AF","C","AF","C","AF","C",
"C","AF","AF","C","AF","C","AF","C","AF","C","C","AF","C","AF","C","AF","AF","C","AF","C",
"AF","C","AF","C","AF","C"))
lu <- factor(rep(c("p","a","p","a","p"), c(6,12,28,14,6)))
hab <- rep(c(13,14,13,14,3,4,3,4,3,4,3,4,3,4,15,35,37,35,37,35,37,35,37,0,2,1,2,1,2,1), 
        c(1,2,2,1,1,1,1,2,2,1,1,1,1,1,18,1,1,1,2,2,1,1,1,14,1,1,1,1,1,1))
ba <-  c(480,6520,6520,480,480,6520,855,1603,855,1603,1603,855,855,12526,855,5100,855,5100,2670,7679,7679,2670,
2670,7679,2670,7679,7679,2670,2670,7679,2670,7679,2670,7679,2670,7679,1595,3000,1595,3000,3000,1595,1595,3000,1595
,3000,4860,5460,4860,5460,5460,4860,5460,4860,5460,4860,4840,5460,4840,5460,3000,1410,3000,1410,3000,1410)
data <- data.frame(st,df,d.sq,tmt,lu,hab,ba,s.bee)
with(data, table(s.bee, tmt) )

# below is a much abbreviated summary of attempted models:

library(MASS)
library(lme4)
library(glmmADMB)
library(coefplot2)

###
### POISSON MIXED MODEL

    m1 <- glmer(s.bee ~ tmt + lu + hab + (1|st/df), family=poisson)
    summary(m1)

    resdev<-sum(resid(m1)^2)
    mdf<-length(fixef(m1)) 
    rdf<-nrow(data)-mdf
    resdev/rdf
# 0.2439303
# underdispersed. ???



###
### NEGATIVE BINOMIAL MIXED MODEL

    m2 <- glmer.nb(s.bee ~ tmt + lu + hab + d.sq + (1|st/df))
# iteration limit reached. Can't make a model work.



###
### ZERO-INFLATED POISSON MIXED MODEL

    fit_zipoiss <- glmmadmb(s.bee~tmt + lu + hab + ba + d.sq +
                    tmt:lu +
                    (1|st/df), data=data,
                    zeroInflation=TRUE,
                    family="poisson")
# has to have lots of variables to fit
# anyway Poisson is not a good fit



###
### ZERO-INFLATED NEGATIVE BINOMIAL MIXED MODELS

## BEST FITTING MODEL SO FAR:

    fit_zinb <- glmmadmb(s.bee~tmt + lu + hab +
                    tmt:lu +
                    (1|st/df),data=data,
                    zeroInflation=TRUE,
                    family="nbinom")
    summary(fit_zinb)
# coefficients are tiny, something odd going on with the interaction term
# but this was best model in AICctab comparison

# model check plots
    qqnorm(resid(fit_zinb))
    qqline(resid(fit_zinb))

    coefplot2(fit_zinb)

    resid_zinb <- resid(fit_zinb , type = "pearson")
    hist(resid_zinb)

    fitted_zinb <- fitted (fit_zinb)
    plot(resid_zinb ~ fitted_zinb)


## MODEL WITHOUT INTERACTION TERM - the coefficients are more realistic:

    fit_zinb2 <- glmmadmb(s.bee~tmt + lu + hab +
                    (1|st/df),data=data,
                    zeroInflation=TRUE,
                    family="nbinom")

# model check plots
    qqnorm(resid(fit_zinb2))
    qqline(resid(fit_zinb2))

    coefplot2(fit_zinb2)

    resid_zinb2 <- resid(fit_zinb2 , type = "pearson")
    hist(resid_zinb2)

    fitted_zinb2 <- fitted (fit_zinb2)
    plot(resid_zinb2 ~ fitted_zinb2)



# ZINB models are best so far
# but I'm not happy with the model check plots

2
我知道这是一个非常老的帖子,现在可能已经不相关了,但是我想强调一下,根据我最近遇到的一个非常类似的问题,不需要正常分布glmers的残差。因此,真的没有必要对正态性进行检验以及对拟合残差与残差进行检验。通常,诊断glmers的残留图非常困难。
fsociety 2015年

Answers:


2

这篇文章有四年了,但是我想听一听社会在评论中所说的话。GLMM中残差的诊断并不简单,因为即使正确指定了模型,标准残差图仍可能显示非正态性,异方差等。有一个R软件包,DHARMa特别适合诊断这些类型的模型。

该软件包基于一种仿真方法,可以从拟合的广义线性混合模型生成比例残差,并生成不同的易于解释的诊断图。这是一个小示例,其中包含原始帖子和第一个拟合模型(m1)的数据:

library(DHARMa)
sim_residuals <- simulateResiduals(m1, 1000)
plotSimulatedResiduals(sim_residuals)

DHARMa残差图

左侧的图显示了缩放残差的QQ图,以检测与预期分布的偏差,右侧的图代表残差与预测值的比较,同时执行分位数回归以检测与均匀性的偏差(红线应为水平且在0.25处,0.50和0.75)。

此外,该软件包还具有特定功能,用于测试过/欠分散和零充气,其中包括:

testOverdispersionParametric(m1)

Chisq test for overdispersion in GLMMs

data:  poisson
dispersion = 0.18926, pearSS = 11.35600, rdf = 60.00000, p-value = 1
alternative hypothesis: true dispersion greater 1

testZeroInflation(sim_residuals)

DHARMa zero-inflation test via comparison to expected zeros with 
simulation under H0 = fitted model


data:  sim_residuals
ratioObsExp = 0.98894, p-value = 0.502
alternative hypothesis: more
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.