# Error using mice() package in R for handling missing data [closed]

I am doing regression with a data with Y as target variable and 16 feature variables. I had two date feature variables which where as factor. I converted them to date format as shown below:

X2 <-  as.Date(X2, format="%m/%d/%Y"))


I had a lot of missing data in my training as well as validation data set. I was suggested to try out imputation. R had a lot of packages like AMELIA and Mice.I started trying with Mice package but I am getting the below error.

Error in FUN(newX[, i], ...) : 'x' must be numeric
In FUN(newX[, i], ...) : NAs introduced by coercion


Can anyone help me with this error.

Thanks

## closed as off-topic by AdamO, chlSep 26 '14 at 20:41

• This question does not appear to be about statistics within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Hi Nikita, you seem to have quite the history of posting software and not statistical related questions on this SE network. Please remember to take questions like these to the appropriate network. – AdamO Sep 26 '14 at 20:18
• Seems like mice was expecting numeric data in a column that didn't have numeric data. The imputation method used by mice depends on the type of data. Check the class of each of your variables, and double-check the arguments you passed to the function. Make sure that you have coded empty values as NA, preferably with the is.na() function to make sure that the class is correct. To troubleshoot, try working with just a few variables at a time. If the problem is in a date column, I agree with the answer provided by @AdamO. – EdM Sep 26 '14 at 20:26
• This question appears to be off-topic because it is about R software only. – chl Sep 26 '14 at 20:41
• @Adamo Sorry for posting it in the wrong group. Thanks for the answer. – Nikita Sinnarkar Sep 26 '14 at 21:00

A better way to approach this problem might be multiple imputation of the missing data, if your data meet the requirements for imputation. The rms package in R provides useful tools for imputation and model validation. You might also want to look at the mice package for the imputation part of the problem; rms can handle objects produced by mice. The web page displaying your question now shows links to other related questions, whose answers might also be useful.
rms is a good package, however, I am not aware of how the imputation was developed in rms and mice has had several publications on the topic.