*! version 1.0 14 Nov 2025

Title

confreg -- Confusion matrix (Accuracy measures) estimated by
mixed regression and nlcom

Syntax

confreg
varlist(min=2
max=3)
[if]
[,
options]

Optional
id(passthru) If modalities are measured on the same id,
specify the id variable. The used model becomes a mixed random intercepts by id.

randomeffect(string) String for adding random effects to the model.
Possibly succeeded by the random effect of the ids (||id:).

adjustment(varlist fv) Add adjustment variables to the model.

coleq(string) Add coleq text to the stored matrices.

prevalence(numlist max=1 >0 <1) Specify prevalence to use.
Default is the sample prevalence.

vce(passthru) Set vce options.

stub(string) Stub to add the names of the returned estimates.

scale(#) Default value is 100.

Description

confreg estimates sensitivity and specificity for a single modality
by OLS regressing the binary values from the modality on the pathology using
robust variance estimation.

The area under the ROC curve (AUC) is estimated here as the mean of
sensitivity and specificity for the modality.

There are non-linear formulas for estimating the PPV, NPV, and accuracy
using prevalence, sensitivity, and specificity (Bland, 2015, subsection 20.6).

To model more modalities, confreg stacks the values of each modality and
the pathology and adds a categorical modality variable.

Using the stacked dataset, sensitivity and specificity are estimated by
regressing the modality values on the pathology values and the categorical
modality variable, with robust variance estimation.

If modalities are measured on the same patients, estimation uses random
intercepts by ID.

The AUC, PPV, NPV, and accuracy are estimated from the prevalence,
sensitivity, and specificity as described.

Examples

Getting example data:

`"webuse hanley, clear"'

Reviewer classified 109 tomographic images using a 5-point scale,
from 1 = definitely normal to 5 = definitely abnormal.

Patients: 58 normal, 51 abnormal.

Making data long:

`"generate id = _n"'

`"generate rating2 = rating >= 2"'

`"generate rating3 = rating >= 3"'

`"drop rating"'

`"reshape long rating, i(id) j(point)"'

`"label define point 2 "rating 2" 3 "rating 3" "'

`"label values point point"'

Using confreg to report sensitivities, specificities, and AUCs
at values 2 and 3:

`"confreg disease rating point, id(id) vce(robust)"'

The sensitivities are highly correlated, likewise for the specificities:

`"matlist r(se_sp_auc_corr), tw(32)"'

Note that sensitivities and specificities are uncorrelated:

Report all the accuracy measures:

`"matlist r(confreg), tw(32)"'

Retrieve sensitivities, specificities, and AUCs for estimation:

`"estimates restore _se_sp_auc"'

See the estimation table from nlcom:

`"nlcom"'

Test if the sensitivities are the same:

`"test se2 = se3"'

Stored results

Matrices

r(se_sp_auc)

r(se_sp_auc_corr)

r(acc_ppv_npv)

r(confreg)

Estimates based on nlcom

_se_sp_auc For testing sensitivities, specificities, and AUCs.

_acc_ppv_npv For testing accuracies, PPVs, and NPVs.

References

Bland, Martin. 2015. An Introduction to Medical Statistics. Fourth edition.
Oxford University Press.

Cohen, Jérémie F, Daniël A Korevaar, Douglas G Altman, et al. 2016.
"STARD 2015 Guidelines for Reporting Diagnostic Accuracy Studies:
Explanation and Elaboration." BMJ Open (LONDON) 6 (11): e012799–.

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com