rposnegbin {VGAM} | R Documentation |
Generate random variates from a positive-negative binomial distribution.
rposnegbin(n, munb, k)
n |
number of random values to return.
|
munb |
vector of positive means (of an ordinary negative binomial distribution).
|
k |
vector of positive index parameters (of an ordinary negative binomial distribution).
This is called the size argument in
rnbinom .
Short vectors are recycled. The parameter 1/k is known as a dispersion parameter;
as k approaches infinity, the negative binomial distribution
approaches a Poisson distribution.
|
The positive-negative binomial distribution is a negative binomial distribution but with the probability of a zero being zero. The other probabilities are scaled to add to unity. The mean therefore is
munb / (1-p(0))
where munb the mean of an ordinary negative binomial distribution.
The arguments of the function are fed into
rnbinom
until n positive values
are obtained.
n random deviates are returned.
The running time is slow when munb
is very close to zero.
T. W. Yee
Welsh, A. H., Cunningham, R. B., Donnelly, C. F. and Lindenmayer, D. B. (1996) Modelling the abundances of rare species: statistical models for counts with extra zeros. Ecological Modelling, 88, 297–308.
rnbinom
,
posnegbinomial
,
zanegbinomial
.
munb = 2; k = 4; n = 1000 y = rposnegbin(n, munb=munb, k=k) table(y) mean(y) # sample mean munb / (1 - (k/(k+munb))^k) # population mean