Learn R Programming

nmfem (version 1.0.5)

loglik_mult: Extract log-likelihood from a mixture of multinomials

Description

Extract log-likelihood from a mixture of multinomials

Usage

loglik_mult(X, Theta, Lambda = NULL, p)

Arguments

X

a matrix of dimension N (number of observation) x M (number of variables) containing multinomials observations.

Theta

matrix of dimension M x H.

Lambda

matrix of dimension H x K. Can be NULL.

p

vector containing the proportions of each cluster. Must be of dimension K (or H if Lambda is NULL).

Value

The function returns the log-likelihood of the data to the model

Examples

Run this code
# NOT RUN {
travelers <- travelers[ ,-1]
M <- ncol(travelers)
K <- 5

Theta0    <- t(dplyr::sample_n(travelers, K))
Theta0    <- Theta0 / matrix(rep(apply(Theta0, 2, sum), M), nrow = M, ncol = K, byrow = TRUE)
travelers <- as.matrix(travelers)
p0        <- rep(1 / K, K)

llh <- loglik_mult(travelers, Theta0, p = p0)
llh

# }

Run the code above in your browser using DataLab