Traditional variable selection methods (e.g., backward elimination, LASSO) optimise statistical performance metrics such as AUC or deviance. However, the best-performing model in statistical terms does not necessarily yield the best clinical utility when predictor costs (test harms) are accounted for. The NBvarsel package implements a variable selection framework based on cross-validated Net Benefit, the standard metric for clinical utility in decision curve analysis.
The core function nb_varsel() evaluates predictor subsets by their contribution to clinical decision-making, optionally adjusted for test harms. It supports:
Exhaustive and groupwise (backward elimination) search strategies
Predictor costs (per-variable or grouped)
Restricted cubic splines for continuous predictors
Interaction terms
Permutation importance scores
Parallel computation
2 Simple illustration
Reproducible section
This section is fully reproducible as the data generation is included in the code.
Let us consider a hypothetical scenario with four predictors, two continuous (X1, X3) and two binary (X2, X4), used to predict a binary outcome Y. The true data-generating model is:
logit(Y) = −3 + 3X1 + 2X2 + 0.1X3 − 0.05X4 (1)
In this model, X1 and X2 are strongly predictive, X3 and X4 are weakly predictive, and the outcome has a prevalence of approximately 64%. Each predictor is associated with a test harm: X1 and X3 (harm = 0.05), X2 (harm = 0.025), and X4 (harm = 0.00005).
Table 1: Results for the simple illustration. Models are ranked by cost-adjusted Net Benefit.
Included predictors
AUC
Brier Score
Total Cost
Avg. Adj. Net Benefit
Avg. Net Benefit
X1, X4
0.906
0.115
0.05005
0.104
0.154
X1
0.907
0.114
0.05000
0.102
0.152
X1, X2
0.925
0.102
0.07500
0.099
0.174
X1, X2, X4
0.925
0.102
0.07505
0.099
0.174
X1, X3
0.906
0.114
0.10000
0.056
0.156
X1, X3, X4
0.906
0.114
0.10005
0.055
0.155
X1, X2, X3, X4
0.925
0.102
0.12505
0.049
0.174
X1, X2, X3
0.925
0.101
0.12500
0.048
0.173
X4
0.521
0.217
0.00005
0.000
0.000
X2
0.589
0.210
0.02500
−0.025
0.000
X2, X4
0.571
0.211
0.02505
−0.025
0.000
X3
0.532
0.217
0.05000
−0.050
0.000
X3, X4
0.520
0.217
0.05005
−0.050
0.000
X2, X3
0.607
0.210
0.07500
−0.075
0.000
X2, X3, X4
0.593
0.211
0.07505
−0.075
0.000
The variable importance of each feature is shown in Figure 1, illustrating the main contributors to utility. In Figure 2, the all-subset plot shows the evolution of the average adjusted Net Benefit across all possible combinations. It is immediately apparent that including X1 improves performance. This simple illustration demonstrates how the best subset of predictors in statistical terms does not necessarily translate to better cost-utility.
Figure 1: Net benefit based variable importance for the simple illustration.
Figure 2: All subset plot for the simple illustration.
3 Case study — fabricated clinical data
Reproducible section
This section uses fabricated data designed to resemble a clinical prediction setting. All data generation code is included.
We now demonstrate the methodology on a more realistic scenario. We simulate a dataset mimicking a heart failure readmission prediction setting with 10 predictors and a binary outcome (readmitted within 30 days vs. not). Predictors are grouped into three cost categories:
Clinical history (no cost): patient age, prior admission, specialist centre, symptom severity
Figure 4 and Figure 5 show the all-subset plots. Each point represents a model. The heatmap below indicates which predictors are included. Note the difference in ranking when costs are accounted for.
Figure 7: Decision curve analysis comparing net benefit across methods.
Figure 8: Decision curve analysis comparing harm-adjusted net benefit.
Figure 7 shows the standard decision curve analysis. Figure 8 shows the same curves after subtracting each method’s test costs, highlighting the advantage of cost-aware variable selection.
4 Case study — ADNEX ovarian tumour data
Pre-computed results
The original patient-level data from the IOTA consortium are not publicly available. This section uses pre-computed results shipped with the package (adnex_results). The analysis code is shown for transparency but is not executed.
This section demonstrates the methodology on real clinical data used to develop the ADNEX model for classifying ovarian tumours as benign or malignant. The data come from the International Ovarian Tumour Analysis (IOTA) consortium, phases 1–3, and comprise 16 candidate predictors.
4.1 Predictors and cost structure
Predictors are grouped into three cost categories reflecting the clinical workflow:
Clinical history (no cost): patient age, family history of ovarian cancer, oncology centre, pain
The exhaustive search evaluated all 65,535 (2^16 - 1) predictor combinations using 20-fold cross-validation with restricted cubic splines (3 knots) and permutation importance.
The best model retains 13 of the 16 predictors, excluding CA-125, family history, and maximum solid diameter. Despite using fewer predictors, the cost-adjusted Net Benefit is maximised because the excluded predictors contributed little utility relative to their cost.
Table 7: Top models per predictor count from the ADNEX exhaustive search
4.2.3 Visualisation
Code
VIF_plot(adnex_results)$plot
Figure 9: Variable importance for the ADNEX case study. Bars show the average drop in Net Benefit when each predictor is permuted.
Figure 9 shows that the proportion solid component and colour score are the most important predictors for clinical utility, followed by maximum lesion diameter and oncology centre status.
Figure 10: All subset plot (Net Benefit) for the ADNEX case study.
Figure 11: All subset plot (cost-adjusted Net Benefit) for the ADNEX case study.
Figure 10 and Figure 11 show the all-subset plots. The heatmap indicates which predictors are included in each model. The best model’s predictors are highlighted in bold. Note that cost adjustment changes the ranking: models that include the blood biomarker (CA-125) are penalised, shifting the optimum toward models relying on ultrasound and clinical history alone.
5 Summary
This vignette demonstrated the NBvarsel workflow:
nb_varsel() identifies optimal predictor subsets by maximising cross-validated Net Benefit, optionally adjusted for test costs.
all_subset_plot() provides a comprehensive view of model performance and predictor inclusion across all evaluated combinations.
External validation of selected models can be performed using standard discrimination metrics such as AUC.
The key insight is that the statistically best-performing model may not be the most clinically useful when predictor costs are taken into account. Cost-aware variable selection via Net Benefit can lead to simpler, cheaper models that maintain or improve clinical utility.