2

I ran into the same issue presented in mice: glm.fit: algorithm did not converge and originally adopted the solution that the question asker did (and it worked ok). My imputation procedure takes a longer time than is acceptable to me, though, so I've tried using futuremice. The problem is the the solution that I was using locally defines a function that cannot be found when using futuremice. I've opted to try a suggestion provided in the comments, passing an argument though mice::mice to glm.fit to try to get around this problem (instead of cloning the mice package and redefining the method parameters there).

I've tried several different ways to pass the maxit=100 argument, and I get errors for each way I try. Reprex below:

test_data <- data.frame(x = as.factor(round(rnorm(100))), 
                        y = as.factor(round(rnorm(100, 1,1))),
                        z = rnorm(100,5,1))
test_data[3:4, 1] <- NA
test_data[5:8, 2] <- NA

test_init <- mice(test_data, max = 0, print = F, vis = "monotone", 
                  defaultMethod = c("pmm", "logreg", "polyreg", "polr"))


predictor_matrix <- quickpred(test_data)

# try 1
test_data_mice <- mice::mice(test_data, print = F, 
                        predictorMatrix = predictor_matrix,
                        method = test_init$method,
                        vis = test_init$visitSequence,
                        glm.fit(control = list(glm.control(maxit = 100)))
)
#ERROR:Error in glm.control(list(epsilon = 1e-08, maxit = 100, trace = FALSE)) : 
 # value of 'epsilon' must be > 0

#try 2
test_data_mice <- mice::mice(test_data, print = F, 
                        predictorMatrix = predictor_matrix,
                        method = test_init$method,
                        vis = test_init$visitSequence,
                        glm.fit(control = list(maxit = 100))
)
#ERROR: Error in as.matrix(x) : argument "x" is missing, with no default

I'm pretty sure that Try 1 should be correct, so I don't get what's happening there. I tried explicitly defining epsilon and it didn't change the error.

0 Answers0