prevalence.scaling <- function(model.P, model.prevalence = 0.5, target.prevalence = 0.1) { ## Purpose: Convert a probability based on training data prevalence to ## a probability based on target population prevalence. ## Arguments: ## model.P: a vector of model-based probability (risk score) ## model.prevalence: prevalence of the model's training data ## target.prevalence: prevalence of the target population ## Return: ## a vector of scaled probabilities reflecting the prevalence of the target population ## Author: Feiming Chen ## ________________________________________________ ## convert a probability to the odds O <- function(p) p / (1-p) 1 / ( 1 + O(model.prevalence) / O(target.prevalence) / O(model.P) ) } if (F) { # Unit Test set.seed(1) prevalence.scaling(runif(5)) ## [1] 0.038614 0.061784 0.129688 0.523663 0.027304 }
Wednesday, February 24, 2021
Prevalence Scaling
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment