Skip to content

Bug in the negative binomial because of syntax error #22

@ugroempi

Description

@ugroempi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions