Error when imputing low-variance observations with mice

Viewed 132

I'm working with a few datasets that have missing values, which should be predictable based on other complete observations in the datasets. I would like to impute these using multiple imputation with the mice package. Many of the data values are very small (E-3 or -4).

The behavior of mice has been a bit odd. When there are observations with many values of low variance, say, ~300 observations of roughly 50 variables, I receive errors using the "rf" or "midastouch" methods. The other methods work fine. If I increase the variance of the observations the errors disappear.

library(mice)

#simulate the dataset
sim <- matrix(data = rnorm(14500, sd=0.01), nrow=290)

#randomly select 20% of rows to have some missing data to replicate the pattern of NAs in the real datasets
r <- sample(1:nrow(sim), nrow(sim)*0.2)

#for each selected row, randomly set 6 of the 50 variables to NA.
for(i in r){
  sim[i, sample(50, 6)] <- NA
}

mice(sim, method='rf')

This returns:

Error in randomForest.default(x = xobs, y = yobs, ntree = 1, ...) : 
  NAs in foreign function call (arg 11)
In addition: Warning messages:
1: In randomForest.default(x = xobs, y = yobs, ntree = 1, ...) :
  invalid mtry: reset to within valid range
2: In max(ncat) : no non-missing arguments to max; returning -Inf
3: In randomForest.default(x = xobs, y = yobs, ntree = 1, ...) :
  NAs introduced by coercion to integer range

And using mice(sim, method='midastouch'):

Error in base::rbind(...) : 
  number of columns of matrices must match (see arg 2)

If we use a different method, or increase the variance of the observations, no problem:

mice(sim, method='norm')

sim <- sim*10
mice(sim, method='rf')
mice(sim, method='midastouch')

I initially thought that the low variance must cause an issue with randomForest, yet 'midastouch' also fails, albeit with a different error. I've tried searching the issue, debugging in R, and searching through the mice and randomForest code, but I can't figure out why these errors might occur. Any help would be appreciated.

I'm performing multiple imputation.

0 Answers
Related