Last chance! 50% off unlimited learning
Sale ends in
Density, distribution function, quantile function and random
generation for the zero-altered Poisson distribution with
parameter pobs0
.
dzapois(x, lambda, pobs0 = 0, log = FALSE)
pzapois(q, lambda, pobs0 = 0)
qzapois(p, lambda, pobs0 = 0)
rzapois(n, lambda, pobs0 = 0)
dzapois
gives the density,
pzapois
gives the distribution function,
qzapois
gives the quantile function, and
rzapois
generates random deviates.
vector of quantiles.
vector of probabilities.
number of observations.
If length(n) > 1
then the length is taken to be the
number required.
Vector of positive means.
Probability of zero, called pobs0 = 0
corresponds
to the response having a positive Poisson distribution.
Logical. Return the logarithm of the answer?
T. W. Yee
The probability function of pobs0
, else a positive
zapoisson
,
Gaitdpois
,
dzipois
.
lambda <- 3; pobs0 <- 0.2; x <- (-1):7
(ii <- dzapois(x, lambda, pobs0))
max(abs(cumsum(ii) - pzapois(x, lambda, pobs0))) # Should be 0
table(rzapois(100, lambda, pobs0))
table(qzapois(runif(100), lambda, pobs0))
round(dzapois(0:10, lambda, pobs0) * 100) # Should be similar
if (FALSE) x <- 0:10
barplot(rbind(dzapois(x, lambda, pobs0), dpois(x, lambda)),
beside = TRUE, col = c("blue", "green"), las = 1,
main = paste0("ZAP(", lambda, ", pobs0 = ", pobs0, ") [blue]",
"vs Poisson(", lambda, ") [green] densities"),
names.arg = as.character(x), ylab = "Probability")
Run the code above in your browser using DataLab