munb = 3; phi = 0.2; size = k = 10
x = 0:10
(ii = dzinegbin(x, phi=phi, mu=munb, size=k))
max(abs(cumsum(ii) - pzinegbin(x, phi=phi, mu=munb, size=k))) # Should be 0
table(rzinegbin(100, phi=phi, mu=munb, size=k))
table(qzinegbin(runif(1000), phi=phi, mu=munb, size=k))
round(dzinegbin(x, phi=phi, mu=munb, size=k) * 1000) # Should be similar
barplot(rbind(dzinegbin(x, phi=phi, mu=munb, size=k),
dnbinom(x, mu=munb, size=k)),
beside = TRUE, col = c("blue","green"),
main=paste("ZINB(mu=", munb, ", k=", k, ", phi=", phi,
") (blue) vs negative binomial(mu=", munb,
", size=", k, ") (green)", sep=""),
names.arg = as.character(x))
Run the code above in your browser using DataLab