LC.MLE: LC.MLE function

Description Usage Arguments Details Examples

View source: R/LC.MLE.R

Description

This function estimates parameters of the latent class model using the maximum likelihood method. As a subroutine it uses constrOptim().

Usage

1
LC.MLE(counts, k, tries = 3, theta = NULL, tol = 1e-08, mode = "optim")

Arguments

counts

The array of counts of format (r[1],...,r[m])

k

The number of latent classes fitted

tries

The number of times the algorithm reruns from different random starting points. The default value is tries=3

theta

The vector of parameters from which the algorithm starts. If not specified, the algorithm starts from a random point.

tol

The convergence criterion for the EM algorithm. The maximal decrease of the log-likelihood function that will terminate the algorithm.

mode

The algorithm used to compute the MLE. Write 'EM' to use the EM algorithm and 'optim' to use the standard R constrained optimization routine constrOptim().

Details

This function works as an alternative to LC.EM() that uses the EM algorithm.

Examples

1
2
3
4
5
6
7
8
9
theta0 <- list()
theta0[[1]] <- matrix(c(0.9,0.2,0.1,0.8),2,2)
theta0[[2]] <- matrix(c(0.7,0.2,0.3,0.8),2,2)
theta0[[3]] <- matrix(c(0.9,0.1,0.1,0.9),2,2)
theta0[[4]] <- matrix(c(0.7,0.1,0.3,0.9),2,2)
theta0[[5]] <- matrix(c(0.7,0.1,0.3,0.9),2,2)
theta0[[6]] <- c(0.3,0.7)
data <- sample.counts(500,theta0)
LC.MLE(data,2,tries=3,tol=1e-8,margin.size=3)

pzwiernik/LatentClass documentation built on May 26, 2019, 11:35 a.m.