em.cov {EMgaussian} | R Documentation |
EM algorithm for multivariate normal, covariance matrix parameterization
Description
EM algorithm for multivariate normal, covariance matrix parameterization
Usage
em.cov(
dat,
max.iter = 500,
tol = 1e-05,
start = c("diag", "pairwise", "listwise", "full"),
debug = 0,
...
)
Arguments
dat |
Data frame or matrix that contains the raw data. |
max.iter |
Max number of EM cycles. |
tol |
Tolerance for change in parameter estimates across EM Cycles. If
all changes are less than |
start |
Starting value method (see details). |
debug |
(Experimental) set an integer value > 1 for some information as the algorithm runs. |
... |
Space for additional arguments, not currently used. |
Details
This function computes all means and covariances among a set of variables using
the Expectation-Maximization (EM) algorithm to handle missing values, and assuming
multivariate normality. The EM code was originally developed for the precision
matrix parameterization (em.prec
), i.e., the parameters are the
means and the inverse of the covariance matrix. But, this is easily modifiable
to handle a covariance matrix parameterization such that means and covariances
are the model parameters.
For starting values, the function accepts either a list that has mu
and
S
slots corresponding to the starting mean and covariance matrix. This
is useful if the user would like to use custom starting values. Otherwise, a
character corresponding to any of the options available in the
startvals.cov
function will be used to take a guess at starting values.
Value
A list with the following:
p.est
: all parameter estimates as a vector (means followed by unique elements of precision matrix).mu
: estimated means.S
: estimated covariance matrix.it
: number of EM cycles completed.conv
: boolean value indicating convergence (TRUE) or not (FALSE).
Examples
library(psych)
data(bfi)
test <- em.cov(bfi[,1:25])