em: EM function

Description Usage Arguments Value

View source: R/em.R

Description

Run EM for a multinomial mixture model on a sample x feature matrix. Take a matrix counts and classify the samples in each row into one of k clusters. The initial parameters of the multinomial mixture model must be given as a list in the parameter mn_params.

Usage

1
2
em(counts, k, mn_params, max_iter = 100, eps = 1e-08, psc = 1e-04,
  labels = NULL, verbose = TRUE)

Arguments

counts

observation by variable matrix of non-negative integer counts.

k

Number of clusters.

mn_params

A list containing

Mu

A variable by k matrix containing the means of the of the k multinomial distributions.

Mc

A numeric vector of mixture coefficients.

max_iter

A numeric value indivating the maximum number of iterations.

eps

The epsilon value, which is the convergence threshold of the percent change in the log likelihood.

psc

Pseudocount to add to the multinomial mean parameter to avoid the likelihood collapsing to 0.

labels

Numeric vector of same length as number of observations in counts. Fixes the group probabilities of the integer in this vector element to 1. In other words, the latent variable for these samples are treated as known.

verbose

verbosity.

Value

A list with

Z

An observation by cluster matrix of log log likelihoods. Each element is the log likelihood of that data point under the the k multinomial.

Mu

A variable by cluster matrix of multinomial parameters.

Mc

A numeric vector of mixture coefficients.

loglk

Data log likelihood.

converged

logical indicating whether the EM algorithm converged (TRUE) or reached the maximum number of iterations.


diem documentation built on Nov. 16, 2019, 1:08 a.m.