glmer(cbind(NGG,NGNG) ~ RH3*Altitude + AbH + Date3 + (1 | Receptor/Code/Plant) +
(1 | Mountain/Community), data=database, family="binomial",
control = glmerControl(optimizer="bobyqa"))
其中NGG是成功次数(每个柱头的发芽谷粒,范围从0到例如55),NGNG是失败次数(非发芽谷粒0到例如80)。问题是,在看到结果之后,数据似乎过于分散,如该函数所示(位于http://rstudio-pubs-static.s3.amazonaws.com/263877_d811720e434d47fb8430b8f0bb7f7da4.html中):
overdisp_fun <- function(model) {
vpars <- function(m) {
nrow(m)*(nrow(m)+1)/2
}
model.df <- sum(sapply(VarCorr(model), vpars)) + length(fixef(model))
rdf <- nrow(model.frame(model))-model.df
rp <- residuals(model, type = "pearson") # computes pearson residuals
Pearson.chisq <- sum(rp^2)
prat <- Pearson.chisq/rdf
pval <- pchisq(Pearson.chisq, df = rdf, lower.tail = FALSE)
c(chisq = Pearson.chisq, ratio = prat, rdf = rdf, p = pval)
}
输出为: chisq = 1.334567e + 04,比率= 1.656201e + 00,rdf = 8.058000e + 03,p = 3.845911e-268
因此,我决定尝试按以下方式在glmmTMB中使用beta二项式(保持这种层次结构很重要):
glmmTMB(cbind(NGG,NGNG) ~ RH3*Altitude + AbH + Date3 + (1 | Receptor/Code/Plant) +
(1 | Mountain/Community), data=database,
family=betabinomial(link = "logit"), na.action = na.omit, weights=NGT)
当我运行它时..说: nlminb中的错误(开始= par,目标= fn,梯度= gr,控制= control $ optCtrl):(从警告转换)NA / NaN函数评估
模型编写中是否存在错误?我已经在(http://rstudio-pubs-static.s3.amazonaws.com/263877_d811720e434d47fb8430b8f0bb7f7da4.html)中检查了可能的问题,但尚未找到任何解决方案。
谢谢