oiposbinomUC: One-Inflated Positive Binomial Distribution

OiposbinomR Documentation

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?

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.

Value

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

Note

The argument pstr1 is recycled to the required length, and usually has values which lie in the interval [0,1]. These functions actually allow for the zero-deflated binomial distribution. Here, pstr1 is also permitted to lie in the interval [-A, 0] for some positive quantity A. The resulting probability of a unit value is less than the nominal positive binomial value, and the use of pstr1 to stand for the probability of a structural 1 loses its meaning. If pstr1 equals A then this corresponds to the 0- and 1-truncated binomial distribution.

Author(s)

T. W. Yee

See Also

posbinomial, dbinom, binomialff.

Examples

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)  # 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 = paste0("OIPB(", size, ",", prob, ", pstr1 = ", pstr1,
     ") (blue) vs PosBinomial(", size, ",", prob, ") (orange)"),
   names.arg = as.character(x))

# Zero-deflated Pos Binomial:
def.limit <- -dposbinom(1, size, prob) / (1 - dposbinom(1, size, prob))
def.limit <- size * prob / (1 + (size-1) * prob-1 / (1-prob)^(size-1))
newpstr1 <- round(def.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 = paste0("ODPB(", size, ",", prob, ", pstr1 = ", newpstr1,
      ") (blue) vs PosBinomial(", size, ",", prob, ") (orange)"),
   names.arg = as.character(x)) 
## End(Not run)

VGAMdata documentation built on Sept. 17, 2024, 9:09 a.m.