Skip to contents

[Experimental]

Calculates the density function for a mixture of beta-binomial distributions.

Usage

dbetabinomMix(x, m, par, weights, log = FALSE)

Arguments

x

(numeric):
number of successes.

m

(number):
number of trials.

par

(matrix):
the beta parameters matrix, with K rows and 2 columns, corresponding to the beta parameters of the K components.

weights

(numeric):
the mixture weights of the beta mixture prior of length K. Each element corresponds to the row of beta parameters in par.

log

(flag):
whether to return the log density value (not default).

Value

The (log) density values of the mixture of beta-binomial distributions at x.

Examples

dbetabinomMix(x = 2, m = 29, par = rbind(c(0.2, 0.4)), weights = 1)
#> [1] 0.04286893

dbetabinomMix(
  x = 2, m = 29, par = rbind(c(0.2, 0.4), c(1, 1)),
  weights = c(0.6, 0.4)
)
#> [1] 0.03905469
# x could be a vector
dbetabinomMix(
  x = 1:28, m = 29, par = rbind(c(0.2, 0.4), c(1, 1)),
  weights = c(0.6, 0.4)
)
#>  [1] 0.05528364 0.03905469 0.03262435 0.02913070 0.02692943 0.02541875
#>  [7] 0.02432428 0.02350253 0.02287111 0.02237947 0.02199510 0.02169642
#> [13] 0.02146890 0.02130287 0.02119218 0.02113354 0.02112613 0.02117171
#> [19] 0.02127484 0.02144381 0.02169209 0.02204123 0.02252632 0.02320728
#> [25] 0.02419467 0.02571821 0.02835573 0.03418074