An R package to make imputation simple. Currently supported methods include
- Model based (optionally add [non-]parametric random residual)
- linear regression
- robust linear regression (M-estimation)
- ridge/elasticnet/lasso regression (from version >= 0.2.1)
- CART models
- Random forest
- Model based, multivariate
- Imputation based on EM-estimated parameters (from version >= 0.2.1)
- missForest (from version >= 0.2.1)
- Donor imputation (including various donor pool specifications)
- k-nearest neigbour (based on gower's distance)
- sequential hotdeck (LOCF, NOCB)
- random hotdeck
- Predictive mean matching
- Other
- (groupwise) median imputation (optional random residual)
- Proxy imputation (copy from other variable)
simputation requires R >= 4.1.0. To install it together with all packages needed to support the various imputation models, do the following.
install.packages("simputation", dependencies=TRUE)A plain install.packages("simputation") pulls in only MASS, rpart and
gower. The backends for the remaining methods are optional:
| method | package |
|---|---|
impute_en |
glmnet |
impute_rf |
randomForest |
impute_mf |
missForest |
impute_em |
norm |
impute_rhd, impute_shd, impute_knn with backend="VIM" |
VIM |
If one of these is not installed, the corresponding impute_ function warns
and returns the data unchanged rather than failing.
To install the development version. The man/ directory is generated, so
building from a clone needs roxygen2 and pkgload installed.
git clone https://github.com/markvanderloo/simputation
cd simputation
make installCreate some data suffering from missings
library(simputation) # current package
dat <- iris
# empty a few fields
dat[1:3,1] <- dat[3:7,2] <- dat[8:10,5] <- NA
head(dat,10)Now impute Sepal.Length and Sepal.Width by regression on Petal.Length and Species, and impute Species using a CART model, that uses all other variables (including the imputed variables in this case).
dat |>
impute_lm(Sepal.Length + Sepal.Width ~ Petal.Length + Species) |>
impute_cart(Species ~ .) |> # use all variables except 'Species' as predictor
head(10)