我有一个关于单蜂丰度的非常小的数据集,我无法进行分析。它是计数数据,几乎所有计数都在一种处理中,而大多数零在另一种处理中。还有两个非常高的值(六个站点中的两个站点中的每个站点),因此计数分布的尾巴非常长。我正在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