RepositoryR
amices

amices/mice

Multivariate Imputation by Chained Equations

522sao
126fork
15issue
2lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: chained-equations

#1 Repository của tuần

1
TINIX TRENDING·Chủ đề: fcs

#1 Repository của tuần

1
TINIX TRENDING·Chủ đề: imputation

#1 Repository của tuần

mice

CRAN_Status_Badge R-CMD-check

Multivariate Imputation by Chained Equations

The mice package implements a method to deal with missing data. The package creates multiple imputations (replacement values) for multivariate missing data. The method is based on Fully Conditional Specification, where each incomplete variable is imputed by a separate model. The MICE algorithm can impute mixes of continuous, binary, unordered categorical and ordered categorical data. In addition, MICE can impute continuous two-level data, and maintain consistency between imputations by means of passive imputation. Many diagnostic plots are implemented to inspect the quality of the imputations.

Installation

The mice package can be installed from CRAN as follows:

install.packages("mice")

The latest version can be installed from GitHub as follows:

install.packages("devtools")
devtools::install_github(repo = "amices/mice")

Minimal example

library(mice, warn.conflicts = FALSE)

# show the missing data pattern
md.pattern(nhanes)
Missing data pattern of nhanes data. Blue is observed, red is missing.
#>    age hyp bmi chl   
#> 13   1   1   1   1  0
#> 3    1   1   1   0  1
#> 1    1   1   0   1  1
#> 1    1   0   0   1  2
#> 7    1   0   0   0  3
#>      0   8   9  10 27

The table and the graph summarize where the missing data occur in the nhanes dataset.

# multiple impute the missing values
imp <- mice(nhanes, maxit = 2, m = 2, seed = 1)
#> 
#>  iter imp variable
#>   1   1  bmi  hyp  chl
#>   1   2  bmi  hyp  chl
#>   2   1  bmi  hyp  chl
#>   2   2  bmi  hyp  chl

# inspect quality of imputations
stripplot(imp, chl, pch = 19, xlab = "Imputation number")
Distribution of chl per imputed data set.

In general, we would like the imputations to be plausible, i.e., values that could have been observed if they had not been missing.

# fit complete-data model
fit <- with(imp, lm(chl ~ age + bmi))

# pool and summarize the results
summary(pool(fit))
#>          term estimate std.error statistic    df p.value
#> 1 (Intercept)    12.01     70.99     0.169  4.31  0.8733
#> 2         age    31.04     18.73     1.657  1.20  0.3134
#> 3         bmi     4.84      1.88     2.572 16.20  0.0203

The complete-data is fit to each imputed dataset, and the results are combined to arrive at estimates that properly account for the missing data.

mice 3.0

Version 3.0 represents a major update that implements the following features:

  1. blocks: The main algorithm iterates over blocks. A block is simply a collection of variables. In the common MICE algorithm each block was equivalent to one variable, which - of course - is the default; The blocks argument allows mixing univariate imputation method multivariate imputation methods. The blocks feature bridges two seemingly disparate approaches, joint modeling and fully conditional specification, into one framework;

  2. where: The where argument is a logical matrix of the same size of data that specifies which cells should be imputed. This opens up some new analytic possibilities;

  3. Multivariate tests: There are new functions D1(), D2(), D3() and anova() that perform multivariate parameter tests on the repeated analysis from on multiply-imputed data;

  4. formulas: The old form argument has been redesign and is now renamed to formulas. This provides an alternative way to specify imputation models that exploits the full power of R’s native formula’s.

  5. Better integration with the tidyverse framework, especially for packages dplyr, tibble and broom;

  6. Improved numerical algorithms for low-level imputation function. Better handling of duplicate variables.

  7. Last but not least: A brand new edition AND online version of Flexible Imputation of Missing Data. Second Edition.

See MICE: Multivariate Imputation by Chained Equations for more resources.

I’ll be happy to take feedback and discuss suggestions. Please submit these through Github’s issues facility.

Resources

