| dirmult | R Documentation |
Density and and random generation for the Dirichlet-multinomial distribution.
ddirmult(x, size, alpha, log = FALSE)
rdirmult(n, size, alpha)
x |
vector or matrix of non-negative counts, where rows are observations and columns are categories. |
size |
vector of total counts for each observation. Needs to match the row sums of |
alpha |
vector or matrix of positive shape parameters |
log |
logical; if |
n |
number of random values to return. |
This implementation of ddirmult allows for automatic differentiation with RTMB.
ddirmult gives the density and rdirmult generates random samples.
# single alpha
alpha <- c(1,2,3)
size <- 10
x <- rdirmult(1, size, alpha)
d <- ddirmult(x, size, alpha)
# vectorised over alpha and size
alpha <- rbind(alpha, 2*alpha)
size <- c(size, 3*size)
x <- rdirmult(2, size, alpha)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.