Oiposbinom | R Documentation |
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)
x , p , q , n |
Same as |
size , prob |
Same as |
pstr1 |
Probability of a structural one
(i.e., ignoring the positive binomial distribution),
called |
log |
Logical. Return the logarithm of the answer? |
The probability function of Y
is 1 with probability
\phi
,
and PosBinomial(size, prob)
with probability 1-\phi
. Thus
P(Y=1) =\phi + (1-\phi) P(W=1)
where W
is distributed as a
positive binomial(size, prob)
random variable.
doiposbinom
gives the density,
poiposbinom
gives the distribution function,
qoiposbinom
gives the quantile function, and
roiposbinom
generates random deviates.
The argument pstr1
is recycled to the required length,
and usually has values which lie in the interval [0,1]
.
These functions actually allow for the zero-deflated
binomial distribution. Here, pstr1
is also permitted
to lie in the interval [-A, 0]
for some positive
quantity A
. The
resulting probability of a unit value is less than
the nominal positive binomial value, and the use of pstr1
to stand for the probability of a structural 1 loses its
meaning.
If pstr1
equals A
then this corresponds to the 0- and 1-truncated binomial
distribution.
T. W. Yee
posbinomial
,
dbinom
,
binomialff
.
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) # 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 = paste0("OIPB(", size, ",", prob, ", pstr1 = ", pstr1,
") (blue) vs PosBinomial(", size, ",", prob, ") (orange)"),
names.arg = as.character(x))
# Zero-deflated Pos Binomial:
def.limit <- -dposbinom(1, size, prob) / (1 - dposbinom(1, size, prob))
def.limit <- size * prob / (1 + (size-1) * prob-1 / (1-prob)^(size-1))
newpstr1 <- round(def.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 = paste0("ODPB(", size, ",", prob, ", pstr1 = ", newpstr1,
") (blue) vs PosBinomial(", size, ",", prob, ") (orange)"),
names.arg = as.character(x))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.