R: Bootstrapped binary mixed-model logistic regression using bootMer() of the new lme4 package

╄→гoц情女王★ 提交于 2019-12-03 03:57:19

There are basically two (simple) confusions here.

  • The first is between coef() (which returns a list of matrices) and fixef() (which returns a vector of the fixed-effect coefficients): I assume that fixef() is what you wanted, although you might want something like c(fixef(mixed),unlist(VarCorr(mixed))).
  • the second is that FUN should take a fitted model object as input ...

For example:

library(lme4)
library(boot)

mixed <- glmer(incidence/size ~ period + (1|herd),
               weights=size, data=cbpp, family=binomial)

FUN <- function(fit) {
    return(fixef(fit))
}

result <- bootMer(mixed, FUN, nsim = 3)

result

## Call:
## bootMer(x = mixed, FUN = FUN, nsim = 3)
## Bootstrap Statistics :
##      original      bias    std. error
## t1* -1.398343 -0.20084060  0.09157886
## t2* -0.991925  0.02597136  0.18432336
## t3* -1.128216 -0.03456143  0.05967291
## t4* -1.579745 -0.08249495  0.38272580
## 

This might be the same problem, that I reported as an issue here. At least it leads to the same, unhelpful error message and took me a while too.

That would mean you have missings in your data, which lmer ignores but which kill bootMer.

Try:

(mixed5 <- glmer(DV ~ (Demo1 +Demo2 +Demo3 +Demo4 +Trt)^2 
                 + (1 | PatientID) + (0 + Trt | PatientID)
                 , family=binomial(logit), na.omit(MixedModelData4[,c('DV','Demo1','Demo2','Demo3','Trt','PatientId')])))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!