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 Multinom.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Multinom. For the log-likelihood and the estimation functions, x is the sample of observations.

log

logical. Should the logarithm of the probability be returned?

n

number of observations. If length(n) > 1, the length is taken to be the number required.

type

character, case ignored. The estimator type (mle or me).

...

extra arguments.

na.rm

logical. Should the NA values be removed?

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:

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")

[Package joker version 0.14.2 Index]