FBB: The Flexible Beta-Binomial Distribution

dFBBR Documentation

The Flexible Beta-Binomial Distribution

Description

Mass function, distribution function, quantile function, and random generation for the flexible beta-binomial distribution.

Usage

dFBB(x, size, mu, theta = NULL, phi = NULL, p, w, log = FALSE)

qFBB(prob, size, mu, theta = NULL, phi = NULL, p, w, log.prob = FALSE)

pFBB(q, size, mu, theta = NULL, phi = NULL, p, w, log.prob = FALSE)

rFBB(n, size = NULL, mu, theta = NULL, phi = NULL, p, w)

Arguments

x, q

a vector of quantiles.

size

the total number of trials.

mu

the mean parameter. It must lie in (0, 1).

theta

the overdispersion parameter. It must lie in (0, 1).

phi

the precision parameter, an alternative way to specify the overdispersion parameter theta. It must be a real positive value.

p

the mixing weight. It must lie in (0, 1).

w

the normalized distance among component means. It must lie in (0, 1).

log

logical; if TRUE, probabilities are returned on log-scale.

prob

a vector of probabilities.

log.prob

logical; if TRUE, probabilities prob are given as log(prob).

n

the number of values to generate. If length(n) > 1, the length is taken to be the number required.

Details

The FBB distribution is a special mixture of two beta-binomial distributions with probability mass function

f_{FBB}(x;\mu,\phi,p,w) = p BB(x;\lambda_1,\phi)+(1-p)BB(x;\lambda_2,\phi),

for x \in \lbrace 0, 1, \dots, n \rbrace, where BB(x;\cdot,\cdot) is the beta-binomial distribution with a mean-precision parameterization. Moreover, \phi=(1-\theta)/\theta>0 is a precision parameter, 0<p<1 is the mixing weight, 0<\mu=p\lambda_1+(1-p)\lambda_2<1 is the overall mean, 0<w<1 is the normalized distance between component means, and \lambda_1=\mu+(1-p)w and \lambda_2=\mu-pw are the scaled means of the first and second component of the mixture, respectively.

Value

The function dFBB returns a vector with the same length as x containing the probability mass values. The function pFBB returns a vector with the same length as q containing the values of the distribution function. The function qFBB returns a vector with the same length as prob containing the quantiles. The function rFBB returns a vector of length n containing the generated random values.

References

Ascari, R., Migliorati, S. (2021). A new regression model for overdispersed binomial data accounting for outliers and an excess of zeros. Statistics in Medicine, 40(17), 3895–3914. doi:10.1002/sim.9005

Examples

dFBB(x = c(5,7,8), size=10, mu = .3, phi = 20, p = .5, w = .5)
dFBB(x = c(5,7,8), size=10, mu = .3, theta = 1/(20+1), p = .5, w = .5)

qFBB(prob = .5, size=10, mu = .3, phi = 20, p = .5, w = .5)
qFBB(prob = .5, size=10, mu = .3, theta = 1/(20+1), p = .5, w = .5)

pFBB(q = c(5,7,8), size=10, mu = .3, phi = 20, p = .5, w = .5)
pFBB(q = c(5,7,8), size=10, mu = .3, theta = 1/(20+1), p = .5, w = .5)

rFBB(n = 100, size = 40, mu = .5, phi = 5, p = .3, w = .6)
rFBB(n = 100, size = 40, mu = .5, theta = 1/(5+1), p = .3, w = .6)


FlexReg documentation built on Sept. 9, 2025, 5:49 p.m.