dzibinom: Zero-inflated binomial probability density

View source: R/distributions.r

dzibinomR Documentation

Zero-inflated binomial probability density

Description

Functions for computing density and producing random samples from a zero-inflated binomial probability distribution.

Usage

dzibinom( x , p_zero , size , prob , log=FALSE )
rzibinom( n , p_zero , size , prob )

Arguments

x

Integer values to compute densities or probabilies of

p_zero

Probability of a zero from bernoulli process

size

Number of binomial trials

prob

Probability of success in binomial trial

log

If TRUE, returns log-probability instead of probability

Details

These functions provide density and random number calculations for zero-inflated binomial observations. This distribution is defined as a finite mixture of zeros and binomial values, where p_zero determines the weight of the pure zeros. As such, the probability of a zero is p_zero + (1-p_zero)(1-prob)^size. And the probability of a non-zero value x is (1-p_zero) choose(size,x) prob^x (1-prob)^(size-x).

dzibinom does its calculations in a way meant to reduce numerical issues with probabilities close to 0 and 1. As a result, it's not very fast.

Author(s)

Richard McElreath


rmcelreath/rethinking documentation built on Aug. 26, 2024, 5:54 p.m.