Learn R Programming

VGAM (version 1.1-1)

Genabinom: Generally-Altered Binomial Distribution

Description

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

Usage

dgenabinom(x, size, prob, alter = 0, pobs.a = 0, byrow.arg = FALSE,
           log = FALSE)
pgenabinom(q, size, prob, alter = 0, pobs.a = 0, byrow.arg = FALSE)
rgenabinom(n, size, prob, alter = 0, pobs.a = 0, byrow.arg = FALSE,
          maxits = 10000)

Arguments

x, q, n, log

Same type of argument as in rbinom.

size, prob

vector of positive means (of an ordinary binomial distribution). Short vectors are recycled.

alter

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

pobs.a, byrow.arg

Same as pgenapois.

maxits

Fed into rgentbinom.

Value

dgenabinom gives the density, pgenabinom gives the distribution function, rgenabinom generates random deviates.

Warning

See rgentbinom. The function can run slowly for certain combinations of pobs.a and alter, e.g., rgenabinom(1e5, 10, 0.1, alter=0:9, pobs.a = seq(10)/56, byrow=TRUE). Failure to obtain random variates will result in some NA values instead.

Details

The generally-altered binomial distribution is a binomial distribution with the probability of certain (altered) values having some prespecified probabilities. It can be considered a mixture of a multinomial distribution and a generally-truncated binomial distribution. Since alter = 0 and pobs.a = 0 then the default is a 0-truncated (positive) binomial distribution.

See Also

Genibinom, Gentbinom, dposbinom, rbinom.

Examples

Run this code
# NOT RUN {
avec <- 2:4  # Alter these values
pobs.a <- (1:3)/10; size <- 10; prob <- 0.5;
y <- rgenabinom(1000, size, prob, alter = avec,
                 pobs.a = pobs.a, byrow = TRUE)
table(y)
(ii <- dgenabinom(0:7, size, prob, alter = avec,
                  pobs.a = pobs.a, byrow = TRUE))
table(rgenabinom(100, size, prob, alter = avec,
                 pobs.a = pobs.a, byrow = TRUE))

# }
# NOT RUN {
 x <- 0:size
barplot(rbind(dgenabinom(x, size, prob, alter = avec, pobs.a = pobs.a,
                        byrow = TRUE),
              dbinom(x, size, prob)),
        beside = TRUE, col = c("blue", "orange"),
        main = paste("Gen-alt Binom(size = ", size, ", ",
                     "prob = ", prob, ", ",
                     "alter = c(", paste(avec, collapse = ","),
                     "), pobs.a = c(", paste(pobs.a, collapse = ","),
                     "), byrow = TRUE) vs",
        " Binom(", size, ", ", prob, ")", sep = ""),
        sub = "Generally-altered binomial is blue; binomial is orange",
        names.arg = as.character(x), las = 1, lwd = 2) 
# }

Run the code above in your browser using DataLab