| Gaitnbinom.mix {VGAM} | R Documentation |
Density, distribution function, quantile function and random generation for the generally–altered, –inflated and –truncated negative binomial (NB) distribution, based on mixtures of NB distributions having different and/or nested support. This distribution is sometimes abbreviated as GAIT–NB–NB–NB.
dgaitnbinom.mix(x, size.p, prob.p = NULL, munb.p = NULL, alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p, prob.a = prob.p, prob.i = prob.p, munb.a = munb.p, munb.i = munb.p, log.arg = FALSE) pgaitnbinom.mix(q, size.p, prob.p = NULL, munb.p = NULL, alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p, prob.a = prob.p, prob.i = prob.p, munb.a = munb.p, munb.i = munb.p) qgaitnbinom.mix(p, size.p, prob.p = NULL, munb.p = NULL, alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p, prob.a = prob.p, prob.i = prob.p, munb.a = munb.p, munb.i = munb.p) rgaitnbinom.mix(n, size.p, prob.p = NULL, munb.p = NULL, alter = NULL, inflate = NULL, truncate = NULL, max.support = Inf, pobs.a = 0, pstr.i = 0, size.a = size.p, size.i = size.p, prob.a = prob.p, prob.i = prob.p, munb.a = munb.p, munb.i = munb.p)
x, p, q, n, log.arg |
Same meaning as in |
size.p, size.a, size.i |
Same meaning as |
prob.p, prob.a, prob.i |
Same meaning as |
munb.p, munb.a, munb.i |
Same meaning as |
alter, inflate, truncate |
See |
pobs.a, pstr.i |
See |
max.support |
Same as |
These functions will be combined soon.
See Gaitpois for parallel information.
This distribution may be suitable for heaped data whose parent
distribution is overdispersed with respect to the Poisson.
In the notation of Yee and Ma (2020)
these functions concern the GAIT–NB–NB–NB distribution.
For information on the GAIT–NB–MLM–MLM distribution
see Gaitnbinom.mlm.
dgaitnbinom.mix gives the density (PMF),
pgaitnbinom.mix gives the distribution function,
qgaitnbinom.mix gives the quantile function, and
rgaitnbinom.mix generates random deviates.
It is intended that the minimal defaults of these functions
are equivalent to NegBinomial,
e.g.,
dgaitnbinom.mix(x, size, munb.p = munb) and
dnbinom(x, size, mu = munb) should be identical, and
ditto for the other 3 functions.
T. W. Yee.
Gaitnbinom.mlm
for the GAIT–NB–MLM–MLM distribution,
NegBinomial.
ivec <- c(5, 15, 10); avec <- ivec; size = 10; munb <- 10
max.support <- 20; pobs.a <- 0.35; xvec <- 0:max.support
# GAT-NB-NB mixture
(pmf.a <- dgaitnbinom.mix(xvec, size.p = size, munb.p = munb,
max.support = max.support, pobs.a = pobs.a, alter = avec))
sum(pmf.a) # Should be 1
## Not run:
ind4 <- match(xvec, avec, nomatch = 0) > 0 # xvec %in% avec
plot(xvec[ ind4], pmf.a[ ind4], type = "h", col = "orange", lwd = 1.1,
las = 1, xlim = range(xvec), main = "GAT-NB-NB",
ylim = c(0, max(pmf.a)), xlab = "y", ylab = "Probability") # Spikes
lines(xvec[!ind4], pmf.a[!ind4], type = "h", col = "blue")
## End(Not run)
# GIT-NB-NB mixture
pstr.i <- 0.15
(pmf.i <- dgaitnbinom.mix(xvec, size.p = size, munb.p = munb,
max.support = max.support, pstr.i = pstr.i, inflate = ivec))
sum(pmf.i) # Should be 1
## Not run: # Plot the components of pmf.i
plot(xvec, (1 - pstr.i) * dnbinom(xvec, size, mu = munb), type = "h",
col = "blue", las = 1, xlim = range(xvec),
main = "GIT-NB-NB", # The inner distribution
ylim = c(0, max(pmf.i)), xlab = "y", ylab = "Probability")
spikes <- dnbinom(ivec, size, mu = munb) * pstr.i / sum(
dnbinom(ivec, size, mu = munb))
start.pt <- dnbinom(ivec, size, mu = munb) *
(1 - pstr.i) / pnbinom(max.support, size, mu = munb)
segments(ivec, start.pt, # The outer distribution
ivec, start.pt + spikes, col = "orange", lwd = 1.1)
## End(Not run)