Learn R Programming

VGAM (version 1.0-3)

Oipospois: One-Inflated Positive Poisson Distribution

Description

Density, distribution function, quantile function and random generation for the one-inflated positive Poisson distribution with parameter pstr1.

Usage

doipospois(x, lambda, pstr1 = 0, log = FALSE)
poipospois(q, lambda, pstr1 = 0)
qoipospois(p, lambda, pstr1 = 0)
roipospois(n, lambda, pstr1 = 0)

Arguments

x, p, q, n

Same as Pospois.

lambda

Vector of positive means.

pstr1

Probability of a structural one (i.e., ignoring the positive Poisson distribution), called \(\phi\). The default value of \(\phi = 0\) corresponds to the response having a positive Poisson distribution.

log

Logical. Return the logarithm of the answer?

Value

doipospois gives the density, poipospois gives the distribution function, qoipospois gives the quantile function, and roipospois generates random deviates.

Details

The probability function of \(Y\) is 1 with probability \(\phi\), and \(PosPoisson(\lambda)\) with probability \(1-\phi\). Thus $$P(Y=1) =\phi + (1-\phi) P(W=1)$$ where \(W\) is distributed as a positive \(Poisson(\lambda)\) random variate.

See Also

Pospois, oapospoisson, oipospoisson, otpospoisson, pospoisson, dpois, poissonff.

Examples

Run this code
# NOT RUN {
lambda <- 3; pstr1 <- 0.2; x <- (-1):7
(ii <- doipospois(x, lambda, pstr1 = pstr1))
table(roipospois(100, lambda, pstr1 = pstr1))
round(doipospois(1:10, lambda, pstr1 = pstr1) * 100)  # Should be similar

# }
# NOT RUN {
 x <- 0:10
par(mfrow = c(2, 1))  # One-Inflated Positive Poisson
barplot(rbind(doipospois(x, lambda, pstr1 = pstr1), dpospois(x, lambda)),
        beside = TRUE, col = c("blue", "orange"),
        main = paste("OIPP(", lambda, ", pstr1 = ", pstr1, ") (blue) vs",
                     " PosPoisson(", lambda, ") (orange)", sep = ""),
        names.arg = as.character(x))

deflat.limit <- -lambda / (expm1(lambda) - lambda)  # 0-deflated Pos Poisson
newpstr1 <- round(deflat.limit, 3) + 0.001  # Inside and near the boundary
barplot(rbind(doipospois(x, lambda, pstr1 = newpstr1),
                dpospois(x, lambda)),
        beside = TRUE, col = c("blue","orange"),
        main = paste("ODPP(", lambda, ", pstr1 = ", newpstr1, ") (blue) vs",
                     " PosPoisson(", lambda, ") (orange)", sep = ""),
        names.arg = as.character(x)) 
# }

Run the code above in your browser using DataLab