Learn R Programming

VGAM (version 0.7-5)

rposnegbin: 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 param

Value

  • $n$ random deviates are returned.

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 $$\mu / (1-p(0))$$ where $\mu$ the mean of an ordinary negative binomial distribution. The arguments of the function are fed into rnbinom until $n$ positive values are obtained.

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

Run this code
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

Run the code above in your browser using DataLab