我正在运行一个逻辑广义线性混合模型,并希望将我的效果与置信区间一起绘制 . 我使用lme4包来适应我的模型:

glmer (cbind(positive, negative) ~ F1 * F2 * F3 + V1 + F1 * I(V1^2) + V2 + F1 * I(V2^2) + V3 + I(V3^2) + V4 + I(V4^2) +  F4 + (1|OLRE) + (1|ind), family = binomial, data = try, na.action = na.omit, control=glmerControl(optimizer = "optimx", calc.derivs = FALSE, optCtrl = list(method = "nlminb", starttests = FALSE, kkt = FALSE)))

OLRE意味着我使用观察水平随机效应来克服过度离散 .

如果您因为收敛警告而感到奇怪,我会通过lme4故障排除协议,它应该没问题 .

为了获得具有置信区间的效果图,我尝试使用ggpredict:sjPlot,例如:

plot_model(mod, type = "pred", terms = c("F1", "F2", "F3"), ci.lvl = 0.95)

我也尝试过这个协议:https://rpubs.com/hughes/84484

intdata <- expand.grid(
  positive = c(0,1), 
  negative = c(0,1),
  F1 = as.factor(c(0,1)), 
  F2 = as.factor(c(1,2,3)), 
  F3= as.factor(c(1,2,3,4)), 
  V1= as.numeric(median(try$V1)),
  F4= as.factor(c(30, 31)), 
  ind= as.factor(c(68)), 
  OLRE = as.factor(c(2450)), 
  V2= as.numeric(median(try$V2)), 
  V3= as.numeric(median(try$V3)), 
  V4= as.numeric(median(try$V4))
  )


 #conditional variances
 cV <- ranef(mod, condVar = TRUE) 
 ranvar <- attr(cV[[1]], "postVar")
 sqrt(diag(ranvar[,,1]))


 mm <- model.matrix(terms(  mod), data=intdata, 
               contrasts.arg = lapply(intdata[,c(3:5, 7:9)], contrasts, contrasts=FALSE))


 predFun<-function(.) mm%*%fixef(.) 
 bb<-bootMer(mod,FUN=predFun,nsim=3)

有关对比和问题的一些问题和警告

Error in mm %*% fixef(.) : non-conformable arguments

因此,我想知道是否有人可以帮助我,但到目前为止我无法做到目前为止没有任何工作,所以我真的很感激一些帮助 .

这里是数据的链接https://drive.google.com/file/d/1qZaJBbM1ggxwPnZ9bsTCXL7_BnXlvfkW/view?usp=sharing