warning messages using glmer function from lme4 package R

∥☆過路亽.° 提交于 2019-12-24 19:02:05

问题


I am trying to fit a logistic random intercept model using glmer function from package lme4. Unfortunately I am getting the following warning messages and clearly wrong results (for the coefficients).

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

Doing some research, I found that glmer produces merMod objects. Relying on this : http://jaredknowles.com/journal/2014/5/17/mixed-effects-tutorial-2-fun-with-mermod-objects and reproducing the "Exploring the Internals of a merMod Object" section I had the following results as far as my model is concerned:

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

which is clearly different from

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

as indicated on the tutorial.

My question why my object is not of merMod class? Are the above warnings related to this and how could I fix them?

This is the code I used to create the data frame and run the model

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)

session info

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

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [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

loaded via a namespace (and not attached): [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

package info

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

来源:https://stackoverflow.com/questions/24673425/warning-messages-using-glmer-function-from-lme4-package-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!