Description Usage Arguments Details Author(s) See Also Examples
dBetaBinom
and dBetaBinom_One
provide a beta binomial
distribution that can be used directly from R or in nimble
models. These are also used by beta binomial variations of dNmixture distributions.
nimBetaFun
is the beta function.
1 2 3 4 5 6 7 8 9  nimBetaFun(a, b, log)
dBetaBinom(x, N, shape1, shape2, log = 0)
dBetaBinom_One(x, N, shape1, shape2, log = 0)
rBetaBinom(n, N, shape1, shape2)
rBetaBinom_One(n, N, shape1, shape2)

a 
shape1 argument of the beta function nimBetaFun. 
b 
shape2 argument of the beta function nimBetaFun. 
log 
TRUE or 1 to return log probability. FALSE or 0 to return probability. 
x 
vector of integer counts. 
N 
number of trials, sometimes called "size". 
shape1 
shape1 parameter of the betabinomial distribution. 
shape2 
shape2 parameter of the betabinomial distribution. 
n 
number of random draws, each returning a vector of length

These nimbleFunctions provide distributions that can be
used directly in R or in nimble
hierarchical models (via
nimbleCode
and
nimbleModel
). They were originally written for
the beta binomial Nmixture extensions.
The beta binomial distribution is equivalent to a binomial distribution whose probability is itself a beta distributed random variable.
The probability mass function of the beta binomial is
choose(N, x) * B(x + shape1, N  x + shape2) /
B(shape1, shape2)
, where B(shape1, shape2)
is the beta function.
The beta binomial distribution is provided in two forms. dBetaBinom
and
rBetaBinom
are used when x
is a vector (i.e. length(x) > 1
),
in which case the parameters alpha
and beta
must also be vectors.
When x
is scalar, dBetaBinom_One
and rBetaBinom_One
are
used.
Ben Goldstein and Perry de Valpine
For beta binomial Nmixture models, see dNmixture
.
For documentation on the beta function, use ?stats::dbeta
1 2 3 4 5  # Calculate a beta binomial probability
dBetaBinom(x = c(4, 0, 0, 3), N = 10,
shape1 = c(0.5, 0.5, 0.3, 0.5), shape2 = c(0.2, 0.4, 1, 1.2))
# Same for case with one observation
dBetaBinom_One(x = 3, N = 10, shape1 = 0.5, shape2 = 0.5, log = TRUE)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.