-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rgampois seems to be incorrectly defined ( with respect to neg_binomial_2 from stan) #53
Comments
Thanks. If I understand right, the issue is just that the internal Stan function has a different parameterization than is assumed to be consistent with random number generator function? The map2stan model seems to be working fine. |
You are right. Based on my observation, I think the parameterization of negative binomial in stan and rethinking are different as follows: Using X ~ Gamma(a, b) where E[X]= a * b, Var[X]=a* b^2 as a reference gamma distribution(where
I was a bit confused initially, because when I think of negative binomial(or gamma-poisson mixture), I always think of poisson + overdispersion. So I automatically assumed that "scale" represented the parameter for the overdispersion, when in fact it's not. |
Just found this bug myself - I was going to post an issue but found this one. Rethinking will fit an NBD model correctly using rgampois - I can get results to match brms() glm.nb() and match the model parameters for some simulated data. (I can share detail on this if helpful) However, if you run I agree with |
Hi,
Thank you so much writing an amazing textbook. I really enjoyed it a lot and also really liked the
rethinking
package. It made bayesian analysis enjoyable thing to do.While using
rethinking::rgampois
, I noticed some inconsistency.Here's my small experiment that illustrates the point:
Plot
We can see from the bottom plot that the samples are very different from each other
Fitting the data with map2stan
precis(m2s_proposed)
precis(m2s_rethinking)
As you can see, the estimate of
phi
is more or less closer to the correct phi_truth=10 inm2s_proposed
but way off inm2s_rethinking
.The text was updated successfully, but these errors were encountered: