Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in "missforest" in R

Tags:

r

imputation

Need help to get around the below error while performing data imputation in R using "missforest" package.

> imputed<- missForest(dummy, maxiter = 10, ntree = 100, variablewise = TRUE,
+                      decreasing = TRUE, verbose = TRUE,
+                      mtry = floor(sqrt(ncol(dummy))), replace = TRUE)
Error in sample.int(length(x), size, replace, prob) : 
  invalid first argument
like image 646
Sandeep Avatar asked Sep 08 '17 22:09

Sandeep


People also ask

What is MissForest in R?

MissForest is a random forest imputation algorithm for missing data, implemented in R in the missForest() package. It initially imputes all missing data using the mean/mode, then for each variable with missing values, MissForest fits a random forest on the observed part and then predicts the missing part.

Is MissForest multiple imputation?

The 'missForest' package (Stekhoven, 2013, Stekhoven, 2012) provides not only a function for conduct- ing multiple imputation of mixed data (numeric and factor variables in one data frame), but it also has a utility to parallelize the process of doing such imputations.

What is MissForest imputation?

What is MissForest? MissForest is a machine learning-based imputation technique. It uses a Random Forest algorithm to do the task. It is based on an iterative approach, and at each iteration the generated predictions are better.


1 Answers

Had the same problem. Transforming xmis object with as.data.frame helped. In your case it would be something like:

dummy <- as.data.frame(dummy)    
imputed<- missForest(dummy, maxiter = 10, ntree = 100, variablewise = TRUE,
                      decreasing = TRUE, verbose = TRUE,
                      mtry = floor(sqrt(ncol(dummy))), replace = TRUE)
like image 126
mrbubu Avatar answered Sep 19 '22 17:09

mrbubu