SensSpec: Calculate sensitivity and specificity

View source: R/SensSpec.R

SensSpecR Documentation

Calculate sensitivity and specificity

Description

SensSpec() is a function for calculating overall sensitivity and specificity, modality-specific sensitivity and specificity, and reader-specific sensitivity and specificity within each modality.

Usage

SensSpec(
  data,
  Modality,
  Reader,
  Case = NULL,
  D,
  Y,
  percentage = FALSE,
  digits = max(1L, getOption("digits") - 3L)
)

Arguments

data

A data frame containing the modality identifiers (Modality), the reader identifiers (Reader), the case identifiers (Case), the true disease status (D), and the binary diagnostic test result (Y).

Modality

Variable specifying the modality identifiers.

Reader

Variable specifying the reader identifiers.

Case

Variable specifying the case identifiers. This variable is not directly used in the calculation of sensitivity and specificity in SensSpec(). Default: NULL.

D

Variable specifying the true disease status, coded as 1 for diseased cases and 0 for non-diseased cases.

Y

Variable specifying the binary diagnostic test result, coded as 1 for test-positive results and 0 for test-negative results.

percentage

Logical indicating whether the results should be reported as percentages rather than decimal proportions. Default: FALSE.

digits

Number of significant digits used to format the reported results. Default: max(1L, getOption("digits") - 3L).

Value

An object of class SensSpec containing the following components:

Overall Result

Overall sensitivity and specificity.

Modality-specific Result

Modality-specific sensitivity and specificity.

Reader-specific Modality-specific Result

Reader- and modality-specific sensitivity and specificity.

digits

Number of significant digits used to format the reported results.

Readers

Unique reader identifiers in the input data.

Modalities

Unique modality identifiers in the input data.

The results for SensSpec objects can be printed with print.SensSpec.

References

Yerushalmy, J. (1947). Statistical Problems in Assessing Methods of Medical Diagnosis, with Special Reference to X-Ray Techniques. Public Health Reports (1896-1970), 62(40), 1432–1449.

See Also

print.SensSpec

Examples

## Load example data
data(VanDyke)

## Return the first parts of an object
head(VanDyke)

## Extract unique modalities
unique(VanDyke$treatment)

## Extract Unique readers
unique(VanDyke$reader)

## Create binary test results (Y_ijk)
VanDyke$Y <- as.numeric(VanDyke$rating >= 3)

## Example usage of SensSpec function:
# Report results as decimals
senspe_result1 <- SensSpec(data = VanDyke, Modality = treatment,
                           Reader = reader, Case = case,
                           D = truth, Y = Y, percentage = FALSE, digits = 3)

# Report results as percentage points
senspe_result2 <- SensSpec(data = VanDyke, Modality = treatment,
                           Reader = reader, Case = case,
                           D = truth, Y = Y, percentage = TRUE, digits = 1)


MRMCbinary documentation built on March 23, 2026, 5:07 p.m.