LC.EM: LC.EM function

Description Usage Arguments Examples

View source: R/LC.EM.R

Description

This function estimates parameters of the latent class model using the standard EM algorithm.

Usage

1
LC.EM(counts, k, tries = 3, theta = NULL, tol = 1e-06)

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 EM 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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
theta0 <- list()
length(theta0) <- 5
theta0[[1]] <- matrix(c(0.8,1-0.7,1-0.8,0.7),2,2)
theta0[[2]] <- matrix(c(0.8,1-0.7,1-0.8,0.7),2,2)
theta0[[3]] <- matrix(c(0.8,1-0.7,1-0.8,0.7),2,2)
theta0[[4]] <- matrix(c(0.8,1-0.9,1-0.8,0.9),2,2)
theta0[[5]] <- c(1-0.7,0.7)
n <- 1000
counts <- sample.counts(n, theta0)
EM(counts,2)

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