How to aggregate roc curves using VGAM (vglm) and multiclass.roc

roc.multi function is not properly being defined? How to do? How to aggregate? See code below.

# Aggregate the ROC curves to obtain an overall ROC curve
roc_agg <- roc.multi(roc_curves)
#Error in roc.multi(roc_curves) : could not find function "roc.multi" ???

Complete code is given below.


library(pROC)
library(VGAM)

# Generate some sample data
set.seed(123)
n <- 1000
x1 <- rnorm(n)
x2 <- rnorm(n)
x3 <- rnorm(n)
y <- ordered(sample(1:4, n, replace=TRUE), levels=1:4)
cat(y)

# fit an ordinal logistic regression model
fit <- vglm(y ~ x1 + x2 + x3, family=cumulative(parallel=TRUE))

# Compute the predicted probabilities for each category
pred <- predict(fit, type="response")

roc.multi <- multiclass.roc(y, pred)
auc(roc.multi)  # Multi-class area under the curve: 0.5053

# Compute the ROC curves for each category
roc_curves <- lapply(levels(y), function(level) {
  roc(y == level, pred[, level])
})
#Setting levels: control = FALSE, case = TRUE
#Setting direction: controls < cases
#Setting levels: control = FALSE, case = TRUE
#Setting direction: controls > cases
#Setting levels: control = FALSE, case = TRUE
#Setting direction: controls < cases
#Setting levels: control = FALSE, case = TRUE
#Setting direction: controls < cases

# Aggregate the ROC curves to obtain an overall ROC curve
roc_agg <- roc.multi(roc_curves)
#Error in roc.multi(roc_curves) : could not find function "roc.multi" ????

# Plot the ROC curves
plot(roc_agg, print.auc=TRUE, col="blue", main="Multi-ROC Curve")

rs <- roc.multi[['rocs']]
plot.roc(rs[[1]])
sapply(2:length(rs),function(i) lines.roc(rs[[i]],col=i))

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.