findRocTpAtFp: Find the ROC true-positive (TP) rate for a given...

Description Usage Arguments Value Author(s) See Also Examples

Description

Find the ROC true-positive (TP) rate for a given false-positive (FP) rate.

Usage

1
2
3
## Default S3 method:
findRocTpAtFp(truth, data, fpRate, acc=0.001, recall=NULL, hasNAs=TRUE, isOrdered=FALSE,
  ..., .checkArgs=TRUE, verbose=FALSE)

Arguments

truth

A numeric vector of length N.

data

A numeric vector of length N.

fpRate

A double in [0,1] specifying the target FP rate.

acc

A double specifying the accuracy.

recall

(Optional) Unless truth is given as binary \{0,1\} values, it can be reclassified as such.

hasNAs

If TRUE (FALSE), ROC is calculated as if there are (no) missing values. [Not used!]

isOrdered

If FALSE, data is ordered, otherwise not.

...

Not used.

.checkArgs

If TRUE, arguments are validated, otherwise not.

verbose

See Verbose.

Value

Returns a list with elements:

tpRateEst,tpRateEstRange

The estimated TP rate with lower and upper limits.

fpRateEst,fpRateEstRange

The estimated FP rate with lower and upper limits. This should be close to the request target FP rate.

fpRate

The target FP rate (equals the corresponding argument).

callRate

Fraction of data points called. If less than one, for instance data points with missing values may have been excluded.

orderedIdxs

The indices of the ordered data points corresponding to the lower and upper limits.

w

The weights of the lower and upper limits.

Author(s)

Henrik Bengtsson

See Also

findRocSmoothingForTpAtFp(). scanRocTpAtFp().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
n <- 1000
x <- rnorm(n=n, mean=0, sd=1)
y <- rnorm(n=n, mean=2, sd=1)

T <- integer(2*n)
T[1:n] <- 1L

D <- c(x,y)

fit <- fitRoc(T,D)
par(xaxs="i", yaxs="i")
xlim <- c(0, 0.5)
plot(fit$roc, type="l", lwd=3, xlim=xlim, ylim=c(1-xlim[2], 1))

adj <- c(-0.05,-0.2)
for (fpRate in c(0.2, 0.4)) {
  fit <- findRocTpAtFp(T,D, fpRate=fpRate)
  fp <- fit$fpRateEst
  tp <- fit$tpRateEst
  lines(x=c(0,fp,fp), y=c(tp,tp,xlim[2]))
  text(x=fp, y=xlim[2], sprintf("FP rate: %.3f", fp), srt=90, adj=adj)
  text(x=0, y=tp, sprintf("TP rate: %.3f", tp), adj=adj)
}

HenrikBengtsson/aroma.cn.eval documentation built on Dec. 9, 2019, 12:16 p.m.