REGRESSION MODELLING FOR HEALTH PRACTITIONERS · CHAPTER 14
Predictive Modelling, Risk and Fairness
Regression models are often used to predict the risk of an outcome for an individual patient. In clinical practice, risk scores guide screening, treatment decisions and communication of prognosis. Developing and evaluating prediction models require careful attention to model performance and ethical considerations.
Developing Risk Prediction Models
A typical prediction study includes the following steps:
Define the outcome and eligible population. For example, predicting 5‑year cardiovascular disease risk among adults aged 40–79.
Specify candidate predictors. These may include demographics, clinical measurements, laboratory values and prior history.
Preprocess the data. Handle missing values (see Chapter 12), code categorical variables and scale continuous variables if necessary.
Split the data. Use a training set to develop the model and a validation or test set for evaluation; alternatively, use cross‑validation or bootstrapping (Chapter 13).
Fit the model. Logistic regression or survival models are common for binary and time‑to‑event outcomes; machine learning methods may also be used. Choose appropriate functional forms (linear, nonlinear, interactions).
Evaluate performance. Assess discrimination, calibration and, if relevant, decision‑analytic metrics.
Update or recalibrate. Adjust the model based on validation results; perform external validation in independent datasets.
Discrimination and Calibration
Discrimination measures how well a model separates individuals who experience the event from those who do not. The area under the receiver operating characteristic curve (AUC or c‑statistic) summarises discrimination, with a value of 1 indicating perfect discrimination and 0.5 indicating no better than chance. Sensitivity and specificity at particular risk thresholds are also used.
Calibration reflects the agreement between predicted probabilities and observed outcomes. A well‑calibrated model provides accurate risk estimates across all levels of predicted risk. Even a model with good discrimination can be poorly calibrated. Poor calibration may lead to systematically over‑ or underestimating risk, which can misinform patients and clinicians. The TRIPOD guidelines recommend reporting both discrimination and calibration. Calibration can be assessed using calibration plots, the calibration intercept and slope, and the Hosmer–Lemeshow test. Recalibration may be necessary when applying a model to a new population.
Fairness and Bias
In addition to technical performance, prediction models must be fair. Bias in training data, algorithmic design or implementation can lead to unequal predictions across subgroups. In medical AI, skewed datasets, algorithmic flaws and systemic inequities contribute to bias. To mitigate bias, data sets should be diverse and representative; reweighing techniques and synthetic data may help. Bias‑aware training methods, such as adversarial debiasing and federated learning, can enhance model fairness. Transparency and accountability are essential; models should explain their decisions and undergo regular fairness assessments. Without proactive interventions, biased models may reinforce healthcare inequities.
Worked Example
We build a model to predict 5‑year cardiovascular disease (CVD) risk using age, systolic blood pressure (SBP), cholesterol and smoking status. We compare discrimination, calibration and fairness across sexes.
Worked example
R (using pROC and
rms):
library(pROC)
library(rms)
data <- read.csv("cvd_data.csv")
fit <- lrm(CVD ~ Age + SBP + Cholesterol + Smoking, data = data)
# Discrimination
prob <- predict(fit, type = "fitted")
roc_obj <- roc(data$CVD, prob)
print(auc(roc_obj))
# Calibration curve
cal <- calibrate(fit, method = "boot", B = 200)
plot(cal)
# Fairness: compare predicted risk by sex
data$pred <- prob
aggregate(pred ~ Sex, data = data, FUN = mean)
aggregate(CVD ~ Sex, data = data, FUN = mean)
Python (using scikit_learn and
sklearn_calibration):
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score, brier_score_loss
from sklearn.calibration import calibration_curve
import matplotlib.pyplot as plt
data = pd.read_csv("cvd_data.csv")
X = data[["Age", "SBP", "Cholesterol", "Smoking"]]
y = data["CVD"]
model = LogisticRegression(max_iter=1000)
model.fit(X, y)
probs = model.predict_proba(X)[:,1]
# Discrimination
print("AUC:", roc_auc_score(y, probs))
# Calibration plot
frac_pos, mean_pred = calibration_curve(y, probs, n_bins=10)
plt.plot(mean_pred, frac_pos, marker='o')
plt.plot([0,1],[0,1], linestyle='--')
plt.xlabel('Mean predicted risk')
plt.ylabel('Observed proportion')
plt.show()
# Fairness: predicted vs observed risk by sex
data['pred'] = probs
print(data.groupby('Sex')['pred'].mean())
print(data.groupby('Sex')['CVD'].mean())
Julia (using GLM.jl and
ROCR.jl):
using CSV, DataFrames, GLM, ROCAnalysis
data = CSV.read("cvd_data.csv", DataFrame)
form = @formula(CVD ~ Age + SBP + Cholesterol + Smoking)
model = glm(form, data, Binomial(), LogitLink())
pred = predict(model)
# Discrimination
auc_val = auc(ROCAnalysis.roc(pred, data.CVD))
println(auc_val)
# Calibration: group into deciles
data.pred = pred
cutoffs = quantile(data.pred, 0:0.1:1)
data.group = cut(data.pred, cutoffs, labels=1:10)
df_cal = combine(groupby(data, :group),
:pred => mean => :mean_pred,
:CVD => mean => :obs_rate)
# Fairness
println(combine(groupby(data, :Sex), :pred => mean, :CVD => mean))
Interpretation
Discrimination summarises how well the model ranks individuals by risk, whereas calibration assesses whether predicted probabilities agree with observed outcomes. Even highly discriminative models may provide unreliable risk estimates; therefore both metrics should be reported. Fairness requires that the model’s performance and predictions are comparable across demographic groups. Evaluate predicted and observed risks by subgroup and use bias‑mitigating techniques when disparities are detected.
Exercises
Using the
cvd_data.csvdataset, fit a logistic regression model to predict CVD. Compute the AUC and plot a calibration curve. Interpret the results.Compare predicted risks for male and female patients. Are there differences between predicted and observed risk across sexes? Discuss possible reasons and remedies.
Implement a recalibration by fitting a logistic regression model that uses the logit of the original model’s predictions as a single predictor. Does calibration improve?
Investigate an algorithmic debiasing technique (e.g., reweighing or adversarial debiasing) using a toy dataset. How does it affect fairness metrics?
Code examples use illustrative datasets. Supply data with the named columns to run them.