covEM {AATtools} | R Documentation |
Covariance matrix computation with multiple imputation
Description
This function computes a covariance matrix from data with some values missing at random. The code was written by Eric from StackExchange. https://stats.stackexchange.com/questions/182718/ml-covariance-estimation-from-expectation-maximization-with-missing-data
Usage
covEM(dat_missing, iters = 1000)
Arguments
dat_missing |
a matrix with missing values |
iters |
the number of iterations to perform to estimate missing values |
References
Beale, E. M. L., & Little, R. J. A.. (1975). Missing Values in Multivariate Analysis. Journal of the Royal Statistical Society. Series B (methodological), 37(1), 129–145.
Examples
# make data with missing values
missing_mtcars <- mtcars
for(i in 1:20){
missing_mtcars[sample(1:nrow(mtcars),1),sample(1:ncol(mtcars),1)]<-NA
}
covmat<-covEM(as.matrix(missing_mtcars))$sigma
calpha(covmat)
[Package AATtools version 0.0.2 Index]