0

The code below should display a roc curve for 28-day mortality using a clinical scores (based on organ dysfunction). The code worked perfectly some months ago, now it yields error:

"Error in roc(y1, x, plot = TRUE, legacy.axes = TRUE, lwd = 4, add = TRUE,  : 
  unused arguments (plot = TRUE, legacy.axes = TRUE, lwd = 4, add = TRUE, col = "darkred").
  y1 <- as.integer(E_SOFA_StudyPop$`Dead within 28 d (1/0)`) #

  x <- as.integer(E_SOFA_StudyPop$`3h total SOFA`)

  #28 -d mortality
  par(pty= "s")
  roc.a = roc(y1, x, plot=TRUE, legacy.axes=TRUE, lwd=4, add=TRUE,  col="darkred")

I have tried:

  • installing the pROC package again
  • Restarted R session
  • Tried one argument at a time, but it gives a similar error for all
    arguments that I tried

As I said, this worked without problems some two months ago, thankful for help with this issue.

Calimo
  • 7,510
  • 4
  • 39
  • 61
  • 1
    It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. Have you loaded other packages? What does `environment(roc)` return? – MrFlick Sep 13 '22 at 12:38
  • 1
    You may have a local function called `roc()` in your workspace, or have another package attached that also has a function with that name. Use `pROC::roc()` to be sure to get the right one. – user2554330 Sep 13 '22 at 14:04

1 Answers1

1

This is covered by the pROC FAQ:

Several packages on CRAN provide alternative roc or auc functions. These packages can interfere with pROC, especially if they are loaded later in the session (and hence appear earlier in the search path).

For instance, here are a few messages you may see if you have the AUC package loaded:

Not enough distinct predictions to compute area under the ROC curve.

Error in roc(outcome ~ ndka, data = aSAH) : unused argument (data = aSAH)

If that happens, you should unload the package by typing detach("package:AUC"). To find out where the function is coming from, simply type its name on the R prompt:

> roc
function (predictions, labels)
{
[function code]
}
<bytecode: 0x7fdb71d32ed0>
<environment: namespace:AUC>

The line at the bottom indicates that the function comes from the AUC package.

In addition, you may have defined a roc function yourself. In this case, rm(roc) will solve the problem.

Alternatively you can refer to the pROC version of the function specifically through their namespace:

pROC::auc(pROC::roc(aSAH$outcome, aSAH$ndka))

The FAQ carries on by providing a list of possibly conflicting packages.

Calimo
  • 7,510
  • 4
  • 39
  • 61