Learn R Programming

VGAM (version 1.1-1)

Genapois: Generally-Altered Poisson Distribution

Description

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

Usage

dgenapois(x, lambda, alter = 0, pobs.a = 0, byrow.arg = FALSE, log = FALSE)
pgenapois(q, lambda, alter = 0, pobs.a = 0, byrow.arg = FALSE)
rgenapois(n, lambda, alter = 0, pobs.a = 0, byrow.arg = FALSE,
          maxits = 10000)

Arguments

x, q, n, log

Same type of argument as in rpois.

lambda

vector of positive means (of an ordinary Poisson 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

The first argument can be a length(alter)-vector of probabilities; else a matrix of dimension n x length(alter) of probabilities (whose enumeration is determined by byrow.arg). Regardless, it is made into a matrix of dimension n x (length(alter) + 1) of probabilities whose rowSums are a vector of 1s. Then a multinomial sample is taken and if it belongs to the final column then generally-truncated Poisson random variates are drawn.

maxits

Fed into rgentpois.

Value

dgenapois gives the density, pgenapois gives the distribution function, rgenapois generates random deviates.

Warning

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

Details

The generally-altered Poisson distribution is a Poisson 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 Poisson distribution. Since alter = 0 and pobs.a = 0 then the default is a 0-truncated (positive) Poisson distribution.

See Also

genapoisson, Genipois, Gentpois, dpospois, rpois.

Examples

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

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

Run the code above in your browser using DataLab