rdirmn {MGLM} | R Documentation |
The Dirichlet Multinomial Distribution
Description
ddirmn
computes the log of the Dirichlet multinomial probability mass function.
rdirmn
generates Dirichlet multinomially distributed random number vectors.
Usage
rdirmn(n, size, alpha)
ddirmn(Y, alpha)
Arguments
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 |
Details
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 ,
the probability mass of
-category count vector
,
under Dirichlet multinomial distribution is
where . Here,
, often read as "
choose
",
refers the number of
combinations from a set of
elements.
The parameter can be a vector of length
,
such as the results from the distribution fitting.
can also be a matrix with
rows, such as the inverse link
calculated from the regression parameter estimate
.
Value
For each count vector and each corresponding parameter vector
, the function
ddirmn
returns the value .
When
Y
is a matrix of rows,
ddirmn
returns a vector of length .
rdirmn
returns a matrix of the generated random observations.
Examples
m <- 20
alpha <- c(0.1, 0.2)
dm.Y <- rdirmn(n=10, m, alpha)
pdfln <- ddirmn(dm.Y, alpha)