Description Usage Arguments Details Value Examples
The multinomial log-likelihood, for predicted or fitted values. Requires the
predicted (or fitted) probability matrix p
, and one of the following: labels
,
indices
or indicator.matrix
. Preferably one of the two former.
1 |
p |
An n x K matrix of probabilities, where n is the number of observations, and K the number of mutually exclusive outcome categories. |
labels |
Vector of length n, containing the labels (character or factor) of
the observed outcome categories. If specified, must correspond with the column names
of |
indices |
Optional. A vector of length n, containing the indices k, k = 1,...,K,
of the observed outcome categories. If specified, these indices must corresond with
their respective indices in |
indicator.matrix |
Optional. An n x K matrix indicating the outcome category of
each observation, where n is the number of observations, and K the number of mutually
exclusive outcome categories. If specified, the order of the columns should correspond
with the order of the columns of |
names |
Optional. What are the |
na.rm |
logical. Should missing values (including NaN) be removed? |
The multinomial log-likelihood
mll
provides the multinomial log-likelihood.
1 2 3 4 5 6 7 8 9 10 11 | # When we observe 3 outcomes with indices 1, 2 and 3,
# we can obtain the log-likelihood of the null-model:
# by letting all observed probabilities equal 1/3:
probabilities <- matrix(1/3, nrow = 3, ncol = 3)
indices <- c(1,2,3)
mll(probabilities, indices = indices)
# If the outcome is measured as a factor, the levels need to correspond to colnames(p):
labels <- as.factor(indices)
colnames(probabilities) <- labels
mll(probabilities, labels)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.