How to combine two ROC curves

Hello :slight_smile:
I am new to R, and I already need some help. So bear with me.

My research is about predicting response of treatment in patients with pancreatic cancer using cancer biomarkers. For each biomarker, I have created a ROC curve using the pROC package to see have well the biomarker performance (sensitivity, specificity etc.)

d$resb <- ifelse(d$Resectability=="Resectable",1,0)
r.CA199 <- roc(d$resb,d$CA19.9)
       best.method = "youden",
       ret = c("npv", "ppv", "sensitivity", "specificity","threshold")) 

r.VICM <- roc(d$resb,d$VICM)
       best.method = "youden",
       ret = c("npv", "ppv", "sensitivity", "specificity","threshold"))

However, I want to combine the ROC curves of two biomarkers, to see how well they perform together.
My question is: How do I combine the two ROC curves (CA199 and VICM) into one single ROC curve in one plot?

It is my first post, so if you need more information just tell me.

Thank you!

Here I have written a simple code. First, extract the data from roc calculation and plot the data manually.

y = c(rep(0,50), rep(1, 50))
x1 = y + rnorm(100, sd = 1)
x2 = y + rnorm(100, sd = 4)

model1 = glm(y ~ x1, family = binomial())
pred1 = predict(model1)
model2 = glm(y ~ x1 + x2, family = binomial())
pred2 = predict(model2)

roc1 = roc(y, pred1)
roc2 = roc(y, pred2)

#### Extract the values of specificities and sensitivities

roc1.p<- data.frame(roc1$sensitivities, roc1$specificities, condition = "Condition1")
roc2.p<- data.frame(roc2$sensitivities, roc2$specificities, condition = "Condition2") 

### Combine two dataframe
## first rename the columns name as same to use rbind
names(roc2.p)<- names(roc1.p)
roc.p<- rbind(roc1.p, roc2.p) 

ggplot(roc.p, aes(roc1.sensitivities,roc1.specificities,colour=condition)) + 
  geom_line() +
  geom_point() +
  coord_cartesian(xlim=c(0,1), ylim=c(0,1)) +

### you can play with geom_smooth instead of geom_line if you want to have soomth curve
###geom_smooth(method="lm", formula=y ~ splines::bs(x, df=3), se=FALSE)

This topic was automatically closed 21 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.