multinom_EM: An EM algorithm to fit a multinomial with maximum likelihood

View source: R/multinom_EM.R

multinom_EMR Documentation

An EM algorithm to fit a multinomial with maximum likelihood

Description

An EM algorithm to fit a multinomial with maximum likelihood

Usage

multinom_EM(
  X,
  simMM,
  min_iter = 10,
  max_iter = 1000,
  logLik_threshold = 0.01,
  verbose = TRUE
)

Arguments

X

A vector of commopent sizes

simMM

A matrix of floats (n_cluster, n_cluster) for the similarity matrix between clusters. simMM[i,j] means the proportion of cluster i will be assigned to cluster j, hence colSums(simMM) are ones.

min_iter

integer(1). number of minimum iterations

max_iter

integer(1). number of maximum iterations

logLik_threshold

A float. The threshold of logLikelihood increase for detecting convergence

verbose

A logic. Whether to print the iteration times and log likelihood.

Value

a list containing mu, a vector for estimated latent proportion of each cluster, logLik, a float for the estimated log likelihood, simMM, the input of simMM, codeX, the input of X, X_prop, the proportion of clusters in the input X, predict_X_prop, and the predicted proportion of clusters based on mu and simMM.

Examples

X = c(100, 300, 1500, 500, 1000)
simMM = create_simMat(5, confuse_rate=0.2)
multinom_EM(X, simMM)


huangyh09/DCATS documentation built on Nov. 25, 2022, 7:02 a.m.