Learn R Programming

VGAM (version 1.0-5)

Oiposbinom: One-Inflated Positive Binomial Distribution

Description

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

Usage

doiposbinom(x, size, prob, pstr1 = 0, log = FALSE)
poiposbinom(q, size, prob, pstr1 = 0)
qoiposbinom(p, size, prob, pstr1 = 0)
roiposbinom(n, size, prob, pstr1 = 0)

Arguments

x, p, q, n

Same as Posbinom.

size, prob

Same as Posbinom.

pstr1

Probability of a structural one (i.e., ignoring the positive binomial distribution), called \(\phi\). The default value of \(\phi = 0\) corresponds to the response having a positive binomial distribution. However, pstr1 can also be negative, in which case it ceases its interpretation as a probability, and this is known as one-deflation.

log

Logical. Return the logarithm of the answer?

Value

doiposbinom gives the density, poiposbinom gives the distribution function, qoiposbinom gives the quantile function, and roiposbinom generates random deviates.

Details

The probability function of \(Y\) is 1 with probability \(\phi\), and \(PosBinomial(size, prob)\) with probability \(1-\phi\). Thus $$P(Y=1) =\phi + (1-\phi) P(W=1)$$ where \(W\) is distributed as a positive \(binomial(size, prob)\) random variable.

See Also

posbinomial, dbinom, binomialff.

Examples

Run this code
# NOT RUN {
size <- 10; prob <- 0.2; pstr1 <- 0.4; x <- (-1):size
(ii <- doiposbinom(x, size, prob, pstr1 = pstr1))
table(roiposbinom(100, size, prob, pstr1 = pstr1))
round(doiposbinom(x  , size, prob, pstr1 = pstr1) * 100)  # Should be similar

# }
# NOT RUN {
 x <- 0:size
par(mfrow = c(2, 1))  # One-Inflated Positive Binomial
barplot(rbind(doiposbinom(x, size, prob, pstr1 = pstr1),
              dposbinom(x, size, prob)),
        beside = TRUE, col = c("blue", "orange"),
        main = paste("OIPB(", size, ",", prob, ", pstr1 = ", pstr1, ") (blue) vs",
                     " PosBinomial(", size, ",", prob, ") (orange)", sep = ""),
        names.arg = as.character(x))

# Zero-deflated Pos Binomial
deflat.limit <- -dposbinom(1, size, prob) / (1 - dposbinom(1, size, prob))
deflat.limit <- size * prob / (1 + (size-1) * prob - 1 / (1-prob)^(size-1))
newpstr1 <- round(deflat.limit, 3) + 0.001  # A little from the boundary
barplot(rbind(doiposbinom(x, size, prob, pstr1 = newpstr1),
                dposbinom(x, size, prob)),
        beside = TRUE, col = c("blue","orange"),
        main = paste("ODPB(", size, ",", prob, ", pstr1 = ", newpstr1, ") (blue) vs",
                     " PosBinomial(", size, ",", prob, ") (orange)", sep = ""),
        names.arg = as.character(x)) 
# }

Run the code above in your browser using DataLab