specificity.given.PPV <- function(Sensitivity = 0.5, PPV = 0.3, Prevalence = 0.1) { ## Purpose: calculate specificity based on sensitivity, PPV, and prevalence. ## ## Arguments: ## Sensitivity: performance target for sensitivity ## PPV: performance target for PPV (positive predictive value) ## Prevalence: assumed disease prevalence in the target population ## ## Return: ## Specificity: expected performance target for specificity ## ## Author: Feiming Chen (Copyright 2024; GPLv3; No Warranty; gnu.org/licenses) ## ________________________________________________ ## Assume 1000 patients N <- 1000 n.pos <- N * Prevalence n.neg <- N - n.pos n.true.pos <- n.pos * Sensitivity n.false.neg <- n.pos - n.true.pos Specificity <- 1 - n.true.pos / (n.neg * (PPV / (1 - PPV))) cat("What should the Specificity be if we want", paste0(round(100*Sensitivity), "%"), "Sensitivity and", paste0(round(100*PPV), "%"), "PPV under", paste0(round(100*Prevalence), "%"), "Prevalence assumption?\n") cat("Specificity =", round(Specificity, 3), "\n\n") make.Sankey.diagram.for.Dx.performance(Sensitivity = Sensitivity, Specificity = Specificity, Prevalence = Prevalence) } if (F) { # Unit Test specificity.given.PPV(Sensitivity = 0.7, PPV = 0.3, Prevalence = 0.05) }
Tuesday, October 1, 2024
Expected Specificity Given Sensitivity, PPV, and Prevalence Assumption
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment