Skip to content
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

Bug in the negative binomial because of syntax error #22

Open
ugroempi opened this issue Nov 13, 2024 · 0 comments
Open

Bug in the negative binomial because of syntax error #22

ugroempi opened this issue Nov 13, 2024 · 0 comments

Comments

@ugroempi
Copy link

Thank you very much for making this very interesting and useful book available on github!
I have used it today for teaching Poisson regression, and I got stuck with the negative binomial model.

Actually, the model that is printed in the book uses the weights offset(log(offset1000)) instead of the offset, as the correct implementation of the offset would be with a "+" instead of the ",". You can verify that this is indeed the case by running str(modelinb). The corrected code produces quite different coefficients in some places, e.g., the type within the central region is no longer significant (this was presumably caused by universities being bigger than colleges, which was not accounted for by an offset). It remains true that the negative binomial model has several effects with smaller p-values.

By the way, the tweak to prevent the logarithm from becoming negative by modifying the offset1000 for c.data2 is not necessary for the corrected code, because a negative offset is perfectly permissible, whereas a negative weight is not (this error message drew my attention to the issue, because I tried to run the code on c.data, because I didn't immediately know how to obtain c.data2).

Best regards,
Ulrike Grömping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant