RepositoryR
mayer79

mayer79/missRanger

Fast multivariate imputation by random forests.

73stars
10forks
2issues
4views

{missRanger}

R-CMD-check Codecov test coverage CRAN_Status_Badge

Overview

{missRanger} is a multivariate imputation algorithm based on random forests. It is a fast alternative to the famous 'MissForest' algorithm (Stekhoven and Buehlmann, 2012), and uses the {ranger} package (Wright and Ziegler, 2017) to fit the random forests. Since version 2.6.0, out-of-sample application is possible.

Installation

# From CRAN
install.packages("missRanger")

# Development version
devtools::install_github("mayer79/missRanger")

Usage

library(missRanger)

set.seed(3)

iris_NA <- generateNA(iris, p = 0.1)
head(iris_NA)
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#         5.1         3.5          1.4         0.2  setosa
#         4.9         3.0          1.4          NA  setosa
#         4.7         3.2          1.3         0.2  setosa
#         4.6         3.1          1.5         0.2    <NA>
#          NA         3.6          1.4         0.2  setosa
#         5.4         3.9          1.7         0.4    <NA>

iris_filled <- missRanger(iris_NA, pmm.k = 5, num.trees = 100)
head(iris_filled)

#   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# 1          5.1         3.5          1.4         0.2  setosa
# 2          4.9         3.0          1.4         0.2  setosa
# 3          4.7         3.2          1.3         0.2  setosa
# 4          4.6         3.1          1.5         0.2  setosa
# 5          5.2         3.6          1.4         0.2  setosa
# 6          5.4         3.9          1.7         0.4  setosa

How it works

The algorithm iterates until the average out-of-bag (OOB) error of the forests stops improving. The missing values are filled by OOB predictions of the best iteration, optionally followed by predictive mean matching (PMM). The PMM step avoids values not present in the original data (like a value 0.3334 in a 0-1 coded variable). Furthermore, PMM raises the variance in the resulting conditional distributions to a more realistic level, a crucial property for multiple imputation.

Check-out the vignettes for more info, and for how to use missRanger() in multiple imputation.

References

  • Stekhoven D. J., Buehlmann, P. (2012). MissForest - non-parametric missing value imputation for mixed-type data. Bioinformatics, 28(1), 112-118.
  • Marvin N. Wright, Andreas Ziegler (2017). ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R. Journal of Statistical Software, 77(1), 1-17. doi:10.18637/jss.v077.i01

Similar Projects

Discover other similar projects and AI models.

RepositoryJupyter Notebook
microsoft/ML-For-Beginners

12 weeks, 26 lessons, 52 quizzes, classic Machine Learning for all

92.5k
Nov 7, 2026
RepositoryC++
tensorflow/tensorflow

An Open Source Machine Learning Framework for Everyone

201.9k
Dec 1, 2026
RepositoryR
qinwf/awesome-R

A curated list of awesome R packages, frameworks and software.

6.5k
Sep 18, 2025
RepositoryR
plotly/plotly.R

An interactive graphing library for R

2.7k
Jul 25, 2026
RepositoryR
r-spatial/sf

Simple Features for R

1.5k
Nov 23, 2026
RepositoryR
hrbrmstr/hrbrthemes

:lock_with_ink_pen: Opinionated, typographic-centric ggplot2 themes and theme components

1.4k
Oct 17, 2026
RepositoryR
ropensci/drake

An R-focused pipeline toolkit for reproducibility and high-performance computing

1.3k
Dec 4, 2024
RepositoryR
mitchelloharawild/vitae

R Markdown Résumés and CVs

1.3k
Aug 21, 2026
RepositoryR
ddsjoberg/gtsummary

Presentation-Ready Data Summary and Analytic Result Tables

1.2k
Nov 27, 2026