Compares rule-out and rule-in cutoffs, classification results, and performance metrics across multiple cutoff methods.
Arguments
- percentile_result
Output list from
derive_cutoffs_percentile().- sensspec_result
Output list from
derive_cutoffs_sensspec().- outcome
Character, name of binary disease outcome column (0/1).
Examples
n <- 500
set.seed(123)
# outcome
DISEASE <- rbinom(n, 1, 0.35)
# biomarker depends on disease
PTAU <- rnorm(n, mean = 25 + 10 * DISEASE, sd = 8)
# confounders (optional noise)
AGE <- round(rnorm(n, 73, 7))
SEX <- sample(c(0,1), n, replace = TRUE)
BMI <- rnorm(n, 25, 4)
HTN <- rbinom(n, 1, 0.3)
DM <- rbinom(n, 1, 0.2)
df <- data.frame(PTAU, AGE, SEX, BMI, HTN, DM, DISEASE)
res <- adjust_score(
df,
biomarker = "PTAU",
outcome = "DISEASE",
confounders = c("AGE","SEX","BMI","HTN","DM")
)
#> number of iterations= 704
#> Setting levels: control = 0, case = 1
#> Setting direction: controls < cases
cutoffs_p <- derive_cutoffs_percentile(res, biomarker = "PTAU")
#> Number of cases below low_thresh = 0.05 is too small, so fallback to 5th percentile of biomarker was used. Consider using another low_thresh value if your dataset is small.
cutoffs_r <- derive_cutoffs_sensspec(res, biomarker = "PTAU", outcome = "DISEASE")
#> Warning: Sensitivity target not achievable -> using 5th percentile of adjusted risk as fallback threshold.
#> Warning: Specificity target not achievable -> using 95th percentile of adjusted risk as fallback threshold.
compare_performance(cutoffs_p, cutoffs_r, outcome = "DISEASE")
#> Method c_L c_H Sensitivity Specificity PPV NPV
#> 1 Percentile-based 13.309 36.847 1 0.500 0.755 1
#> 2 ROC-based 9.468 44.063 1 0.722 0.808 1
#> Percent_Indeterminate
#> 1 74.6
#> 2 92.2
