如何在R pROC中制作多因素模型?

问题描述 投票:0回答:1

我有一个数据表,其中包含响应“y”和一些预测变量,其中包括“X1”和“X2”。我可以使用 pROC 创建两个单因素模型:

roc1 <- roc(data$y, data$X1)
roc2 <- roc(data$y, data$X2)

但我正在尝试计算二因素模型的 ROC AUC:

t1 = data$X1
t2 = data$X2
t12 = cbind(t1, t2)
roc12 <- roc(data$y, t12)

并收到错误消息:

Response and predictor must be vectors of the same length.

有没有办法在 pROC 中制作多因素模型?

r machine-learning
1个回答
0
投票

手册

https://cran.r-project.org/web/packages/pROC/pROC.pdf
第69至75页描述了pROC::roc函数的功能。

函数的第二个参数称为

predictor
并解释为

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 for roc_, and optionally quoted for roc.data.frame (non-standard evaluation or NSE).

(数字或有序)向量不能包含两列。因此,这不是该功能提供的一部分。

© www.soinside.com 2019 - 2024. All rights reserved.