Multinom {joker} | R Documentation |
Multinomial Distribution
Description
The multinomial distribution is a discrete probability distribution which models the probability of having x successes in n independent categorical trials with success probability vector p.
Usage
Multinom(size = 1, prob = c(0.5, 0.5))
## S4 method for signature 'Multinom,numeric'
d(distr, x, log = FALSE)
## S4 method for signature 'Multinom,numeric'
r(distr, n)
## S4 method for signature 'Multinom'
mean(x)
## S4 method for signature 'Multinom'
mode(x)
## S4 method for signature 'Multinom'
var(x)
## S4 method for signature 'Multinom'
entro(x)
## S4 method for signature 'Multinom'
finf(x)
llmultinom(x, size, prob)
## S4 method for signature 'Multinom,matrix'
ll(distr, x)
emultinom(x, type = "mle", ...)
## S4 method for signature 'Multinom,matrix'
mle(distr, x, na.rm = FALSE)
## S4 method for signature 'Multinom,matrix'
me(distr, x, na.rm = FALSE)
vmultinom(size, prob, type = "mle")
## S4 method for signature 'Multinom'
avar_mle(distr)
## S4 method for signature 'Multinom'
avar_me(distr)
Arguments
size |
number of trials (zero or more). |
prob |
numeric. Probability of success on each trial. |
distr |
an object of class |
x |
For the density function, |
log |
logical. Should the logarithm of the probability be returned? |
n |
number of observations. If |
type |
character, case ignored. The estimator type (mle or me). |
... |
extra arguments. |
na.rm |
logical. Should the |
Details
The probability mass function (PMF) of the Multinomial distribution is:
P(X_1 = x_1, ..., X_k = x_k) = \frac{n!}{x_1! x_2! ... x_k!}
\prod_{i=1}^k p_i^{x_i},
subject to \sum_{i=1}^{k} x_i = n
.
Value
Each type of function returns a different type of object:
Distribution Functions: When supplied with one argument (
distr
), thed()
,p()
,q()
,r()
,ll()
functions return the density, cumulative probability, quantile, random sample generator, and log-likelihood functions, respectively. When supplied with both arguments (distr
andx
), they evaluate the aforementioned functions directly.Moments: Returns a numeric, either vector or matrix depending on the moment and the distribution. The
moments()
function returns a list with all the available methods.Estimation: Returns a list, the estimators of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.
Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.
See Also
Functions from the stats
package: dmultinom()
, rmultinom()
Examples
# -----------------------------------------------------
# Multinomial Distribution Example
# -----------------------------------------------------
# Create the distribution
N <- 10 ; p <- c(0.1, 0.2, 0.7)
D <- Multinom(N, p)
# ------------------
# dpqr Functions
# ------------------
d(D, c(2, 3, 5)) # density function
# alternative way to use the function
df <- d(D) ; df(c(2, 3, 5)) # df is a function itself
x <- r(D, 100) # random generator function
# ------------------
# Moments
# ------------------
mean(D) # Expectation
mode(D) # Mode
var(D) # Variance
entro(D) # Entropy
finf(D) # Fisher Information Matrix
# List of all available moments
mom <- moments(D)
mom$mean # expectation
# ------------------
# Point Estimation
# ------------------
ll(D, x)
llmultinom(x, N, p)
emultinom(x, type = "mle")
emultinom(x, type = "me")
mle(D, x)
me(D, x)
e(D, x, type = "mle")
mle("multinom", x) # the distr argument can be a character
# ------------------
# Estimator Variance
# ------------------
vmultinom(N, p, type = "mle")
vmultinom(N, p, type = "me")
avar_mle(D)
avar_me(D)
v(D, type = "mle")