Analysis of Diagnostic Accuracy Measures

Theodora Chatzimichail, MD  
tc@hcsl.com

Hellenic Complex Systems Laboratory, Kostis Palamas 21, 66131 Drama, Greece.

Initialization Code

sens[x_,μD_,μH_,σD_,σH_]:=
1-CDF[NormalDistribution[μD,σD],InverseCDF[NormalDistribution[μH,σH],x]];
spec[x_,μD_,μH_,σD_,σH_]:=
CDF[NormalDistribution[μH,σH],InverseCDF[NormalDistribution[μD,σD],1-x]];

dppv[x_,μD_,μH_,σD_,σH_,pd_]:=(x pd)/(x pd+(1-spec[x,μD,μH,σD,σH])(1-pd));
dnpv[x_,μD_,μH_,σD_,σH_,pd_]:=(spec[x,μD,μH,σD,σH](1-pd))/(spec[x,μD,μH,σD,σH](1-pd)+(1-x)pd);

dor(x_,μD_,μH_,σD_,σH_):=x/(((1 - x)*(1 - spec[x, μD, μH, σD, σH]))/
   spec[x, μD, μH, σD, σH]);
dplr[x_,μD_,μH_,σD_,σH_]:=x/(1-spec[x,μD,μH,σD,σH]);
dnlr[x_,μD_,μH_,σD_,σH_]:=(1-x)/spec[x,μD,μH,σD,σH];

hppv[x_,μD_,μH_,σD_,σH_,pd_]:=(sens[x,μD,μH,σD,σH]pd)/(sens[x,μD,μH,σD,σH]pd+(1-pd)(1-x));
hnpv[x_,μD_,μH_,σD_,σH_,pd_]:=x(1-pd)/(x(1-pd)+(pd(1-sens[x,μD,μH,σD,σH])));

hor[x_,μD_,μH_,σD_,σH_]:=x sens[x, μD, μH, σD, σH]/((1 - x)(1 - sens[x, μD, μH, σD, σH]));
hplr[x_,μD_,μH_,σD_,σH_]:=(1/(1-x))sens[x,μD,μH,σD,σH];
hnlr[x_,μD_,μH_,σD_,σH_]:=(1/x)(1-sens[x,μD,μH,σD,σH]);

