Error in check_stanfit(stanfit)

Please also provide the following information in addition to your question:

  • Operating System: Windows
  • rstanarm Version: 2.19.3

Hi everyone; I ran a stal_glm example for a poisson regression that I found here:

Estimating Generalized Linear Models for Count Data with rstanarm

The code exact code I ran was this one:

 library(rstanarm)
 data(roaches)

stan_glm1 <- stan_glm(y ~ roach1, offset = log(exposure2),
                  data = roaches, family = poisson, 
                  prior = normal(0, 2.5, autoscale=FALSE), 
                  prior_intercept = normal(0, 5, autoscale=FALSE),
                  seed = 12345)

When stan finishes the iterations, I got this error:

[1] "Error in sampler$call_sampler(args_list[[i]]) : " 
[2] "  Exception: poisson_rng: Rate parameter is 0, but must be > 0!  (in 'model_count' at line 197)"
[1] "error occurred during calling the sampler; sampling not done"
Error in check_stanfit(stanfit) : 
  Invalid stanfit object produced please report bug

I update my rstanarm package and the same error happens again!

I would try with a different seed or just call stan_glm with mean_PPD = FALSE. However, if you are underflowing, then the model has problems.

1 Like

Yes Changing the seed helps! But I dont understand why rstanarm send that message!

The expectation of the Poisson distribution was so close to zero that it was considered zero, which is invalid.

1 Like

Thanks again :)