Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

zibinomUC

Zero-Inflated Binomial Distribution


Description

Density, distribution function, quantile function and random generation for the zero-inflated binomial distribution with parameter pstr0.

Usage

dzibinom(x, size, prob, pstr0 = 0, log = FALSE)
pzibinom(q, size, prob, pstr0 = 0)
qzibinom(p, size, prob, pstr0 = 0)
rzibinom(n, size, prob, pstr0 = 0)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

size

number of trials. It is the N symbol in the formula given in zibinomial.

prob

probability of success on each trial.

n

Same as in runif.

log

Same as pbinom.

pstr0

Probability of a structural zero (i.e., ignoring the binomial distribution), called phi. The default value of phi=0 corresponds to the response having an ordinary binomial distribution.

Details

The probability function of Y is 0 with probability phi, and Binomial(size, prob) with probability 1-phi. Thus

P(Y=0) = phi + (1-phi) * P(W=0)

where W is distributed Binomial(size, prob).

Value

dzibinom gives the density, pzibinom gives the distribution function, qzibinom gives the quantile function, and rzibinom generates random deviates.

Note

The argument pstr0 is recycled to the required length, and must have values which lie in the interval [0,1].

These functions actually allow for zero-deflation. That is, the resulting probability of a zero count is less than the nominal value of the parent distribution. See Zipois for more information.

Author(s)

T. W. Yee

See Also

Examples

prob <- 0.2; size <- 10; pstr0 <- 0.5
(ii <- dzibinom(0:size, size, prob, pstr0 = pstr0))
max(abs(cumsum(ii) - pzibinom(0:size, size, prob, pstr0 = pstr0)))  # Should be 0
table(rzibinom(100, size, prob, pstr0 = pstr0))

table(qzibinom(runif(100), size, prob, pstr0 = pstr0))
round(dzibinom(0:10, size, prob, pstr0 = pstr0) * 100)  # Should be similar

## Not run:  x <- 0:size
barplot(rbind(dzibinom(x, size, prob, pstr0 = pstr0),
                dbinom(x, size, prob)),
        beside = TRUE, col = c("blue", "green"), ylab = "Probability",
        main = paste("ZIB(", size, ", ", prob, ", pstr0 = ", pstr0, ") (blue) vs",
                     " Binomial(", size, ", ", prob, ") (green)", sep=""),
        names.arg = as.character(x), las = 1, lwd = 2) 
## End(Not run)

VGAM

Vector Generalized Linear and Additive Models

v1.1-5
GPL-3
Authors
Thomas Yee [aut, cre], Cleve Moler [ctb] (author of several LINPACK routines)
Initial release
2021-01-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.