Manipulate[
Which[
vs==0,
Which[
plot==0,
Plot[Tooltip[dppv[x,μD,μH,σD,σH,pd],"PPV curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"sensitivity","PPV"},PlotLabel->Row[{"PPV curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==1,
Plot[Tooltip[dnpv[x,μD,μH,σD,σH,pd],"NPV curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"sensitivity","NPV"},PlotLabel->Row[{"NPV curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==2,
Plot[Tooltip[dor[x,μD,μH,σD,σH],"odds ratio curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"sensitivity","OR"},PlotLabel->Row[{"OR curve"}],PlotStyle->{ RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==3,
Plot[Tooltip[dplr[x,μD,μH,σD,σH],"LR+ curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"sensitivity","LR+"},PlotLabel->Row[{"LR+ curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==4,
Plot[Tooltip[dnlr[x,μD,μH,σD,σH],"LR- curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"sensitivity","LR-"},PlotLabel->Row[{"LR- curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}]
],
vs==1,
Which[
plot==0,
Plot[Tooltip[hppv[x,μD,μH,σD,σH,pd],"PPV curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"specificity","PPV"},PlotLabel->Row[{"PPV curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==1,
Plot[Tooltip[hnpv[x,μD,μH,σD,σH,pd],"NPV curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"specificity","NPV"},PlotLabel->Row[{"NPV curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==2,
Plot[Tooltip[hor[x,μD,μH,σD,σH],"OR curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"specificity","OR"},PlotLabel->Row[{"OR curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==3,
Plot[Tooltip[hplr[x,μD,μH,σD,σH],"LR+ curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"specificity","LR+"},PlotLabel->Row[{"LR+ curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}],
plot==4,
Plot[Tooltip[hnlr[x,μD,μH,σD,σH],"LR- curve"],{x,0.001,0.999},AspectRatio->1,AxesLabel->{"specificity","LR-"},PlotLabel->Row[{"LR- curve"}],PlotStyle->{RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{350,375}]
]
],
{{plot,0,"plot"},{0->"PPV",1->"NPV",2->"OR",3->"LR+",4-> "LR-"},ControlPlacement->Top},
{{vs,0,"versus"},{0->"sensitivity",1->"specificity"},ControlPlacement->Top},
Style["prevalence of disease",Bold],
{{pd,0.05,"prevalence"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Style["nondiseased population",Bold],
{{μH,0,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σH,1,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Style["diseased population",Bold],
{{μD,3.67,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,1,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
SaveDefinitions->True,AutorunSequencing->{1,2,6},TrackedSymbols->True,ControlPlacement->Left]

Description

This Demonstration shows plots of various accuracy measures for diagnostic tests on normally distributed nondiseased and diseased populations. This is done for differing prevalence of the disease, taking into account mean and standard deviations of the populations. The mean and standard deviations are expressed in arbitrary units. The measures considered are the positive prognostic value ("PPV"), the negative prognostic value ("NPV"), the (diagnostic) odds ratio ("OR"), the likelihood ratio for a positive result ("LR+"), and the likelihood ratio for a negative result ("LR-"). The measures are plotted against the sensitivity or the specificity of the test, which can be selected by clicking the respective button.

Snapshots

Details

The measures that are used in the evaluation of the clinical accuracy of a diagnostic test applied to a diseased or nondiseased population can be calculated as functions of the sensitivity or the specificity of the test. Sensitivity is the fraction of the diseased population with a positive test result, while specificity is the fraction of the nondiseased population with a negative test result. If we denote by sens the sensitivity, spec the specificity, and pr the prevalence, we have: 
PPV=((sens×pr)/(sens×pr+(1-spec)(1-pr))), NPV=((spec(1-pr))/(spec(1-pr)+(1-sens)pr)), OR=(sens/(1-sens))/((1-spec)/spec), LR+ =(sens/(1-spec)), LR- =((1-sens)/spec).

In the thumbnail and the snapshots, the population data describes a bimodal distribution of serum glucose measurements in non-diabetic and diabetic populations [2].

This Demonstration is a simplified version of another Demonstration [1], and is appropriate as an educational tool for medical students.

References

[1] A. T. Hatjimihail, "Uncertainty of Measurement and Diagnostic Accuracy Measures", Wolfram Demonstrations Project, 2009. Available at: demonstrations.wolfram.com/UncertaintyOfMeasurementAndDiagnosticAccuracyMeasures.

[2] T. O. Lim, R. Bakri, Z. Morad, and M. A. Ham id, "Bimodality in Blood Glucose Distribution: Is It Universal?", Diabetes Care, 25(12), 2002 pp. 2212–2217.

Keywords

sensitivity
specificity
diagnostic test
clinical accuracy
diagnostic accuracy
normal distribution
binormal distribution
positive predictive value
negative predictive value
likelihood ratio
odds ratio

Related Links

Uncertainty of Measurement and Diagnostic Accuracy Measures

Disclaimer of Warranties

The notebook is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or Hellenic Complex Systems Laboratory or any of its members be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the notebook or the use or other dealings in the notebook.

About

Analysis of Diagnostic Accuracy Measures
Version Number 1.1.0
Hellenic Complex Systems Laboratory 2021
Initially published at: https://demonstrations.wolfram.com/AnalysisOfDiagnosticAccuracyMeasures/
Based on Uncertainty of Measurement and Diagnostic Accuracy Measures
The notebook is distributed under  an Attribution - NonCommercial - ShareAlike 4.0 International Creative Commons License.