dbnb: Probability density function of the BNB distribution

Description Usage Arguments Details Value References Examples

View source: R/utils.R

Description

Evaluates the probability density function of the beta-negative-binomial (BNB) distribution with a mean parameter and two shape parameters.

Usage

1
dbnb(x, mu, a, b, log = FALSE)

Arguments

x

vector of quantiles.

mu

mean parameter.

a

1st shape parameter.

b

2nd shape parameter.

log

logical; if TRUE, density values p are given as log(p).

Details

The BNB distribution has density

f(x) = (Γ(μ + x) B(μ + a, x + b)) / (Gamma(μ) Gamma(x + 1) B(a, b)),

where μ is the mean parameter and a and b are the first and second shape parameter.

Value

Numeric vector of density values.

References

Frühwirth-Schnatter, S., Malsiner-Walli, G., and Grün, B. (2020) Generalized mixtures of finite mixtures and telescoping sampling https://arxiv.org/abs/2005.09918

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Similar to other d+DISTRIBUTION_NAME functions such as dnorm, it
## evaluates the density of a distribution (in this case the BNB distri)
## at point x
##
## Let's try with the density of x = 1 for BNB(1,4,3)
x <- 1
dbnb(x, mu = 1, a = 4, b = 3)

## The primary use of this function is in the closures returned from
## fipp() or nCluststers() as a prior on K-1
pmf <- nClusters(Kplus = 1:15, N = 100, type = "static",
gamma = 1, maxK = 150)

## Now evaluate above when K-1 ~ BNB(1,4,3)
pmf(priorK = dbnb, priorKparams = list(mu = 1, a = 4, b = 3))

## Compare the result with the case when K-1 ~ Pois(1)
pmf(priorK = dpois, priorKparams = list(lambda = 1))

## Although both BNB(1,4,3) and Pois(1) have 1 as their mean, the former
## has a fatter rhs tail. We see that it is reflected in the induced prior 
## on K+ as well

fipp documentation built on Feb. 11, 2021, 5:07 p.m.