Learn R Programming

VGAM (version 1.1-1)

Genibinom: Generally-Inflated Binomial Distribution

Description

Density, distribution function, and random generation for the generally-inflated binomial distribution.

Usage

dgenibinom(x, size, prob, inflate = 0, pstr.i = 0, byrow.arg = FALSE,
          log.arg = FALSE)
pgenibinom(q, size, prob, inflate = 0, pstr.i = 0, byrow.arg = FALSE)
rgenibinom(n, size, prob, inflate = 0, pstr.i = 0, byrow.arg = FALSE)

Arguments

x, q, n, log.arg

Same type of argument as in rbinom.

size, prob

Same type of argument as in dbinom.

inflate

vector of nonnegative integers; the inflated values. Must have unique values only. A NULL is acceptable and means an empty set.

pstr.i, byrow.arg

Same as rgenipois.

Value

dgenibinom gives the density, pgenibinom gives the distribution function, rgenibinom generates random deviates.

Details

The generally-inflated binomial distribution is a mixture of an ordinary binomial distribution with a multinomial distribution. Certain (inflated) values having some prespecified multinomial probabilities can have structural values. Since inflate = 0 and pstr.i = 0 then the default is an ordinary binomial distribution.

See Also

Gentbinom, Genabinom, dposbinom, rbinom.

Examples

Run this code
# NOT RUN {
ivec <- c(2, 4)  # Inflate these values
pstr.i <- (1:2)/10; size <- 10; prob <- 0.5;
y <- rgenibinom(1000, size, prob, inflate = ivec, pstr.i = pstr.i,
                byrow = TRUE)
table(y)
(ii <- dgenibinom(0:11, size, prob, inflate = ivec, pstr.i = pstr.i,
                  byrow = TRUE))
table(rgenibinom(1000, size, prob, inflate = ivec,
                 pstr.i = pstr.i, byrow = TRUE))

# }
# NOT RUN {
 x <- 0:size
barplot(rbind(dgenibinom(x, size, prob, inflate = ivec,
                         pstr.i = pstr.i, byrow = TRUE),
              dbinom(x, size, prob)),
        beside = TRUE, col = c("blue", "orange"),
        main = paste("Gen-inf Binom(size = ", size, ", ",
                     "prob = ", prob, ", ",
                     "inflate = c(", paste(ivec, collapse = ","),
                     "), pstr.i = c(", paste(pstr.i, collapse = ","),
                     "), byrow = TRUE) vs",
        " Binom(", size, ", ", prob, ")", sep = ""),
        sub = "Generally-inflated binomial is blue; binomial is orange",
        names.arg = as.character(x), las = 1, lwd = 2) 
# }

Run the code above in your browser using DataLab