rmn {MGLM} | R Documentation |
The Multinomial Distribution
Description
rmn
generates random number vectors given alpha
.
The function rmn(n, size, alpha)
calls rmultinom(n, size, prob)
after converting alpha
to probability.
dmn
computes the log of multinomial probability mass function.
Usage
rmn(n, size, alpha)
dmn(Y, prob)
Arguments
n |
number of random vectors to generate. |
size |
a scalar or a vector. |
alpha |
a vector or a matrix. |
Y |
the multivariate count matrix with dimension |
prob |
the probability parameter of the multinomial distribution. |
Details
A multinomial distribution models the counts of possible outcomes.
The counts of categories are negatively correlated.
is a
category count vector.
Given the parameter vector
,
,
, the function calculates the log of the multinomial pmf
where . Here,
, often read as "
choose
",
refers the number of
combinations from a set of
elements.
The parameter can be one vector, like the result from the distribution
fitting function; or,
can be a matrix with
rows, like the estimate
from the regression function,
where
and
.
The
-th column of the coefficient matrix
is set to
to avoid the identifiability issue.
Value
The function dmn
returns the value of .
When
Y
is a matrix of rows, the function returns a
vector of length
.
The function rmn
returns multinomially distributed random number vectors
Author(s)
Yiwen Zhang and Hua Zhou
Examples
m <- 20
prob <- c(0.1, 0.2)
dm.Y <- rdirmn(n=10, m, prob)
pdfln <- dmn(dm.Y, prob)