stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
388 stars 133 forks source link

rstanarm throwing error when applied to estimation of negative binomial model in ROS book (ch15 ex1) #494

Closed edhearn84 closed 3 years ago

edhearn84 commented 3 years ago

Summary:

Negative binomial model crashes out when applied to Risky data on HIV infection

Description:

Code keeps throwing this error:

"error occurred during calling the sampler; sampling not done Error in check_stanfit(stanfit) : Invalid stanfit object produced please report bug"

Poisson regressions in parts a and b of Ch 15, Ex1 run fine, if run prior to to negative binomial. But, once negative binomial errors out, the Poisson regressions won't run either.

Reproducible Steps:

neg_bin = stan_glm(bupacts ~ women_alone , data = risky , family = neg_binomial_2(link = "log"))

After application to Gelman's Risky ROS data.

RStanARM Version:

RStanArm Version 2.19.2

R Version:

R Version 3.6.2

Operating System:

Mac OS Catalina Version 10.15.5

jgabry commented 3 years ago

Hi @edhearn84, thanks for reporting this. I'm not able to reproduce this on my Mac with Catalina 10.15.5 (it runs fine for me), but I have R 4.0.3 and rstanarm 2.21.1 and it looks like you have older versions of both. I think it should work with your versions, but since it's not working I would guess that updating both would fix the problem. Either way I recommend updating R and rstanarm because we made some other changes specifically to line up with the content of Regression and Other Stories. So even if you weren't getting an error there would differences between your version and what the book is expecting (e.g. some changes to priors, the new posterior_epred() function, and a few other things).

edhearn84 commented 3 years ago

Hello @jgabry, no problem. I'm also happy to report that your suggestion worked like a charm: updates to both R and rstanarm (via CRAN) solved my issues! Thanks for your prompt response and good advice

jgabry commented 3 years ago

I'm also happy to report that your suggestion worked like a charm: updates to both R and rstanarm (via CRAN) solved my issues! Thanks for your prompt response and good advice

Ok great, glad that worked! Thanks for letting me know.