I have a data table with a response 'y' and some predictors, 'X1' and 'X2' among them. I can create two one-factor models with pROC:
roc1 <- roc(data$y, data$X1)
roc2 <- roc(data$y, data$X2)
But I'm trying to calculate ROC AUC for two-factor model:
t1 = data$X1
t2 = data$X2
t12 = cbind(t1, t2)
roc12 <- roc(data$y, t12)
and get an error message:
Response and predictor must be vectors of the same length.
Is there a way to make multifactor models in pROC?
The functionality of the pROC::roc
function is described in the manual at https://cran.r-project.org/web/packages/pROC/pROC.pdf pages 69 to 75.
The second argument to the function is called predictor
and explaines as
a numeric or ordered vector of the same length than response, containing the predicted value of each observation. If the first argument was a data.frame,
predictor
should be the name of the column in data containing the predictor, quoted forroc_
, and optionally quoted forroc.data.frame
(non-standard evaluation or NSE).`
A (numeric or ordered) vector cannot contain two columns. Therefore this is not part of what the function offers.