Skip to content

Instantly share code, notes, and snippets.



Last active Sep 28, 2019
What would you like to do?
A gist that shows how a rootogram helps find that the zero-inflated negative binomial was the data generating mechanism.
# install.packages("countreg", repos="")
rzinbinom(3e3, size = 4, mu = 20, pi = 0.05) -> x
hist(x, col = "orange")
rootogram(glm(x ~ 1, family = "poisson")) # zeros under fit
rootogram(zeroinfl(x ~ 1, dist = "poisson")) # low counts under fit, high counts over fit
rootogram(zeroinfl(x ~ 1, dist = "negbin")) # zero fit well, low counts fit well, high counts fit well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.