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