Computes a comprehensive confusion matrix and diagnostic performance metrics
for binary classification tests.
Usage
diag_test(
data,
test,
ref,
positive = NULL,
test_positive = NULL,
conf.level = 0.95
)
Arguments
- data
A data.frame containing the test and reference variables.
- test
Unquoted name of the diagnostic test variable (binary).
- ref
Unquoted name of the reference standard variable (binary).
- positive
Character or numeric. Level representing "Positive" in REFERENCE.
- test_positive
Character or numeric. Level representing "Positive" in TEST.
- conf.level
Numeric. Confidence level (0-1). Default: 0.95.
Value
An object of class diag_test containing:
table: 2x2 confusion matrix
stats: Data frame with metrics and CIs
labels: List with labels used
sample_size: Total valid observations
Details
Confusion Matrix Structure
The function creates a 2x2 confusion matrix:
TP: True Positives
TN: True Negatives
FP: False Positives
FN: False Negatives
Metrics Calculated
Sensitivity, Specificity, PPV, NPV
Accuracy, Prevalence
Likelihood Ratios, Youden's Index, F1 Score