Studio R giving error about "unused arguments" when plotting ROC-curves

560 Views Asked by At

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.

1

There are 1 best solutions below

0
Calimo On

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.