genpois0UC: Generalized Poisson Distribution (Original Parameterization)

Genpois0R Documentation

Generalized Poisson Distribution (Original Parameterization)

Description

Density, distribution function, quantile function and random generation for the original parameterization of the generalized Poisson distribution.

Usage

dgenpois0(x, theta, lambda = 0, log = FALSE)
pgenpois0(q, theta, lambda = 0, lower.tail = TRUE)
qgenpois0(p, theta, lambda = 0)
rgenpois0(n, theta, lambda = 0, algorithm = c("qgenpois0",
          "inv", "bup","chdn", "napp", "bran"))

Arguments

x, q

Vector of quantiles.

p

Vector of probabilities.

n

Similar to runif.

theta, lambda

See genpoisson0. The default value of lambda corresponds to an ordinary Poisson distribution. Nonnegative values of lambda are currently required.

lower.tail, log

Similar to Poisson.

algorithm

Character. Six choices are available, standing for the qgenpois0, inversion, build-up, chop-down, normal approximation and branching methods. The first one is the default and calls qgenpois0 with runif as its first argument. The value inputted may be abbreviated, e.g., alg = "n". The last 5 algorithms are a direct implementation of Demirtas (2017) and the relative performance of the algorithms are described there—however, the vectorization here may render the comments on relative speed as no longer holding.

Details

Most of the background to these functions are given in genpoisson0. Some warnings relevant to this distribution are given there. The complicated range of the parameter lambda when negative is no longer supported because the distribution is not normalized. For other GPD variants see Genpois1.

Value

dgenpois0 gives the density, pgenpois0 gives the distribution function, qgenpois0 gives the quantile function, and rgenpois generates random deviates. For some of these functions such as dgenpois0 and pgenpois0 the value NaN is returned for elements not satisfying the parameter restrictions, e.g., if \lambda > 1. For some of these functions such as rgenpois0 the input must not contain NAs or NaNs, etc. since the implemented algorithms are fragile.

Warning

These have not been tested thoroughly.

For pgentpois0() mapply is called with 0:q as input, hence will be very slow and memory-hungry for large values of q. Likewise qgentpois0() and rgentpois0() may suffer from the same limitations.

Note

For rgentpois0(): (1). "inv", "bup" and "chdn" appear similar and seem to work okay. (2). "napp" works only when theta is large, away from 0. It suffers from 0-inflation. (3). "bran" has a relatively heavy RHS tail and requires positive lambda. More details can be found in Famoye (1997) and Demirtas (2017).

The function dgenpois0 uses lfactorial, which equals Inf when x is approximately 1e306 on many machines. So the density is returned as 0 in very extreme cases; see .Machine.

Author(s)

T. W. Yee. For rgenpois0() the last 5 algorithms are based on code written in H. Demirtas (2017) and vectorized by T. W. Yee; but the "bran" algorithm was rewritten from Famoye (1997).

References

Demirtas, H. (2017). On accurate and precise generation of generalized Poisson variates. Communications in Statistics—Simulation and Computation, 46, 489–499.

Famoye, F. (1997). Generalized Poisson random variate generation. Amer. J. Mathematical and Management Sciences, 17, 219–237.

See Also

genpoisson0, Genpois1, dpois.

Examples

sum(dgenpois0(0:1000, theta = 2, lambda = 0.5))
## Not run: theta <- 2; lambda <- 0.2; y <- 0:10
proby <- dgenpois0(y, theta = theta, lambda = lambda, log = FALSE)
plot(y, proby, type = "h", col = "blue", lwd = 2, ylab = "Pr(Y=y)",
     main = paste0("Y ~ GP-0(theta=", theta, ", lambda=",
                   lambda, ")"), las = 1, ylim = c(0, 0.3),
     sub = "Orange is the Poisson probability function")
lines(y + 0.1, dpois(y, theta), type = "h", lwd = 2, col = "orange") 
## End(Not run)

VGAM documentation built on Sept. 18, 2024, 9:09 a.m.