prevalence_adjust: Adjust Predicted Probabilities for Population Prevalence

View source: R/helpers.R

prevalence_adjustR Documentation

Adjust Predicted Probabilities for Population Prevalence

Description

Recalibrates predicted probabilities from a risk score model fitted on a study sample to a target population with a different outcome prevalence. The adjustment shifts the log-odds by the difference between the logit of the target prevalence and the logit of the study prevalence, leaving the discrimination (AUC, AUPRC) unchanged while improving calibration.

Usage

prevalence_adjust(predicted_probs, study_prevalence, target_prevalence)

Arguments

predicted_probs

Numeric vector of predicted probabilities from the risk score model (values in (0, 1)).

study_prevalence

Numeric scalar. Outcome prevalence in the sample used to fit the model (i.e. mean(y) on the training data).

target_prevalence

Numeric scalar. Expected outcome prevalence in the target population to which predictions will be applied.

Value

Numeric vector of prevalence-adjusted predicted probabilities with the same length as predicted_probs.

Examples

y <- breastcancer[[1]]
X <- as.matrix(breastcancer[,2:ncol(breastcancer)])
mod <- risk_mod(X, y, lambda0 = 0.01)
preds <- predict(mod, type = "response")[,1]
adj <- prevalence_adjust(preds, study_prevalence = mean(y),
                         target_prevalence = 0.10)

riskscores documentation built on Aug. 24, 2026, 5:07 p.m.