我试图使用包lme4中的glmer函数来拟合逻辑随机拦截模型 . 不幸的是,我收到以下警告信息和明显错误的结果(系数) .

Warning messages:
1: In vcov.merMod(object, use.hessian = use.hessian) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite: falling back to var-cov estimated from RX
2: In vcov.merMod(object, correlation = correlation, sigm = sig) :
  variance-covariance matrix computed from finite-difference Hessian is
not positive definite: falling back to var-cov estimated from RX

做了一些研究,我发现glmer产生了merMod对象 . 依赖于:http://jaredknowles.com/journal/2014/5/17/mixed-effects-tutorial-2-fun-with-mermod-objects并再现"Exploring the Internals of a merMod Object"部分,就我的模型而言,我得到了以下结果:

### [1] "standardGeneric"
###attr(,"package")
###[1] "methods"

这明显不同于

### [1] "lmerMod"
### attr(,"package")
### [1] "lme4"

正如教程中所示 .

我的问题为什么我的对象不是merMod类?上述警告是否与此相关,我该如何解决?

这是我用来创建数据框并运行模型的代码

diagn00<- rep(0,240)

drug00<- rep(0,240)

time00<- c(rep(0,80),rep(1,80),rep(2,80))

response00<- c(rep(0,39),rep(1,41),rep(0,33),rep(1,47),rep(0,26),rep(1,54))

patients00<- rep(1:80,3)

test<- data.frame(patients00,diagn00,drug00,time00,response00)

diagn01<- rep(0,210)

drug01<- rep(1,210)

time01<- c(rep(0,70),rep(1,70),rep(2,70))

response01<- c(rep(0,33),rep(1,37),rep(0,15),rep(1,55),rep(0,2),rep(1,68))

patients01<- rep(81:150,3)

diagn10<- rep(1,300)

drug10<- rep(0,300)

time10<- c(rep(0,100),rep(1,100),rep(2,100))

response10<- c(rep(0,79),rep(1,21),rep(0,72),rep(1,28),rep(0,54),rep(1,46))

patients10<- rep(151:250,3)

diagn11<- rep(1,270)

drug11<- rep(1,270)

time11<- c(rep(0,90),rep(1,90),rep(2,90))

response11<-  c(rep(0,74),rep(1,16),rep(0,45),rep(1,45),rep(0,15),rep(1,75))

patients11<- rep(251:340,3)

diagnosis<- c(diagn00,diagn01,diagn10,diagn11)
diagnosis<- as.factor(diagnosis)

id<- c(patients00,patients01,patients10,patients11)
id<- as.factor(id)

drug<- c(drug00,drug01,drug10,drug11)
drug<- as.factor(drug)
time<- c(time00,time01,time10,time11)

response<- c(response00,response01,response10,response11)

id<- c(patients00,patients01,patients10,patients11)

data<- data.frame(id, response, diagnosis, drug, time)
e<- order(data$id)
d<- data[e,]

library(lme4)

d2<- data.frame(d)
d2$response<- as.factor(d2$response)
d2$time<- as.factor(d2$time)
d2$id<- as.factor(d2$id)

t<- glmer(response ~ diagnosis + drug + time + time:drug +
(1 | id), family=binomial, data=d2)

会话信息

e:[1] LC_COLLATE = English_United States.1252 LC_CTYPE = English_United States.1252
[3] LC_MONETARY = English_United States.1252 LC_NUMERIC = C.
[5] LC_TIME = English_United States.1252

附加基础包:[1] stats graphics grDevices utils数据集方法库

其他附件包:[1] glmmML_1.0 nlme_3.1-111 MASS_7.3-29 lme4_1.1-6 Rcpp_0.11.1 Matrix_1.1-3 MuMIn_1.10.0 [8] gee_4.13-18 geepack_1.1-6

通过命名空间加载(而不是附加):[1] grid_3.0.2 lattice_0.20-29 minqa_1.2.3 RcppEigen_0.3.2.1.1 splines_3.0.2
[6] tools_3.0.2

包裹信息

packageVersion("lme4")
[1] ‘1.1.6’