1

I am trying to run a simple random-effects model in a Poisson family in R. I don't understand the error, or why it's throwing me an error. I tried the same with a few other datasets, and I get a similar error. What could possibly be generating the error?

library(ggplot2)
library(lme4)

y.test <- c(3.09601,3.546579, 12.115740,  2.226694,  1.180938,  4.420249,  2.001162,  3.788012, 21.170732,  7.494421 , 5.602522 , 3.300510, 11.404264 ,23.115029,
            19.371686, 25.444904, 17.094280  ,1.368615 ,19.343291 , 9.724363 , 8.086256 ,13.021972 ,10.740431 , 2.768960 ,14.494745 ,19.040086 , 7.072040,  8.748415,
            10.012655, 14.759963 , 6.669221,  9.179184, 14.069743 ,12.132714,  8.517986, 18.095548,  9.076304,  9.197501,  7.972339 , 3.111373, 10.802117, 16.874861,
            2.977454 ,15.195754,  5.433059 , 8.569472, 24.479745 , 3.756167  ,7.028482 , 7.412065 , 6.298529 , 3.585942 , 4.706638 , 9.00223)

x.test <- c(1:54)

random.effect <- rep(c("A","B","C"), each=18)

df.test <- data.frame(x.test, y.test, random.effect)
df.test$random.effect <- as.factor(df.test$random.effect)
df.test$y.test <- as.numeric(df.test$y.test)
df.test$x.test <- as.numeric(df.test$x.test)

mod <- glmer(y.test ~ x.test + I(x.test^2) + (1|random.effect), data = df.test, family = poisson)
summary(mod)

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

Rspacer
  • 2,369
  • 1
  • 14
  • 40
  • It's a warning, not an error. See https://stackoverflow.com/questions/38997371/glmer-warning-variance-covariance-matrix-is-not-positive-definite-or-cont –  Apr 15 '22 at 04:22
  • Does this answer your question? [GLMER warning: variance-covariance matrix \[...\] is not positive definite or contains NA values](https://stackoverflow.com/questions/38997371/glmer-warning-variance-covariance-matrix-is-not-positive-definite-or-cont) –  Apr 15 '22 at 04:23

0 Answers0