Missing values imputation with missMDA
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
“The best thing to do with missing values is not to have any” (Gertrude Mary Cox)
Unfortunately, missing values are ubiquitous and occur for plenty of reasons. One solution is single imputation which consists in replacing missing entries with plausible values. It leads to a complete dataset that can be analyzed by any statistical methods.
Based on dimensionality reduction methods, the missMDA package successfully imputes large and complex datasets with quantitative variables, categorical variables and mixed variables. Indeed, it imputes data with principal component methods that take into account the similarities between the observations and the relationship between variables. It has proven to be very competitive in terms of quality of the prediction compared to the state of the art methods.
With 3 lines of code, we impute the dataset orange available in missMDA:
library(missMDA)
data(orange)
nbdim <- estim_ncpPCA(orange) # estimate the number of dimensions to impute
res.comp <- imputePCA(orange, ncp = nbdim)
In the same way, imputeMCA imputes datasets with categorical variables and imputeFAMD imputes mixed datasets.
With a completed data, we can pursue our analyses… however we need to be careful and not to forget that the data was incomplete! In a future post, we will see how to visualize the uncertainty on these predicted values.
You can find more information in this JSS paper, on this website, on this tutorial given at useR!2016 at stanford.
You can also watch this playlist on Youtube to practice with R.
You can also enroll in this MOOC.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.