Skip to contents

Maximum-likelihood mean and covariance of incomplete multivariate normal data by EM (Little and Rubin 2002, section 11.2): the E-step replaces each row's missing coordinates by their conditional mean given the observed ones and carries their conditional covariance \(C_i\), which the M-step adds back, \(\Sigma = n^{-1} \sum_i ((x_i - \mu)(x_i - \mu)' + C_i)\). The returned data are the conditional means at the final estimates. Identical to the Python arm morie.fn.emimq.em_imputation.

Usage

em_imputation(data, max_iter = 100, tol = 1e-06)

Arguments

data

Numeric matrix (or vector) with NA for missing values.

max_iter

Maximum EM iterations.

tol

Stop when the largest change in the mean or covariance is below this.

Value

A list with value and n_missing, n, p, imputed_means, mean, cov, imputed, loglik (observed-data), iterations and converged.

References

Dempster, A. P., Laird, N. M. and Rubin, D. B. (1977). Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society B 39, 1-38.

Little, R. J. A. and Rubin, D. B. (2002). Statistical Analysis with Missing Data, 2nd ed. Wiley.

Examples

X <- cbind(c(1, 2, 3.5, 4, 5.5, 6), c(2.1, 2.9, 4.2, 5.1, NA, NA))
em_imputation(X)$mean
#> [1] 3.666667 4.575457