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
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.
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? 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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With