pmultinom
is a library for calculating multinomial probabilities.
To install from CRAN:
install.packages("pmultinom")
The probabilities that can be calculated include the multinomial cumulative distribution function:
pmultinom(upper=us, size=n, probs=ps, method="exact")
where us
is the vector containing n
and ps
are the parameters of the multinomial distribution. This usage is analogous to the use of pbinom
. Another important case is the probability of seeing more than some minimum number of observations in each category:
pmultinom(lower=ls, size=n, probs=ps, method="exact")
where this time ls
is the vector containing pbinom
with lower.tail=FALSE
. With some creativity, these can be adapted to calculate the probability that the maximum or minimum of a multinomial random vector is a given number, or that a given category will be the most or least observed. pmultinom
also supports a more general usage, in which both lower and upper bounds are specified:
pmultinom(lower=ls, upper=us, size=n, probs=ps, method="exact")
See vignette("pmultinom")
for the above text in Latex plus an example application. Many thanks to Aislyn Schalck for advice and encouragement.