rdirmn | R Documentation |
ddirmn
computes the log of the Dirichlet multinomial probability mass function.
rdirmn
generates Dirichlet multinomially distributed random number vectors.
rdirmn(n, size, alpha) ddirmn(Y, alpha)
n |
number of random vectors to generate. When |
size |
a number or vector specifying the total number of objects that are put into d categories in the Dirichlet multinomial distribution. |
alpha |
the parameter of the Dirichlet multinomial distribution. Can be a numerical positive vector or matrix.
For For |
Y |
The multivariate count matrix with dimensions nxd, where n = 1,2, … is the number of observations and d=2,3, … is the number of categories. |
When the multivariate count data exhibits over-dispersion, the traditional multinomial model is insufficient. Dirichlet multinomial distribution models the probabilities of the categories by a Dirichlet distribution. Given the parameter vector α = (α_1, …, α_d), α_j>0 , the probability mass of d-category count vector Y=(y_1, …, y_d), d ≥ 2 under Dirichlet multinomial distribution is
P(y|α) = C_{y_1, …, y_d}^{m} prod_{j=1}^d {Gamma(α_j+y_j)Gamma(sum_{j'=1}^d α_j')} / {Gamma(α_j)Gamma(sum_{j'=1}^d α_j' + sum_{j'=1}^d y_j')},
where m = sum_{j=1}^d y_j. Here, C_k^n, often read as "n choose k", refers the number of k combinations from a set of n elements.
The parameter α can be a vector of length d, such as the results from the distribution fitting. α can also be a matrix with n rows, such as the inverse link calculated from the regression parameter estimate exp(Xβ).
For each count vector and each corresponding parameter vector
α, the function ddirmn
returns the value logP(y|α).
When Y
is a matrix of n rows, ddirmn
returns a vector of length n.
rdirmn
returns a nxd matrix of the generated random observations.
m <- 20 alpha <- c(0.1, 0.2) dm.Y <- rdirmn(n=10, m, alpha) pdfln <- ddirmn(dm.Y, alpha)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.