as.cst | R Documentation |
These functions produce a cst
object, which is a data frame blessed to be used for various
ROC analysis tools. A cst
object is an arbitrary data frame with at least two columns: one named target
, a logical indicating to which class the trial belongs (in detection theory named a "target" vs "non-target" trial, but other fields have different names such as "same-source" vs "difference source"). The second required column is score
, which is either an ordered factor or a numeric, where higer numbers indicate a higher likelihood that the trial is of the kind target==TRUE
.
as.cst
takes as input a data frame, checks for the columns and their types, and blesses it to be of class cst
. cst.tnt
takes two arguments: one for target scores and one for non-targets scores, and it produces a data frame of class cst
as.cst(df)
cst.tnt(tar, non)
df |
A data frame, containing columns |
tar, non |
Target and non-target scores. Either a vector of values, or a file name that is scanned for a vector of values. |
The data frame df
may contain additionmal columns, which are maintained in further processing. They can be used for conditioning the ROC analysis, e.g., in plot.cond
.
The arguments tar
and non
can either refer to a vector of values or to a file name. In the latter case, the file is opened and an attempt is made to read numeric values from the file using scan
.
A data frame of class cst
with at least the columns target
and score
of the right type.
David A. van Leeuwen
## create normally disributed target and nontarget scores around 0 and 1.
df <- data.frame(target=rep(c(F,T),each=100), score=rnorm(200, mean=rep(c(0,1), each=100)))
x <- as.cst(df)
roc(x)
## read in data from vectors
y <- cst.tnt(rnorm(100, 1), rnorm(1000, 0))
## read in data from files
z <- cst.tnt("targets.txt", "nontargets.txt")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.