I am trying to run multiple imputations for a dataframe with 100+ columns. My data has mixed variable types: numeric, factor, ordered factors, binary. I keep running into problems when trying to impute the survey portion of the dataframe, which are ordinal variables.
Only 1 imputation will run and then I will get the error:
iter imp variable
1 1 var1
Error in terms.formula(tmp, simplify = TRUE): invalid term in model formula
Traceback:
My code is: imp <- mice(dat1, m=5, method = meth, seed=500)
Some additional context: The survey data is not all on the same scale. Questions were asked on different Likert scales, so responses are coded ranging from 1-4, 1-5, and 1-6, depending on question type. I have already converted these to ordered factors where necessary. This error is not unique to the first column alone, as I have tried removing it and the same error will occur with the next column. I have split the dataframe into different sections and it seems the numeric and binary columns are imputing fine.
Any help is greatly appreciated
sdanthony is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.