(object 'nLev' not found) on VIM regressionImp function
varvanih opened this issue · 3 comments
Hello, I am trying to use VIM regressionImp function. But I encounter the below error when trying to run the code:
Error in regressionImp_work(formula = formula, data = data, family = family, :
object 'nLev' not found
This is what I am trying to run:
rm(list = ls())
library("VIM")
library("readxl")
setwd("E:\data_sets")
dataincomplete <- read_excel("4-gauss.xlsx")
form1 <- X1 ~ X3
for (v in c("X1")) {
dataincomplete[sample(1:nrow(dataincomplete), round(nrow(dataincomplete) / 10)), v] <- NA
}
dataimputed <- regressionImp(form1, dataincomplete, family = "AUTO", robust = TRUE, mod_cat = FALSE)
I attached my data file to this message.
My R version is 3.6.1 run on Windows 10 64bit.
Any help is really appreciated.
Thanks,
Farahani
I corrected the code. Thanks for pointing this error.
Please reinstall VIM from GitHub with the devtools package.
library(devtools)
install_github("statistikat/VIM")
Best
Matthias
Hello Matthias
Thank you very much for your help. That worked for me.
Also I realized that when I read the data set from an Excel file, its class is not simply "data.frame" but {"tbl_df" "tbl" "data.frame"}.
So I used below line to change its class to "data.frame" and this also solved the problem and now it works also with your previous VIM version:
DATA = as.data.frame(DATA)
Regards,
Farahani
Still produces an error for me. Apparently regressionImp gets into trouble with variables of integer type. Converting them to numeric makes the problem go away for me.