Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double'
0
0
Entering edit mode
5 months ago

Hi there. I was running the MI package for imputing the missing variables with the code below: data <- read.csv("data.csv")

library(mi)
library(doParallel)
mdf <- missing_data.frame(data) 
show(mdf) 
mdf <- change(mdf, y = c("X"), what = "type", to = c("un"))
mdf <- change(mdf, y = c("X"), what = "type", to = c("ir"))
image(mdf)
rm(data) #good to remove large unnecessary objects to save RAM 
#options(mc.cores = 2)
#imputations <-mi(mdf, n.iter = 30, n.chains = 4, max.minutes = 20)
registerDoParallel(cl <- makeCluster(getOption("mc.cores", 10), setup_strategy = "sequential"))
imputations <- mi(mdf, n.iter = 30, n.chains = 4, max.minutes = 20, parallel=FALSE)

stopCluster(cl)
show(imputations)
plot(imputations)

Unfortunately, as it reaches Plot it gives me an error: Error in as. double(y): cannot coerce type 'S4' to a vector of type 'double'.

Also while running the iteration in 4 chains, certain iterations are not converged too. It would be helpful if I could solve this problem.

R • 472 views
ADD COMMENT
0
Entering edit mode

Does it run properly if you leave out all the parallel code and run it plain and simple on a single input object?

ADD REPLY

Login before adding your answer.

Traffic: 1035 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6