0

I'm using the mice package to interpolate some missing values. I've successfully been using mice in many cases without any problem. However I am now facing an unprecedented problem, that is, after the first iteration I get the following error:

mice(my_data)
iter imp variable
  1   1  sunlight
Show Traceback

 Rerun with Debug
Error in cor(xobs[, keep, drop = FALSE], use = "all.obs") : 'x' is empty 

I have tried to look in the documentation but I cannot find anything useful. I looked up the error on the internet and found this https://stat.ethz.ch/pipermail/r-help/2015-December/434914.html but I was unable to find the answer to the problem described.

Sadly I cannot provide a working example of the data since my_data contains private data that I do not own and therefore cannot make publicly available. my_data is a dplyr dataframe however it looks like there's no difference in using a dplyr or a "base" dataframe.

Could anyone please explain me what is happening and (possibly) how to fix it? Thank you.

EDIT: added some more info on traceback:

cor(xobs[, keep, drop = FALSE], use = "all.obs") 
4 remove.lindep(x, y, ry, ...) 
3 sampler(p, data, m, imp, r, visitSequence, c(from, to), printFlag, 
    ...) 
2 mice::mice(my_data)
mickkk
  • 1,172
  • 2
  • 17
  • 38
  • 2
    It's almost impossible to help you without a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Rather than using your data, try using data that "looks like" yours. Does the error only occur when using certain columns? What's unique about those columns? Is there any more information in the full `traceback()`? – MrFlick Jul 01 '16 at 20:26
  • @MrFlick Yeah I know, I'm sorry but my client does not allow me to post some pieces of their data on the internet. However the fact is that this error is really strange since I'm using a standard data.frame class object to do this and the program runs smooth if I include another column to the dataframe. Maybe there are not enough columns?? Who knows... – mickkk Jul 18 '16 at 14:31
  • @MrFlick however, this error is exactly equal to the one indicated at https://stat.ethz.ch/pipermail/r-help/2015-December/434914.html where it is stated that, quote: "It seems that the mice function can only works well with 1st and 2nd envdata. When enter the 3rd data, it triggers an error: data." Sadly I cannot understand what is being said in this sentence, however I guess the solution to the error is there! – mickkk Jul 18 '16 at 14:33
  • There are many different problems that may result in the same error message. It's not always possible for the developer to guess all the different ways that things go wrong so sometimes you end up with generic error messages. There's still nothing we can do for you without a reproducible example to see what's wrong in your particular case. – MrFlick Jul 18 '16 at 14:36
  • @MrFlick ok I get it. Thanks for getting back at me, I'll leave the question open in case someone has some more insights. Meanwhile I solved the problem by adding another variable to the dataframe as I stated above. Not brilliant but seems to work fine. – mickkk Jul 18 '16 at 19:32
  • I just had the same ERROR using function `mice()`. In my particular case, the error warning did not prompt when I removed the variables with an excess of `NAs`. – Santi XGR Jan 23 '17 at 11:18

1 Answers1

1

Very possible, some columns in the data input are overly correlated that certain methods of imputation are not applicable.

ThomasKK
  • 11
  • 1