rposnegbin {VGAM}R Documentation

Positive-negative binomial distribution random variates

Description

Generate random variates from a positive-negative binomial distribution.

Usage

rposnegbin(n, munb, k)

Arguments

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.

Details

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.

Value

n random deviates are returned.

Note

The running time is slow when munb is very close to zero.

Author(s)

T. W. Yee

References

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.

See Also

rnbinom, posnegbinomial, zanegbinomial.

Examples

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

[Package VGAM version 0.7-7 Index]