Reputation: 1
How to do ROC and nomogram plotting after multiple imputation with the "mice" package?
I found online that I could use the "pool_performance" function for calibration curve plotting, performing the Hosmer and Lemeshow test and Brier score.
But there is no method found for ROC and nomogram plotting that can be done after multiple imputation.
Here is my code using pool_performance
pool_performance(
data = imp_complete,
formula = Y ~ X1 + X2 + X3,
nimp = 20,
impvar = ".imp",
model_type = "binomial",
cal.plot = TRUE,
plot.method = "mean",
groups_cal = 10
)
Do you guys have any suggestions for ways to plot ROCs and nomograms after multiple imputation?
update 2024.05.21
I got some ideas from chatgpt.
the way plot ROC
library(mice)
library(pROC)
library(dplyr)
completed_data_list <- lapply(1:46, function(i) complete(imp, i))
predicted_probabilities <- sapply(completed_data_list, function(data) {
model <- glm(Y ~ X1 + X2 + X3, family = binomial(), data = data)
predict(model, newdata = data, type = "response")
})
mean_predicted_probabilities <- rowMeans(predicted_probabilities)
roc_curve <- roc(originaldata$Y, mean_predicted_probabilities)
plot(roc_curve, main = "ROC Curve", col = "#3366FF")
the way plot nomogram
mean_model <- lrm(Y ~ X1 + X2 + X3, data = complete(imp, 1))
mean_model$coefficients <- c(summary.fit$estimate)
plot(nomogram(mean_model, fun = plogis, lp = FALSE),
xfrac=.15, cex.axis=.7)
The only problem is that the calculated AUC is not consistent with the AUC calculated using psfmi, I think it may be due to the calculation process, psfmi calculates the AUC for each interpolated model and then takes the mean, while my method is to calculate the predicted probability of each interpolated model, take the mean of the predicted probability and then calculate the AUC.
Upvotes: 0
Views: 155