1
|
|
# pROC: Tools Receiver operating characteristic (ROC curves) with
|
2
|
|
# (partial) area under the curve, confidence intervals and comparison.
|
3
|
|
# Copyright (C) 2010-2014 Xavier Robin, Alexandre Hainard, Natacha Turck,
|
4
|
|
# Natalia Tiberti, Frédérique Lisacek, Jean-Charles Sanchez
|
5
|
|
# and Markus Müller
|
6
|
|
#
|
7
|
|
# This program is free software: you can redistribute it and/or modify
|
8
|
|
# it under the terms of the GNU General Public License as published by
|
9
|
|
# the Free Software Foundation, either version 3 of the License, or
|
10
|
|
# (at your option) any later version.
|
11
|
|
#
|
12
|
|
# This program is distributed in the hope that it will be useful,
|
13
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
|
# GNU General Public License for more details.
|
16
|
|
#
|
17
|
|
# You should have received a copy of the GNU General Public License
|
18
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
|
|
20
|
|
lines.roc <- function(x, ...) {
|
21
|
1
|
UseMethod("lines.roc")
|
22
|
|
}
|
23
|
|
|
24
|
|
lines.roc.formula <- function(x, data, subset, na.action, ...) {
|
25
|
1
|
data.missing <- missing(data)
|
26
|
1
|
call <- match.call()
|
27
|
1
|
names(call)[2] <- "formula" # forced to be x by definition of lines
|
28
|
1
|
roc.data <- roc.utils.extract.formula(formula=x, data, subset, na.action, ...,
|
29
|
1
|
data.missing = data.missing,
|
30
|
1
|
call = call)
|
31
|
1
|
if (length(roc.data$predictor.name) > 1) {
|
32
|
0
|
stop("Only one predictor supported in 'lines.roc'.")
|
33
|
|
}
|
34
|
1
|
response <- roc.data$response
|
35
|
1
|
predictor <- roc.data$predictors[, 1]
|
36
|
1
|
roc <- roc(response, predictor, ...)
|
37
|
1
|
lines.roc.roc(roc, ...)
|
38
|
1
|
roc$call <- match.call()
|
39
|
1
|
invisible(roc)
|
40
|
|
}
|
41
|
|
|
42
|
|
lines.roc.default <- function(x, predictor, ...) {
|
43
|
0
|
roc <- roc(x, predictor, ...)
|
44
|
0
|
lines.roc.roc(roc, ...)
|
45
|
0
|
roc$call <- match.call()
|
46
|
0
|
invisible(roc)
|
47
|
|
}
|
48
|
|
|
49
|
|
lines.roc.smooth.roc <- lines.smooth.roc <- function(x, ...) {
|
50
|
1
|
lines.roc.roc(x, ...) # force usage of lines.roc.roc
|
51
|
|
}
|
52
|
|
|
53
|
|
lines.roc.roc <- function(x, lwd=2, ...) {
|
54
|
1
|
suppressWarnings(lines(x$sp, x$se, lwd=lwd, ...))
|
55
|
1
|
invisible(x)
|
56
|
|
}
|