来源
- 包:verification
- 函数:roc.area
- 官方文档:https://www.rdocumentation.org/packages/verification/versions/1.42/topics/roc.area
参数
- obs: 标签(0 或 1)
- pred: 预测值(0-1之间的概率)
输出
- A: AUC值
- n.total: 总的样本个数
- n.events: 正样本个数
- n.noevents: 负样本个数
- p.value: P值 (与随机猜测,即AUC=0.5比较)
样例
a<- c(1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990,
1991, 1992, 1993, 1994, 1995)
b<- c(0,0,0,1,1,1,0,1,1,0,0,0,0,1,1)
c<- c(.8, .8, 0, 1,1,.6, .4, .8, 0, 0, .2, 0, 0, 1,1)
d<- c(.928,.576, .008, .944, .832, .816, .136, .584, .032, .016, .28, .024, 0, .984, .952)
A<- data.frame(a,b,c, d)
names(A)<- c("year", "event", "p1", "p2")
## for model with ties
roc.area(A$event, A$p1)
## for model without ties
roc.area(A$event, A$p2)