The log likelihood of a multinomial density with data, x, size and prob parameters.

likmultinom(size = NULL, prob, x, log = FALSE)

Arguments

size

integer, say \(N\), specifying the total number of objects that are put into \(K\) boxes in the typical multinomial experiment. For dmultinom, it defaults to sum(x).

prob

numeric non-negative vector of length \(K\), specifying the probability for the \(K\) classes; is internally normalized to sum 1. Infinite and missing values are not allowed.

x

vector of length \(K\) of integers in 0:size.

log

logical; if TRUE, log probabilities are computed.

Value

A numeric scalar for the log likelihood of the multinomial density given the data where size and prob can be held constant or if vector were given vector will be returned.

Details

The log likelihood is the log of a function of parameters given the data.

Examples

likmultinom(x = rmultinom(n = 2, size = 3, prob = .4), size = 3, prob = .4)
#> [1] 1