Learn R Programming

dentomedical (version 0.2.0)

diag_accuracy: Diagnostic Accuracy Metrics with Optional 2x2 Table

Description

Calculates diagnostic accuracy measures (Sensitivity, Specificity, PPV, NPV, Accuracy, LR+, LR-, DOR) from a binary test and gold standard. Provides 95% confidence intervals using Wilson method for proportions and log method for ratios. Optionally, prints a descriptive 2x2 table.

Usage

diag_accuracy(data, test_col, gold_col, descriptive = FALSE)

Value

A flextable object summarizing diagnostic metrics with 95% CI. If descriptive = TRUE, also prints a 2x2 table of counts.

Arguments

data

A data frame containing the test results and gold standard.

test_col

Character. Name of the column in data with test results ("positive"/"negative").

gold_col

Character. Name of the column in data with gold standard results ("positive"/"negative").

descriptive

Logical. If TRUE, prints a descriptive 2x2 table with counts (TN, TP, FP, FN). Default is FALSE.

Examples

Run this code
diagnostic_data <- data.frame(
  test = c("positive","negative","positive","
  negative","positive","negative","positive","negative"),
  goldstandard = c("positive","positive","negative",
  "negative","positive","negative","positive","negative")
)
diag_accuracy(diagnostic_data, test_col = "test",
gold_col = "goldstandard",
descriptive = FALSE)

Run the code above in your browser using DataLab