Last chance! 50% off unlimited learning
Sale ends in
Density,
distribution function,
quantile function and random generation
for the one-inflated positive
binomial distribution with parameter pstr1
.
doiposbinom(x, size, prob, pstr1 = 0, log = FALSE)
poiposbinom(q, size, prob, pstr1 = 0)
qoiposbinom(p, size, prob, pstr1 = 0)
roiposbinom(n, size, prob, pstr1 = 0)
Same as Posbinom
.
Same as Posbinom
.
Probability of a structural one
(i.e., ignoring the positive binomial distribution),
called pstr1
can also be negative, in which case it
ceases its interpretation as a probability, and this is known
as one-deflation.
Logical. Return the logarithm of the answer?
doiposbinom
gives the density,
poiposbinom
gives the distribution function,
qoiposbinom
gives the quantile function, and
roiposbinom
generates random deviates.
The probability function of
# NOT RUN {
size <- 10; prob <- 0.2; pstr1 <- 0.4; x <- (-1):size
(ii <- doiposbinom(x, size, prob, pstr1 = pstr1))
table(roiposbinom(100, size, prob, pstr1 = pstr1))
round(doiposbinom(x , size, prob, pstr1 = pstr1) * 100) # Should be similar
# }
# NOT RUN {
x <- 0:size
par(mfrow = c(2, 1)) # One-Inflated Positive Binomial
barplot(rbind(doiposbinom(x, size, prob, pstr1 = pstr1),
dposbinom(x, size, prob)),
beside = TRUE, col = c("blue", "orange"),
main = paste("OIPB(", size, ",", prob, ", pstr1 = ", pstr1, ") (blue) vs",
" PosBinomial(", size, ",", prob, ") (orange)", sep = ""),
names.arg = as.character(x))
# Zero-deflated Pos Binomial
deflat.limit <- -dposbinom(1, size, prob) / (1 - dposbinom(1, size, prob))
deflat.limit <- size * prob / (1 + (size-1) * prob - 1 / (1-prob)^(size-1))
newpstr1 <- round(deflat.limit, 3) + 0.001 # A little from the boundary
barplot(rbind(doiposbinom(x, size, prob, pstr1 = newpstr1),
dposbinom(x, size, prob)),
beside = TRUE, col = c("blue","orange"),
main = paste("ODPB(", size, ",", prob, ", pstr1 = ", newpstr1, ") (blue) vs",
" PosBinomial(", size, ",", prob, ") (orange)", sep = ""),
names.arg = as.character(x))
# }
Run the code above in your browser using DataLab