*! version 1.0.0 30mar2026

Title

midas hsruc -- Hierarchical Summary Relative Utility Curve Analysis
for diagnostic test accuracy meta-analysis

Syntax

midas_hsruc
[, options]

Required
prevalence(#) disease prevalence in target population (0 < # < 1)

Threshold grid
thresholds(numlist) custom threshold probabilities

npoints(#) number of equispaced grid points; default is 99

Utility metrics
mrs compute Mean Risk Stratification (Katki 2019)

nbgain compute net benefit gain over treat-all

inb compute incremental net benefit

allmetrics compute all utility metrics

optimal identify optimal cost-effective threshold

Cost-effectiveness (for INB)
screencost(#) cost of screening test; default is 0

treatcost(#) cost of treatment; default is 0

lyg(#) life-years gained per true positive; default is 1

Prediction
prediction compute 95% prediction intervals for utility using
between-study heterogeneity

Reporting
level(#) confidence level; default is level(95)

notable suppress detailed output table

nograph suppress graphical output

saving(filename) save utility curve data to filename

midas_hsruc is a post-estimation command. It must follow a MIDAS
estimation command: midas mle, midas mh, midas hmc, or
midas inla.

Description

midas_hsruc derives the Hierarchical Summary Relative Utility Curve
(HSRUC) from the bivariate random-effects model estimates stored by a prior
MIDAS estimation command. It translates the summary sensitivity, specificity,
and likelihood ratios into decision-analytic metrics that quantify the
clinical value of a diagnostic test across a range of threshold probabilities.

The command produces six families of output:

1. Net benefit (Vickers and Elkin 2006): the number of true positives
per patient examined, net of the harm from false positives, at each threshold
probability.

2. Relative utility (Baker et al. 2009): net benefit normalised by
the maximum achievable (perfect-test) net benefit, yielding a 0-to-1 scale.
The area under this curve (WAU-HSRUC) provides a single-number summary of
clinical utility.

3. Standardised net benefit: equivalent to relative utility; at the
treatment threshold equal to prevalence, sNB equals the Youden index.

4. Mean Risk Stratification (Katki 2019): the test's ability to
separate patients into distinct risk groups.

5. Incremental net benefit (Katki and Bebu 2021): net benefit
adjusted for screening and treatment costs.

6. Prediction intervals: the range of utility expected in a new
clinical setting, reflecting between-study heterogeneity.

A four-panel graph is produced by default: Decision Curve, HSRUC (Relative
Utility), Net Benefit Gain, and Number Needed to Test.

Options

Required

prevalence(#) specifies the disease prevalence in the target clinical
population. This is required because predictive values, net benefit, and all
derived utility metrics depend on prevalence. If omitted, the command attempts
to use the median prevalence stored by the estimation command.

Threshold grid

thresholds(numlist) specifies a custom list of threshold probabilities
at which utility metrics are evaluated. Values must be strictly between 0
and 1. If not specified, an equispaced grid of npoints() values is
generated.

npoints(#) specifies the number of equispaced grid points for the
threshold probability axis. Default is 99, yielding thresholds at 0.01,
0.02, ..., 0.99.

Utility metrics

mrs computes the Mean Risk Stratification statistic (Katki 2019),
which measures the test's ability to assign patients to meaningfully different
risk categories.

nbgain computes the net benefit gain of the test strategy over the
treat-all strategy at each threshold.

inb computes the Incremental Net Benefit (Katki and Bebu 2021),
which incorporates screening and treatment costs. Requires screencost(),
treatcost(), and optionally lyg().

allmetrics is equivalent to specifying mrs, nbgain,
inb, and optimal simultaneously.

optimal identifies the threshold probability that maximises net benefit.

Cost-effectiveness

screencost(#) specifies the cost of the screening/diagnostic test
per patient. Used only with inb.

treatcost(#) specifies the cost of treatment per patient. Used only
with inb.

lyg(#) specifies the life-years gained per true positive treated.
Default is 1. Used only with inb.

Prediction

prediction computes 95% prediction intervals for sensitivity,
specificity, and net benefit in a hypothetical new clinical setting. These
intervals reflect between-study heterogeneity (tau1, tau2) and are always
wider than confidence intervals for the summary estimates.

Reporting

level(#) specifies the confidence level for intervals. Default is 95.

notable suppresses the detailed table of utility metrics at selected
thresholds.

nograph suppresses the four-panel combined graph.

saving(filename) saves the full utility curve dataset (one row per
threshold) to filename. Variables saved include: pt (threshold),
nb (net benefit), ru (relative utility), snb (standardised
NB), nnt (number needed to test), mrs_v (MRS), and inb_v
(INB).

Examples

Setup: fit bivariate model first

. use http://fmwww.bc.edu/repec/bocode/m/midas_example_data.dta, clear

. gen study = _n

. midas mle tp fp fn tn, id(study) hetstats hsroc

Basic HSRUC at 20% prevalence

. midas_hsruc, prevalence(0.20)

All metrics with prediction intervals

. midas_hsruc, prevalence(0.20) allmetrics prediction

Cost-effectiveness analysis

. midas_hsruc, prevalence(0.15) inb screencost(50) treatcost(5000) lyg(3)

After Bayesian estimation

. midas mh tp fp fn tn, id(study) covariance(cholesky) chains(4) mcsize(20000)

. midas_hsruc, prevalence(0.30) prediction

Custom thresholds and save data

. midas_hsruc, prevalence(0.25) thresholds(0.05 0.10 0.15 0.20 0.30 0.50) saving(utility.dta)

Suppress graph, display table only

. midas_hsruc, prevalence(0.20) nograph

Stored results

midas_hsruc stores the following in e():

Scalars

e(N) number of studies

e(prevalence) target prevalence

e(Se) summary sensitivity

e(Sp) summary specificity

e(LRp) positive likelihood ratio

e(LRn) negative likelihood ratio

e(DOR) diagnostic odds ratio

e(youden) Youden index (Se + Sp - 1)

e(alpha) HSROC accuracy parameter

e(theta) HSROC threshold parameter

e(beta) HSROC asymmetry parameter

e(s2alpha) variance of accuracy

e(s2theta) variance of threshold

e(wau_hsruc) weighted area under HSRUC (0 = useless, 1 = perfect)

e(auc_nb) area under net benefit curve

e(opt_pt) optimal threshold probability

e(max_nb) maximum net benefit

e(pt_low) lower bound of positive-NB range

e(pt_high) upper bound of positive-NB range

e(useful_low) lower bound of test-useful range

e(useful_high) upper bound of test-useful range

With prediction:

e(pred_se_lo) prediction interval lower bound for Se

e(pred_se_hi) prediction interval upper bound for Se

e(pred_sp_lo) prediction interval lower bound for Sp

e(pred_sp_hi) prediction interval upper bound for Sp

e(nb_best) best-case NB at optimal threshold

e(nb_worst) worst-case NB at optimal threshold

Macros

e(cmd) midas_hsruc

e(title) Hierarchical Summary Relative Utility Curve Analysis

Methods and formulas

midas_hsruc reads the bivariate model parameters from e(b) and
e(bsum) stored by a prior MIDAS estimation command and derives clinical
utility metrics as follows.

HSROC transformation. The bivariate parameters (mu1, mu2, tau1-squared,
tau2-squared, rho) are transformed to the Rutter-Gatsonis HSROC
parameterisation:

alpha = mu1 + mu2 (overall accuracy = log DOR)

theta = mu1 - mu2 (threshold)

beta = (tau1-squared - tau2-squared) / (tau1-squared + tau2-squared)
(asymmetry)

sigma-squared-alpha = tau1-squared + tau2-squared + 2*rho*tau1*tau2

sigma-squared-theta = tau1-squared + tau2-squared - 2*rho*tau1*tau2

Net benefit (Vickers and Elkin 2006). At threshold probability pt with
prevalence pi:

NB(pt) = Se * pi - (1 - Sp)(1 - pi) * pt / (1 - pt)

Relative utility (Baker et al. 2009):

RU(pt) = NB(pt) / pi

At pt = pi, RU equals the Youden index J = Se + Sp - 1.

WAU-HSRUC. The weighted area under the relative utility curve is computed
by trapezoidal integration of RU(pt) over the threshold grid. WAU-HSRUC = 1
for a perfect test and 0 for a useless test.

Mean Risk Stratification (Katki 2019):

MRS(pt) = pi * Se * (1 - pt) + (1 - pi) * Sp * pt

Incremental net benefit (Katki and Bebu 2021):

INB = NB * LYG - ScreenCost / TreatCost

Prediction intervals. Under the bivariate model, a future study's true
accuracy is drawn from N(mu1, tau1-squared) and N(mu2, tau2-squared). The
95% prediction interval for sensitivity is expit(mu1 +/- 1.96*tau1) and
analogously for specificity. Best-case and worst-case net benefits are
computed at these prediction bounds.

References

Baker SG, Kramer BS, Srivastava S. 2009. Markers for early detection of
cancer: statistical guidelines for nested case-control studies.
Medical Decision Making 29: 247-256.

Harbord RM, Deeks JJ, Egger M, Whiting P, Sterne JAC. 2007. A unification
of models for meta-analysis of diagnostic test accuracy studies.
Biostatistics 8: 239-251.

Katki HA. 2019. Quantifying the clinical utility of genomic tests using mean
risk stratification. Statistics in Medicine 38: 2943-2955.

Katki HA, Bebu I. 2021. Identifying the most useful markers by decision and
cost analysis. Journal of the Royal Statistical Society, Series A
184: 887-903.

Reitsma JB, Glas AS, Rutjes AWS, Scholten RJPM, Bossuyt PM, Zwinderman AH.
2005. Bivariate analysis of sensitivity and specificity produces informative
summary measures in diagnostic reviews.
Journal of Clinical Epidemiology 58: 982-990.

Rutter CM, Gatsonis CA. 2001. A hierarchical regression approach to
meta-analysis of diagnostic test accuracy evaluations.
Statistics in Medicine 20: 2865-2884.

Vickers AJ, Elkin EB. 2006. Decision curve analysis: a novel method for
evaluating prediction models. Medical Decision Making 26: 565-574.

Vickers AJ, van Calster B, Steyerberg EW. 2019. A simple, step-by-step
guide to interpreting decision curve analysis.
Diagnostic and Prognostic Research 3: 18.

Author

Ben Adarkwa Dwamena, MD

Clinical Associate Professor Emeritus of Radiology

Division of Nuclear Medicine and Molecular Imaging

University of Michigan

ben@bennybeaubooks.com

www.bennybeaubooks.com