Я пытаюсь согласовать модель случайных эффектов с нулевым коэффициентом Пуассона с данными счета, используя glmmTMB.Однако я получил несколько ошибок и предупреждений.
head(data)
count time study
1 0 259 1
2 0 199 1
3 0 571 1
4 0 927 1
5 7 254 1
6 0 877 1
str(data)
'data.frame': 959 obs. of 3 variables:
$ count : int 0 0 0 0 7 0 0 0 0 0 ...
$ time : int 259 199 571 927 254 877 555 158 1014 705 ...
$ study : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
время - это смещенный термин, а исследование - это случайный эффект, который я должен добавить.
Ошибка 1
Если я добавлю случайный эффект, то следующие модели со случайным эффектом сообщают о той же ошибке
f1<-glmmTMB(count~1+offset(time)+1|study, data = data, family = poisson, ziformula = ~1|study)
f2<-glmmTMB(count~1+offset(time)+1|study, data = subset(data, study=="1"), family = poisson, ziformula = ~1|study)
NA/NaN function evaluationError in nlminb(start = par, objective = fn, gradient = gr, control = control$optCtrl) :
gradient function must return a numeric vector of length 4
Ошибка 2
Я думал, что мне нужнопопробовать более простую модель, и поэтому я отбросил случайный эффект.К сожалению, я получил другую ошибку.
f3<-glmmTMB(count~1+offset(time), data = data, family = poisson, ziformula = ~1)
f4<-glmmTMB(count~1+offset(time), data = subset(data, study=="1"), family = poisson, ziformula = ~1)
NA/NaN function evaluationError in nlminb(start = par, objective = fn, gradient = gr, control = control$optCtrl) :
NA/NaN gradient evaluation
Предупреждение 1
OK.Интересно, как я могу получить вывод без каких-либо ошибок.Итак, я отбросил смещение вместо случайного эффекта и таким образом получил предупреждение вместо ошибки.
f5<-glmmTMB(count~1+1|study, data = data, family = poisson, ziformula = ~1|study)
f6<-glmmTMB(count~1+1|study, data = subset(data, study=="1"), family = poisson, ziformula = ~1|study)
Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729
«Хорошее» соответствие без ошибок и предупреждений
После нескольких обновлений я обнаружил, что если я уроню хотя бы один из двух терминов со случайным эффектом и смещения, модели не сообщат ни об ошибке, ни о предупреждении.
f7<-glmmTMB(count~1+1|study, data = data, family = poisson, ziformula = ~1)
f8<-glmmTMB(count~1, data = data, family = poisson, ziformula = ~1|study)
Вопрос
Какие проблемы вызвали эти ошибки и возникли проблемы?Если возможно, как я могу подогнать модель со смешанным эффектом ZIP и не получить ни ошибки, ни предупреждения?
Пример
У меня есть воспроизводимый пример, который выдал предупреждение 1
count.ex<-rpois(500, 0.2)
study.ex<-as.factor(sample(1:5, 500, replace = TRUE))
time.ex<-rexp(500, 150)
fit.ex<-glmmTMB(count.ex~1+offset(time.ex)+1|study.ex, family = poisson, ziformula = ~1|study.ex)
Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Cholmod warning 'matrix not positive definite' at file ../Supernodal/t_cholmod_super_numeric.c, line 729Model convergence problem; non-positive-definite Hessian matrix. See vignette('troubleshooting')