em {em} | R Documentation |
A Generic EM Algorithm
Description
This is a generic EM algorithm that can work on specific models/objects. Currently, it supports 'lm', 'glm', 'gnm' in package gnm, 'clogit' in package survival and 'multinom' in package nnet. Use '?em.default' to check the manual of the default function of 'em'.
Usage
em(object, ...)
Arguments
object |
the model used, e.g. 'lm', 'glm', 'gnm', 'clogit', 'multinom' |
... |
arguments used in the 'model'. |
Value
An object of class 'em' is a list containing at least the following components:
models
a list of models/objects whose class are determined by a model fitting from the previous step.
pi
the prior probabilities.
latent
number of the latent classes.
algorithm
the algorithm used (could be either 'em', 'sem' or 'cem').
obs
the number of observations.
post_pr
the posterior probabilities.
concomitant
a list of the concomitant model. It is empty if no concomitant model is used.
init.method
the initialization method used.
call
the matched call.
terms
the codeterms object used.
Author(s)
Dongjie Wu
Examples
fit.lm <- lm(yn ~ x, data = simreg)
results <- em(fit.lm, latent = 2, verbose = FALSE)
fmm_fit <- predict(results)
fmm_fit_post <- predict(results, prob = "posterior")