3

On a regular dataset, the calls will go like this:

library(ROCR)

mymodelFit1 <- glm(data = myData, Outcome~ predictor1+ 
predictor2+ predictor3,
             family = binomial(link = "logit")))

prob <- predict(mymodelFit1, newdata=myData, type="response")
pred <- prediction(prob, myData$Outcome)
perf <- performance(pred, measure = "tpr", x.measure = "fpr")
plot(perf)
auc <- performance(pred, measure = "auc")
auc <- auc@y.values[[1]]
auc

Now, I have used the mice package to impute missing data:

library(mice)

impData <- mice(analysis_set,m=5,maxit=50,meth='pmm',
seed=500, printFlag = FALSE)

And generated a logistic model using the imputed dataset:

mymodelFit2 <- with(data = impData, exp = glm(Outcome~ predictor1+ 
predictor2 + predictor3,
             family = binomial(link = "logit")))

The question is: how can I calculate the AUC for the new model (mymodelFit2)?

"mice" generates x number of sets for missing values (5 in this case, specified in the m= parameter of mice()). The model has x number (5 in this case) of estimates.

Is there a function or an easy way to calculate AUC for these models? And how can I get an AUC for the pooled model?

slamballais
  • 3,161
  • 3
  • 18
  • 29
Wael Hussein
  • 135
  • 1
  • 12
  • I may be missing something, but you should be able to do it exactly as you did for the first model. What error our you getting or what is your issue? – Ian Wesley May 24 '17 at 15:01
  • predict(mymodelFit2.. produces this message: Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "c('mira', 'matrix')" – Wael Hussein May 24 '17 at 19:07
  • You are returning an object of class mira because you are using "with()". Why don't you use as before the glm() function instead ? So the object returned will inherits from glm and can be used in the predict() function. That's basically what the error message is telling you. – bricx May 19 '21 at 18:13

0 Answers0