View source: R/classification.R
LL.ROC | R Documentation |
Generate a ROC curve plotting the false-positive rate against the true-positive rate at different cut-off values across the observed-score scale.
LL.ROC(
x = NULL,
reliability,
min = 0,
max = 1,
truecut,
true.model = "4P",
failsafe = TRUE,
l = 0,
u = 1,
AUC = FALSE,
maxJ = FALSE,
maxAcc = FALSE,
locate = NULL,
raw.out = FALSE,
grainsize = 100
)
x |
A vector of observed results. |
reliability |
The reliability coefficient of the test. |
min |
The minimum possible value to attain on the observed-score scale. |
max |
The maximum value possible to attain on the test. Default is 1 (assumes that the values contained in |
truecut |
The true point along the x-scale that marks the categorization-threshold. |
true.model |
The probability distribution to be fitted to the moments of the true-score distribution. Options are |
failsafe |
If true-model == "4P": Whether to engage a fail-safe reverting to a two-parameter true-score distribution solution should the four-parameter fitting procedure produce impermissible results. Default is TRUE (engage fail-safe in the event of impermissible estimates). |
l |
If |
u |
If |
AUC |
Logical. Calculate and include the area under the curve? Default is |
maxJ |
Logical. Mark the point along the curve where Youden's J statistic is maximized? Default is |
maxAcc |
Logical. Mark the point along the curve where the Accuracy statistic is maximized? Default is |
locate |
Ask the function to locate the cut-point at which sensitivity or NPV is greater than or equal to some value, or specificity or PPV is lesser than or equal to some value. Take as input a character-vector of length 2, with the first argument being which index is to be found (e.g., "sensitivity"), and the second argument the value to locate (e.g., "0.75"). For example: c("sensitivity", "0.75"). |
raw.out |
Give raw coordinates as output rather than plot? Default is |
grainsize |
Specify the number of cutoff-points for which the ROC curve is to be calculated. The greater this number the greater the accuracy. Default is 100 points. |
A plot tracing the ROC curve for the test, or matrix of coordinates if raw.out is TRUE
.
# Generate some fictional data. Say, 1000 individuals take a test with a
# maximum score of 100 and a minimum score of 0.
set.seed(1234)
testdata <- rbinom(1000, 100, rBeta.4P(1000, 0.25, 0.75, 5, 3))
hist(testdata / 100, xlim = c(0, 1), freq = FALSE)
# Suppose the cutoff value for attaining a pass is 50 items correct.
# Suppose further that the reliability of the test-scores were estimated to
# 0.75. To produce a plot with an ROC curve using LL.ROC(), along with the
# AUC statistics and the points at which Youden's J. is maximized:
LL.ROC(x = testdata, reliability = 0.7, truecut = 50, min = 0, max = 100,
AUC = TRUE, maxJ = TRUE)
# Or to locate the point at which accuracy is maximized:
LL.ROC(x = testdata, reliability = 0.7, truecut = 50, min = 0, max = 100,
maxAcc = TRUE)
# Using the example data above, the function can be instructed to locate an
# operational cut-point at which sensitivity or specificity is equal to or
# greater than some specified value by specifying the "locate" argument with
# c("statistic", value). For example, to locate the operational cut-point at
# which sensitivity is first equal to or greater than 0.9:
LL.ROC(testdata, reliability = 0.7, min = 0, max = 100, truecut = 50,
locate = c("sensitivity", 0.9))
# For Negative Predictive value, the point at which it is equal or greater:
LL.ROC(testdata, reliability = 0.7, min = 0, max = 100, truecut = 50,
locate = c("NPV", 0.9))
# And so on for other statistics such as Specificity and Positive Predictive
# Value.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.