Theoretical background

  1. mice: Multivariate Imputation by Chained Equations in R in the Journal of Statistical Software (van Buuren and Groothuis-Oudshoorn 2011).
  2. The first application on missing blood pressure data (van Buuren et al. 1999).
  3. Term Fully Conditional Specification describes a general class of methods that specify imputations model for multivariate data as a set of conditional distributions (van Buuren et al. 2006).
  4. Details about imputing mixes of numerical and categorical data can be found in (van Buuren 2007).
  5. Book Flexible Imputation of Missing Data. Second Edition (van Buuren 2018).

Course materials

  1. Handling Missing Data in R with mice
  2. Statistical Methods for combined data sets

Vignettes

  1. Ad hoc methods and the MICE algorithm
  2. Convergence and pooling
  3. Inspecting how the observed data and missingness are related
  4. Passive imputation and post-processing
  5. Imputing multilevel data
  6. Sensitivity analysis with mice
  7. Generate missing values with ampute
  8. futuremice: Wrapper for parallel MICE imputation through futures

Code from publications

  1. Flexible Imputation of Missing Data. Second edition.

Acknowledgement

The cute mice sticker was designed by Jaden M. Walters. Thanks Jaden!

Code of Conduct

Please note that the mice project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

References

van Buuren, S. 2007. “Multiple Imputation of Discrete and Continuous Data by Fully Conditional Specification.” Statistical Methods in Medical Research 16 (3): 219–42. https://doi.org/10.1177/0962280206074463.

van Buuren, S., H. C. Boshuizen, and D. L. Knook. 1999. “Multiple Imputation of Missing Blood Pressure Covariates in Survival Analysis.” Statistics in Medicine 18 (6): 681–94. https://doi.org/10.1002/(sici)1097-0258(19990330)18:6<681::aid-sim71>3.0.co;2-r.

van Buuren, S., J. P. L. Brand, C. G. M. Groothuis-Oudshoorn, and D. B. Rubin. 2006. “Fully Conditional Specification in Multivariate Imputation.” Journal of Statistical Computation and Simulation 76 (12): 1049–64. https://doi.org/10.1080/10629360600810434.

van Buuren, S., and K. Groothuis-Oudshoorn. 2011. “mice: Multivariate Imputation by Chained Equations in R.” Journal of Statistical Software 45 (3): 1–67. https://doi.org/10.18637/jss.v045.i03.

van Buuren, Stef. 2018. Flexible Imputation of Missing Data. 2nd ed. Interdisciplinary Statistics Series. Chapman and Hall/CRC. https://doi.org/10.1201/9780429492259.

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryPython
WenjieDu/PyGrinder

PyGrinder: a Python toolkit for grinding data beans into the incomplete for real-world data simulation by introducing missing values with different missingness patterns, including MCAR (complete at random), MAR (at random), MNAR (not at random), sub sequence missing, and block missing

71
Nov 17, 2026
RepositoryR
SteffenMoritz/imputeTS

CRAN R Package: Time Series Missing Value Imputation

174
Aug 24, 2025
RepositoryR
mayer79/missRanger

Fast multivariate imputation by random forests.

73
Apr 6, 2025
RepositoryPython
WenjieDu/PyPOTS

A Python toolkit/library for real-world machine/deep learning & data mining on partially-observed time series, with 50+ SOTA neural network models for scientific analysis tasks (imputation, classification, clustering, forecasting, anomaly detection, cleaning) on incomplete industrial irregularly-sampled multivariate TS with NaN missing values

2.1k
Dec 1, 2026
RepositoryJupyter Notebook
WenjieDu/BrewPOTS

The tutorials for PyPOTS, guide you to model partially-observed time series datasets.

128
Aug 25, 2026
RepositoryPython
OpenIDEA-YunanUniversity/ycimpute

A missing value imputation library based on machine learning. It's implementation missForest, simple edition of MICE(R pacakge), knn, EM, etc....

107
Mar 17, 2024
RepositoryJupyter Notebook
eXascaleInfolab/ImputeGAP

ImputeGAP is a comprehensive Python library for imputation of missing values in time series data. It implements user-friendly APIs to easily visualize, analyze, and repair incomplete time series datasets.

78
Nov 28, 2026
RepositoryTypeScript
openclaw/openclaw

The AI that really does things. Any OS. Any Platform. The lobster way. 🦞

395.6k
Dec 2, 2026
Repository
jwasham/coding-interview-university

A complete computer science study plan to become a software engineer.

365.2k
Nov 7, 2026