Relation

A software tool for exploring the relation between diagnostic accuracy and measurement uncertainty

Theodora Chatzimichail, MD  
tc@hcsl.com
Aristides T. Hatjimihail, MD, PhD
 ath@hcsl.com

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

Clear["`*"];
Off[General::stop];
tsens[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) (1+Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))])
tspec[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))]
ttp[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) (1+Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))]) pd;
ttn[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))](1-pd);
tfp[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1-(1/2) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))])(1-pd);
tfn[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) (1-(Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))]))pd;
toda[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) (pd+pd Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))]-(-1+pd) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))])
tppv[t_,μD_,μH_,σD_,σH_,pd_,u_]:=pd (1+Erf[((-t+μD)/((Sqrt[2]) (Sqrt[(u^2)+((σD)^2)])))])/(2-pd Erfc[((-t+μD)/((Sqrt[2]) (Sqrt[(u^2)+((σD)^2)])))]+(-1+pd) Erfc[((-t+μH)/((Sqrt[2]) (Sqrt[(u^2)+((σH)^2)])))])
tnpv[t_,μD_,μH_,σD_,σH_,pd_,u_]:=1/(1-(pd Erfc[(-t+μD)/(√2 √((u^2)+((σD)^2)))])/((-1+pd) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))]))
tdor[t_,μD_,μH_,σD_,σH_,pd_,u_]:=((-2+Erfc[(-t+μD)/(√2 √((u^2)+((σD)^2)))]) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))])/(Erfc[(-t+μD)/(√2 √((u^2)+((σD)^2)))] (-2+Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))]))
tplr[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1+Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))])/(1+Erf[(-t+μH)/(√2 √((u^2)+((σH)^2)))])
tnlr[t_,μD_,μH_,σD_,σH_,pd_,u_]:=Erfc[(-t+μD)/(√2 √((u^2)+((σD)^2)))]/Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))]
tyi[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) (-1+Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))]+Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))]);
ted[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) √((((1+Erf[(-t+μH)/(√2 √((u^2)+((σH)^2)))]))^2)+((Erfc[(-t+μD)/(√2 √((u^2)+((σD)^2)))])^2))
tcz[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/4) (1+Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))]) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))];
ttr[t_,μD_,μH_,σD_,σH_,pd_,u_,{rt_,rtp_,rtn_,rfp_,rfn_}]:=(1/2) (2 (rfp+rt)+pd (rfn-2 rfp+rtp)+pd (-rfn+rtp) Erf[(-t+μD)/(√2 √((u^2)+((σD)^2)))]+(-1+pd) (rfp-rtn) Erfc[(-t+μH)/(√2 √((u^2)+((σH)^2)))])
sens[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=
(1/2) (1+Erf[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])
spec[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=
(1/2) Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]
tp[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=sn pd
tn[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=-(1/2) (-1+pd) Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]
fp[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) (-1+pd) (-2+Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))])
fn[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=(1-sn)pd
oda[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=pd sn-(1/2) (-1+pd) Erfc[((-μD+μH+(Sqrt[2]) (Sqrt[(u^2)+((σD)^2)]) InverseErfc[2-2 sn])/((Sqrt[2]) (Sqrt[(u^2)+((σH)^2)])))]
ppv[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=(2 pd sn)/(2+2 pd (-1+sn)+(-1+pd) Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))])
npv[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=1/(1+(2 pd (-1+sn))/((-1+pd) Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]))
cnpv[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=1-1/(1+(2 pd (-1+sn))/((-1+pd) Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]))
dor[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/(-1+sn))sn (1+2/(-2+Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]))
plr[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=(2 sn)/(1+Erf[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))])
nlr[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=-((2 (-1+sn))/Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))])
yi[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=-1+sn+(1/2) Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]
ed[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=√((((-1+sn))^2)+(1/4) (((1+Erf[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]))^2))
cz[sn_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) sn Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]
tr[sn_,μD_,μH_,σD_,σH_,pd_,u_,{rt_,rtp_,rtn_,rfp_,rfn_}]:=rfp+rt+pd (rfn-rfp-rfn sn+rtp sn)+(1/2) (-1+pd) (rfp-rtn) Erfc[(-μD+μH+√2 √((u^2)+((σD)^2)) InverseErfc[2-2 sn])/(√2 √((u^2)+((σH)^2)))]
htp[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) pd (1+Erf[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])
htn[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=sp(1-pd)
hfp[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(1-sp)(1-pd)
hfn[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) pd Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))]
hoda[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(1-pd) sp+(1/2) pd (1+Erf[((μD-μH+(Sqrt[2]) (Sqrt[(u^2)+((σH)^2)]) InverseErfc[2 sp])/((Sqrt[2]) (Sqrt[(u^2)+((σD)^2)])))])
hppv[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=1+(2 (-1+pd) (-1+sp))/(-2-2 (-1+pd) sp+pd Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])
hnpv[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(2 (-1+pd) sp)/(2 (-1+pd) sp-pd Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])
hdor[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/(-1+sp))sp (1-2/Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])
hplr[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(-2+Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])/(2 (-1+sp))
hnlr[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/(2 sp))Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))]
hyi[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=sp-(1/2) Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))]
hed[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=√((((-1+sp))^2)+(1/4) ((Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])^2))
hcz[sp_,μD_,μH_,σD_,σH_,pd_,u_]:=(1/2) sp (1+Erf[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))])
htr[sp_,μD_,μH_,σD_,σH_,pd_,u_,{rt_,rtp_,rtn_,rfp_,rfn_}]:=rfp-pd rfp+rt+pd rtp+(-1+pd) (rfp-rtn) sp+(1/2) pd (rfn-rtp) Erfc[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2 sp])/(√2 √((u^2)+((σD)^2)))]
roc[x_,μD_,μH_,σD_,σH_,u_]:=
(1/2) (1+Erf[(μD-μH+√2 √((u^2)+((σH)^2)) InverseErfc[2-2 x])/(√2 √((u^2)+((σD)^2)))])
auc[μD_,μH_,σD_,σH_,u_]:=(1/2) Erfc[(-μD+μH)/(√2 √(2 (u^2)+((σD)^2)+((σH)^2)))]
tsd[t_,μD_,μH_,σD_,σH_,pd_,u_]:=(((1-tsens[t,μD,μH,σD,σH,pd,u]))^2)+(((1-tspec[t,μD,μH,σD,σH,pd,u]))^2)
min[f_,{μD_,μH_,σD_,σH_,pd_,u_,l___List}]:=z/.NMinimize[f@@{z,μD,μH,σD,σH,pd,u,l},z][[2]]
max[f_,{μD_,μH_,σD_,σH_,pd_,u_,l___List}]:=z/.NMaximize[f@@{z,μD,μH,σD,σH,pd,u,l},z,MaxIterations->10000][[2]]
damr[μD_,μH_,σD_,σH_,pd_,u1_,u2_]:=
Text@Grid[Quiet[Transpose[
{{"","AUC","AOC"},
{"first test",
NumberForm[Re[N@auc[μD,μH,σD,σH,u1]],{8,3}],
NumberForm[1.0-Re[N@auc[μD,μH,σD,σH,u1]],{8,3}]},
{"second test",
NumberForm[Re[N@auc[μD,μH,σD,σH,u2]],{8,3}],
NumberForm[1.0-Re[N@auc[μD,μH,σD,σH,u2]],{8,3}]},
{"relative difference",
NumberForm[(Re[N@auc[μD,μH,σD,σH,u1]]-Re[N@auc[μD,μH,σD,σH,u2]])/Re[N@auc[μD,μH,σD,σH,u1]],{8,3}],
NumberForm[(Re[N@auc[μD,μH,σD,σH,u2]]-Re[N@auc[μD,μH,σD,σH,u1]])/(1-Re[N@auc[μD,μH,σD,σH,u1]]),{8,3}]}}]],
Frame->All, FrameStyle->Gray,Spacings->{0.5,1},ItemSize->Automatic]
dam1[t_,μD_,μH_,σD_,σH_,pd_,u1_,u2_,{rt_,rtp_,rtn_,rfp_,rfn_}]:=
Text@Grid[Quiet[Transpose[
{{Style["calculation of diagnostic accuracy measures",Bold],Style["diagnostic threshold: "<>ToString[N[t,2]],Red],Style["diagnostic accuracy measures",Bold],"sensitivity","specificity","overall diagnostic accuracy","positive predictive value", "negative predictive value", "diagnostic odds ratio", "likelihood ratio for a positive result","likelihood ratio for a negative result","Euclidean distance","Youden's index","concordance probability","risk"},
{SpanFromLeft,SpanFromLeft,SpanFromLeft,"Se","Sp","ODA","PPV", "NPV", "DOR", "LR+","LR-","ED","J","CZ","R"},
{SpanFromLeft,
SpanFromLeft,
Style["first test",Bold],
NumberForm[Re[N@tsens[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tspec[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@toda[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tppv[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tnpv[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tdor[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tplr[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tnlr[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tyi[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@ted[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tcz[t,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@ttr[t,μD,μH,σD,σH,pd,u1,{rt,rtp,rtn,rfp,rfn}]],{8,3}]},
{SpanFromLeft,
SpanFromLeft,
Style["second test",Bold],
NumberForm[Re[N@tsens[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tspec[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@toda[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tppv[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tnpv[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tdor[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tplr[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tnlr[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tyi[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@ted[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tcz[t,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@ttr[t,μD,μH,σD,σH,pd,u2,{rt,rtp,rtn,rfp,rfn}]],{8,3}]},{SpanFromLeft,
SpanFromLeft,
Style["relative difference",Bold],
NumberForm[Re[N@rdeltaf[tsens,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tspec,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[toda,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tppv,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tnpv,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tdor,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tplr,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tnlr,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tyi,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[ted,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[tcz,{t,μD,μH,σD,σH,pd,u1,u2}]],{8,3}],
NumberForm[Re[N@rdeltaf[ttr,{t,μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}]],{8,3}]}
}]],
Frame->All, FrameStyle->Blend[{Blue,Cyan},0.35],Spacings->{1,1},ItemSize->Automatic]
dam2[m_,{μD_,μH_,σD_,σH_,pd_,u1_,u2_,{rt_,rtp_,rtn_,rfp_,rfn_}}]:=Block[{t1,t2},
t1=Switch[m,j,max[tyi,{μD,μH,σD,σH,pd,u1}],ed,min[ted,{μD,μH,σD,σH,pd,u1}],cz,max[tcz,{μD,μH,σD,σH,pd,u1}],r,min[ttr,{μD,μH,σD,σH,pd,u1,{rt,rtp,rtn,rfp,rfn}}]];t2=Switch[m,j,max[tyi,{μD,μH,σD,σH,pd,u2}],ed,min[ted,{μD,μH,σD,σH,pd,u2}],cz,max[tcz,{μD,μH,σD,σH,pd,u2}],r,min[ttr,{μD,μH,σD,σH,pd,u2,{rt,rtp,rtn,rfp,rfn}}]];
Text@Grid[Quiet[Transpose[
{{tl[m],"",Style["diagnostic threshold",Red],Style["diagnostic accuracy measures",Bold],"sensitivity","specificity","overall diagnostic accuracy","positive predictive value", "negative predictive value", "diagnostic odds ratio", "likelihood ratio for a positive result","likelihood ratio for a negative result","Euclidean distance","Youden's index","concordance probability","risk"},
{SpanFromLeft,SpanFromLeft,SpanFromLeft,SpanFromLeft,"Se","Sp","ODA","PPV", "NPV", "DOR", "LR+","LR-","ED","J","CZ","R"},
{SpanFromLeft,
Style["first test",Bold],
Style[NumberForm[N[t1],{8,3}],Red],
"",
NumberForm[Re[N@tsens[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tspec[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@toda[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tppv[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tnpv[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tdor[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tplr[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tnlr[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tyi[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@ted[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@tcz[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[Re[N@ttr[t1,μD,μH,σD,σH,pd,u1,{rt,rtp,rtn,rfp,rfn}]],{8,3}]},
{SpanFromLeft,
Style["second test",Bold],
Style[NumberForm[N[t2],{8,3}],Red],
"",
NumberForm[Re[N@tsens[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tspec[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@toda[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tppv[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tnpv[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tdor[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tplr[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tnlr[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tyi[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@ted[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@tcz[t2,μD,μH,σD,σH,pd,u2]],{8,3}],
NumberForm[Re[N@ttr[t2,μD,μH,σD,σH,pd,u2,{rt,rtp,rtn,rfp,rfn}]],{8,3}]},
{SpanFromLeft,
Style["relative difference",Bold],
Style[NumberForm[((N[t1]-N[t2])/(N[t1])),{8,3}],Red],
"",
NumberForm[(Re[N@tsens[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tsens[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tsens[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tspec[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tspec[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tspec[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@toda[t1,μD,μH,σD,σH,pd,u1]]-Re[N@toda[t2,μD,μH,σD,σH,pd,u2]])/Re[N@toda[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tppv[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tppv[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tppv[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tnpv[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tnpv[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tnpv[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tdor[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tdor[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tdor[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tplr[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tplr[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tplr[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tnlr[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tnlr[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tnlr[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tyi[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tyi[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tyi[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@ted[t1,μD,μH,σD,σH,pd,u1]]-Re[N@ted[t2,μD,μH,σD,σH,pd,u2]])/Re[N@ted[t2,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@tcz[t1,μD,μH,σD,σH,pd,u1]]-Re[N@tcz[t2,μD,μH,σD,σH,pd,u2]])/Re[N@tcz[t1,μD,μH,σD,σH,pd,u1]],{8,3}],
NumberForm[(Re[N@ttr[t1,μD,μH,σD,σH,pd,u1,{rt,rtp,rtn,rfp,rfn}]]-Re[N@ttr[t2,μD,μH,σD,σH,pd,u2,{rt,rtp,rtn,rfp,rfn}]])/Re[N@ttr[t1,μD,μH,σD,σH,pd,u1,{rt,rtp,rtn,rfp,rfn}]],{8,3}]}}]],
Frame->All, FrameStyle->Blend[{Blue,Cyan},0.35],Spacings->{1,1},ItemSize->Automatic]]
txt[f_,m_]:=Switch[f,vf,Switch[m,sns,"Se",spc,"Sp",csens,"CSens",cspec,"CSpec",oda,"ODA",ppv,"PPV",npv,"NPV",dor,"DOR",plr,"LR+",nlr,"LR-",yi,"J",ed,"ED",cz,"CZ",tr,"R"],deltaf,Switch[m,sns,"∆Se",spc,"∆Sp",oda,"∆ODA",ppv,"∆PPV",npv,"∆NPV",dor,"∆DOR",plr,"∆LR+",nlr,"∆LR-",yi,"∆J",ed,"∆ED",cz,"∆CZ",tr,"∆R"], rdeltaf,Switch[m,sns,"∆r(Se)",spc,"∆r(Sp)",oda,"∆r(ODA)",ppv,"∆r(PPV)",npv,"∆r(NPV)",dor,"∆r(DOR)",plr,"∆r(LR+)",nlr,"∆r(LR-)",yi,"∆r(J)",ed,"∆r(ED)",cz,"∆r(CZ)",tr,"∆r(R)"], df,Switch[m,sns,"∂(Se)/∂u",spc,"∂(Sp)/∂u",oda,"∂(ODA)/∂u",ppv,"∂(PPV)/∂u",npv,"∂(NPV)/∂u",dor,"∂(DOR)/∂u",plr,"∂(LR+)/∂u",nlr,"∂(LR-)/∂u",yi,"∂(J)/∂u",ed,"∂(ED)/∂u",cz,"∂(CZ)/∂u",tr,"∂(R)/∂u"],rf,Switch[m,sns,"Se ratio",spc,"Sp ratio",oda,"ODA ratio",ppv,"PPV ratio",npv,"NPV ratio",dor,"DOR ratio",plr,"LR+ ratio",nlr,"LR- ratio",yi,"J ratio",ed,"ED ratio",cz,"CZ ratio",tr,"R ratio"]]
txt[s_]:=Switch[s,sns,"Se",spc,"Sp",thr,"d"]
ltxt[s_]:=Switch[s,sns,"sensitivity (Se)",spc,"specificity (Sp)",thr,"diagnostic threshold (d)"]
pl[f_,m_]:=Switch[f,deltaf,"(" <>txt[vf,m]<>" of the first test - "<>txt[vf,m] <>" of the second test)",rdeltaf,"(" <>txt[vf,m]<>" of the first test - "<>txt[vf,m] <>" of the second test) / (" <>txt[vf,m]<>" of the first test)",rf,"(" <>txt[vf,m]<>" of the first test / "<>txt[vf,m] <>" of the second test)"]
tl[m_]:=Switch[m,j,Style["maximizing Youden's index J optimization",Bold],ed,Style["minimimizing Euclidean distance (ED) optimization",Bold],cz,Style["maximizing concordance probability (CZ) optimization",Bold],r,Style["minimizing risk optimization",Bold]]
mf[ma_,mb_]:=Switch[mb,sns,Switch[ma,oda,oda,ppv,ppv,npv,npv,dor,dor,plr,plr,nlr,nlr,yi,yi,ed,ed,cz,cz,tr,tr],spc,Switch[ma,oda,hoda,ppv,hppv,npv,hnpv,dor,hdor,plr,hplr,nlr,hnlr,yi,hyi,ed,hed,cz,hcz,tr,htr],thr,Switch[ma,sns,tsens,spc,tspec,oda,toda,ppv,tppv,npv,tnpv,dor,tdor,plr,tplr,nlr,tnlr,yi,tyi,ed,ted,cz,tcz,tr,ttr]]
vf[m_,{x_,μD_,μH_,σD_,σH_,pd_,u_,l___List}]:=m@@{x,μD,μH,σD,σH,pd,u,l}
deltaf[m_,{x_,μD_,μH_,σD_,σH_,pd_,u1_,u2_,l___List}]:=m@@{x,μD,μH,σD,σH,pd,u1,l}-m@@{x,μD,μH,σD,σH,pd,u2,l}
rdeltaf[m_,{x_,μD_,μH_,σD_,σH_,pd_,u1_,u2_,l___List}]:=((m@@{x,μD,μH,σD,σH,pd,u1,l}-m@@{x,μD,μH,σD,σH,pd,u2,l})/(m@@{x,μD,μH,σD,σH,pd,u1,l}))
df[m_,{x_,μD_,μH_,σD_,σH_,pd_,uu_,l___List}]:=D[m[x,μD,μH,σD,σH,pd,u,l],u]/.{u->uu}
rf[m_,{x_,μD_,μH_,σD_,σH_,pd_,u1_,u2_,l___List}]:=m@@{x,μD,μH,σD,σH,pd,u1,l}/m@@{x,μD,μH,σD,σH,pd,u2,l}
pro[pr_]:=Switch[pr,True,SetOptions[Plot,PlotRange->Full];
SetOptions[Plot3D,PlotRange->Full];
SetOptions[ContourPlot,PlotRange->Full];SetOptions[ParametricPlot,PlotRange->Full];SetOptions[ParametricPlot3D,PlotRange->Full],False,SetOptions[Plot,PlotRange->Automatic];SetOptions[Plot3D,PlotRange->Automatic];
SetOptions[ContourPlot,PlotRange->Automatic];SetOptions[ParametricPlot,PlotRange->Automatic];SetOptions[ParametricPlot3D,PlotRange->Automatic]];
pp1[ma_,mb_,{μD_,μH_,σD_,σH_,pd_,u1_,u2_,l__List}]:=Text@Labeled[Quiet[ParametricPlot[{{
Switch[mb,tr,tr@@{x,μD,μH,σD,σH,pd,u1,l},_,mb@@{x,μD,μH,σD,σH,pd,u1}],Switch[ma,tr,tr@@{x,μD,μH,σD,σH,pd,u1,l},_,ma@@{x,μD,μH,σD,σH,pd,u1}]},{Switch[mb,tr,tr@@{x,μD,μH,σD,σH,pd,u2,l},_,mb@@{x,μD,μH,σD,σH,pd,u2}],Switch[ma,tr,tr@@{x,μD,μH,σD,σH,pd,u2,l},_,ma@@{x,μD,μH,σD,σH,pd,u2}]}},{x,0.001,0.999},Exclusions->"Singularities",AspectRatio->1,AxesLabel->{txt[vf,mb],txt[vf,ma]},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]},PlotLegends->Placed[{"first test", "second test"},Top], ImageSize->{400,400}]], txt[vf,ma]<>" versus "<> txt[vf,mb]<>" curve",Top]
pp2[f_,m_,{μD_,μH_,σD_,σH_,pd_,u1_,u2_,l___List}]:=Text@Labeled[Quiet[ParametricPlot3D[{{x,spec[x,μD,μH,σD,σH,pd,u1],Switch[m,tr,f@@{tr,{x,μD,μH,σD,σH,pd,u1,l}},_,f@@{mf[m,sns],{x,μD,μH,σD,σH,pd,u1}}]},{x,spec[x,μD,μH,σD,σH,pd,u2],Switch[m,tr,f@@{tr,{x,μD,μH,σD,σH,pd,u2,l}},_,f@@{mf[m,sns],{x,μD,μH,σD,σH,pd,u2}}]}},{x,0.001,0.999},Exclusions->"Singularities",AspectRatio->1,BoxRatios->{1,1,1},AxesLabel->{"Se","Sp",txt[f,m]},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]},PlotLegends->Placed[{"first test", "second test"},Top], ImageSize->{400,400}]], txt[f,m]<>" versus sensitivity (Se) and specificity (Sp) curve",Top]
p1[f_,m_,s_,{μD_,μH_,σD_,σH_,pd_,u1_,u2_,l___List}]:=Text@Labeled[Quiet[Plot[f@@{mf[m,s],{x,μD,μH,σD,σH,pd,u1,u2,l}},Switch[s,thr,{x,Min[μD-3.5σD,μH-3.5σH], Max[μD+3.5σD,μH+3.5σH]},_,{x,0.001,0.999}],Exclusions->"Singularities",AspectRatio->1,AxesLabel->{txt[s],txt[f,m]},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,PlotLegends->Placed[{pl[f,m]},Top], ImageSize->{400,400}]],txt[f,m]<>" versus "<>ltxt[s]<>" curve",Top]
p2[f_,m_,s_,{μD_,μH_,σD_,σH_,pd_,u1_,u2_,l___List}]:=Text@Labeled[Quiet[Plot[{f@@{mf[m,s],{x,μD,μH,σD,σH,pd,u1,l}},f@@{mf[m,s],{x,μD,μH,σD,σH,pd,u2,l}}},Switch[s,thr,{x,Min[μD-3.5σD,μH-3.5σH], Max[μD+3.5σD,μH+3.5σH]},_,{x,0.001,0.999}],Exclusions->"Singularities",AspectRatio->1,AxesLabel->{txt[s],txt[f,m]},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,PlotLegends->Placed[{"first test", "second test"},Top], ImageSize->{400,400}]],txt[f,m]<>" versus "<>ltxt[s]<>" curve",Top]
ppd1[f_,m_,{t_,μD_,μH_,σD_,σH_,u1_,u2_,l___List}]:=Text@Labeled[Quiet[Plot[Switch[m,tr,f@@{ttr,{t,μD,μH,σD,σH,x,u1,u2,l}},_,f@@{mf[m,thr],{t,μD,μH,σD,σH,x,u1,u2}}],{x,0.00000001,0.99999999},Exclusions->"Singularities",AspectRatio->1,AxesLabel->{"v",txt[f,m]},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,PlotLegends->Placed[{pl[f,m]},Top], ImageSize->{400,400}]],txt[f,m]<>" versus "<>"prevalence (v)"<>" curve",Top]
ppd2[f_,m_,{t_,μD_,μH_,σD_,σH_,u1_,u2_,l___List}]:=Text@Labeled[Quiet[Plot[{Switch[m,tr,f@@{ttr,{t,μD,μH,σD,σH,x,u1,l}},_,f@@{mf[m,thr],{t,μD,μH,σD,σH,x,u1}}],Switch[m,tr,f@@{ttr,{t,μD,μH,σD,σH,x,u2,l}},_,f@@{mf[m,thr],{t,μD,μH,σD,σH,x,u2}}]},{x,0.00000001,0.99999999},Exclusions->"Singularities",AspectRatio->1,AxesLabel->{"v",txt[vf,m]},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,PlotLegends->Placed[{"first test", "second test"},Top], ImageSize->{400,400}]],txt[vf,m]<>" versus "<>"prevalence (v) curve",Top]
pum[m_,{t_,μD_,μH_,σD_,σH_,pd_,l___List}]:=Text@Labeled[Quiet[Plot[Switch[m,tr,vf@@{ttr,{t,μD,μH,σD,σH,pd,x,l}},_,vf@@{mf[m,thr],{t,μD,μH,σD,σH,pd,x}}],{x,0,Max[σD,σH]},Exclusions->"Singularities",AspectRatio->1,AxesLabel->{"u",txt[vf,m]},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} , ImageSize->{400,400}]],txt[vf,m]<>" versus standard measurement uncertainty (u) curve",Top]
TabView[{
"ROC curves"->Manipulate[pro[pr];
Switch[f,rf,Column[{Text@Labeled[Plot[{roc[x,μD,μH,σD,σH,u1],roc[ x,μD,μH,σD,σH,u2]},{x,0,1},AspectRatio->1,AxesLabel->{"1-Sp","Se"},AxesOrigin->{0,1},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,PlotLegends->Placed[{"first test", "second test"},Top],ImageSize->{400,400}],"ROC curves",Top],damr[μD,μH,σD,σH,pd,u1,u2]},Center],prf,Text@Labeled[Quiet[ParametricPlot[{{
cnpv@@{x,μD,μH,σD,σH,pd,u1},ppv@@{x,μD,μH,σD,σH,pd,u1}},{cnpv@@{x,μD,μH,σD,σH,pd,u2},ppv@@{x,μD,μH,σD,σH,pd,u2}}},{x,0,1},AspectRatio->1,AxesOrigin->{0,1},PlotPoints->100, MaxRecursion->100,AspectRatio->1,AxesLabel->{"1-NPV","PPV"},PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]},PlotLegends->Placed[{"first test", "second test"},Top], ImageSize->{400,400}]], "PROC curves",Top]],
{{f,rf,"plot"},{rf->"ROC curves",prf->"PROC curves"},ControlPlacement->Left},
{{pr,True,"plot range"},{True->"full",False->"partial"},ControlPlacement->Left},
"",
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left],
"DAM plots"->
TabView[{
"DAM vs threshold"->
Manipulate[pro[pr];
Switch[m,tr,Switch[f,vf,p2[vf,tr,thr,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],df,p2[df,tr,thr,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],deltaf, p1[deltaf,tr,thr,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],rdeltaf, p1[rdeltaf,tr,thr,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],rf, p1[rf,tr,thr,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}]],_,Switch[f,vf,p2[vf,m,thr,{μD,μH,σD,σH,pd,u1,u2}],df,p2[df,m,thr,{μD,μH,σD,σH,pd,u1,u2}],deltaf, p1[deltaf,m,thr,{μD,μH,σD,σH,pd,u1,u2}],rdeltaf, p1[rdeltaf,m,thr,{μD,μH,σD,σH,pd,u1,u2}],rf, p1[rf,m,thr,{μD,μH,σD,σH,pd,u1,u2}]]],
{{f,rf,"type"},{vf->"measures",df->"derivatives",deltaf->"difference",rdeltaf->"relative difference", rf->"ratio"},ControlPlacement->Left},
{{m,tr,"plot"},{sns->"sensitivity",spc->"specificity",oda->"overall diagnostic accuracy (ODA)",ppv->"positive predictive value (PPV)",npv->"negative predictive value (NPV)",dor->"diagnostic odds ratio (DOR)",plr->"likelihood ratio for a positive result (LR+)",nlr-> "likelihood ratio for a negative result (LR-)",yi->"Youden's index J",ed->"Euclidean distance (ED)",cz->"concordance probability (CZ)",tr->"risk (R)"},ControlPlacement->Left},
{{pr,False,"plot range"},{True->"full",False->"partial"},ControlPlacement->Left},
"",
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left],
"DAM vs prevalence"->Manipulate[pro[pr];
Switch[m,tr,Switch[f,vf,ppd2[vf,tr,{x,μD,μH,σD,σH,u1,u2,{rt,rtp,rtn,rfp,rfn}}],df,ppd2[df,tr,{x,μD,μH,σD,σH,u1,u2,{rt,rtp,rtn,rfp,rfn}}],deltaf, ppd1[deltaf,tr,{x,μD,μH,σD,σH,u1,u2,{rt,rtp,rtn,rfp,rfn}}],rdeltaf, ppd1[rdeltaf,tr,{x,μD,μH,σD,σH,u1,u2,{rt,rtp,rtn,rfp,rfn}}],rf, ppd1[rf,tr,{x,μD,μH,σD,σH,u1,u2,{rt,rtp,rtn,rfp,rfn}}]],_,Switch[f,vf,ppd2[vf,m,{x,μD,μH,σD,σH,u1,u2}],df,ppd2[df,m,{x,μD,μH,σD,σH,u1,u2}],deltaf, ppd1[deltaf,m,{x,μD,μH,σD,σH,u1,u2}],rdeltaf, ppd1[rdeltaf,m,{x,μD,μH,σD,σH,u1,u2}],rf, ppd1[rf,m,{x,μD,μH,σD,σH,u1,u2}]]],
{{f,rf,"type"},{vf->"measures",df->"derivatives",deltaf->"difference",rdeltaf->"relative difference", rf->"ratio"},ControlPlacement->Left},
{{m,npv,"plot"},{oda->"overall diagnostic accuracy (ODA)",ppv->"positive predictive value (PPV)",npv->"negative predictive value (NPV)",tr->"risk (R)"},ControlType->PopupMenu, ControlPlacement->Left},
{{pr,True,"plot range"},{True->"full",False->"partial"},ControlPlacement->Left},
"",
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["diagnostic threshold",Bold],
{{x,2.26,"d"},-5Max[σD,σH]Max[μD,μH],Max[μD,μH]+5Max[σD,σH],.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left],
"DAM vs uncertainty"->Manipulate[pro[pr];Switch[m,tr,pum[tr,{x,μD,μH,σD,σH,pd,{rt,rtp,rtn,rfp,rfn}}],_,
pum[m,{x,μD,μH,σD,σH,pd,{rt,rtp,rtn,rfp,rfn}}]],
{{m,dor,"plot"},{sns->"sensitivity Se",spc->"specificity Sp",oda->"overall diagnostic accuracy (ODA)",ppv->"positive predictive value (PPV)",npv->"negative predictive value (NPV)",dor->"diagnostic odds ratio (DOR)",plr->"likelihood ratio for a positive result (LR+)",nlr-> "likelihood ratio for a negative result (LR-)",yi->"Youden's index J",ed->"Euclidean distance (ED)",cz->"concordance product CZ",tr->"risk (R)"},ControlPlacement->Left},
{{pr,False,"plot range"},{True->"full",False->"partial"},ControlPlacement->Left},
"",
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["diagnostic threshold",Bold],
{{x,2.26,"d"},-5Max[σD,σH]Max[μD,μH],Max[μD,μH]+5Max[σD,σH],.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left]},
ImageSize->All],
"DAM relations plots"->
TabView[{
"DAM vs Se or Sp"->Manipulate[pro[pr];
Switch[m,tr,Switch[f,vf,p2[vf,tr,s,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],df,p2[df,tr,s,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],deltaf, p1[deltaf,tr,s,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],rdeltaf, p1[rdeltaf,tr,s,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],rf, p1[rf,tr,s,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}]],_,Switch[f,vf,p2[vf,m,s,{μD,μH,σD,σH,pd,u1,u2}],df,p2[df,m,s,{μD,μH,σD,σH,pd,u1,u2}],deltaf, p1[deltaf,m,s,{μD,μH,σD,σH,pd,u1,u2}],rdeltaf, p1[rdeltaf,m,s,{μD,μH,σD,σH,pd,u1,u2}],rf, p1[rf,m,s,{μD,μH,σD,σH,pd,u1,u2}]]],
{{f,vf,"type"},{vf->"measures",df->"derivatives",deltaf->"difference",rdeltaf->"relative difference", rf->"ratio"},ControlPlacement->Left},
{{m,dor,"plot"},{oda->"overall diagnostic accuracy (ODA)",ppv->"positive predictive value (PPV)",npv->"negative predictive value (NPV)",dor->"diagnostic odds ratio (DOR)",plr->"likelihood ratio for a positive result (LR+)",nlr-> "likelihood ratio for a negative result (LR-)",yi->"Youden's index J",ed->"Euclidean distance (ED)",cz->"concordance probability (CZ)",tr->"risk (R)"},ControlPlacement->Left},
{{s,spc,"versus"},{sns->"sensitivity",spc->"specificity"},ControlPlacement->Left},
{{pr,False,"plot range"},{True->"full",False->"partial"},ControlPlacement->Left},
"",
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left],
"DAM vs Se and Sp"->Manipulate[pro[pr];Switch[m,tr,Switch[f,vf,pp2[vf,tr,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],df,pp2[df,tr,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}]],_,Switch[f,vf,pp2[vf,m,{μD,μH,σD,σH,pd,u1,u2}],df,pp2[df,m,{μD,μH,σD,σH,pd,u1,u2}]]],
{{f,vf,"type"},{vf->"measures",df->"derivatives"},ControlPlacement->Left},
{{m,plr,"plot"},{oda->"overall diagnostic accuracy (ODA)",ppv->"positive predictive value (PPV)",npv->"negative predictive value (NPV)",dor->"diagnostic odds ratio (DOR)",plr->"likelihood ratio for a positive result (LR+)",nlr-> "likelihood ratio for a negative result (LR-)",yi->"Youden's index J",ed->"Euclidean distance (ED)",cz->"concordance probability (CZ)",tr->"risk (R)"},ControlPlacement->Left},
{{pr,False,"plot range"},{True->"full",False->"partial"},ControlPlacement->Left},
"",
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left],
"DAM relations"->Manipulate[pro[pr];
pp1[ma,mb,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],
{{ma,ppv,"plot"},{oda->"overall diagnostic accuracy (ODA)",ppv->"positive predictive value (PPV)",npv->"negative predictive value (NPV)",dor->"diagnostic odds ratio (DOR)",plr->"likelihood ratio for a positive result (LR+)",nlr-> "likelihood ratio for a negative result (LR-)",yi->"Youden's index J",ed->"Euclidean distance (ED)",cz->"concordance probability (CZ)",tr->"risk (R)"},ControlPlacement->Left},
{{mb,npv,"versus"},{oda->"overall diagnostic accuracy (ODA)",ppv->"positive predictive value (PPV)",npv->"negative predictive value (NPV)",dor->"diagnostic odds ratio (DOR)",plr->"likelihood ratio for a positive result (LR+)",nlr-> "likelihood ratio for a negative result (LR-)",yi->"Youden's index J",ed->"Euclidean distance (ED)",cz->"concordance probability (CZ)",tr->"risk (R)"},ControlPlacement->Left},
{{pr,False,"plot range"},{True->"full",False->"partial"},ControlPlacement->Left},
"",
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left]
},
ImageSize->All
],
"DAM calculator"->Manipulate[
dam1[x,μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}],
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["diagnostic threshold",Bold],
{{x,2.26,"d"},Min[μD-3σD,μH-3σH],Max[μD+3σD,μH+3σH],.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Left, Alignment->Top],
"optimal DAM calculator"->Manipulate[
dam2[m,{μD,μH,σD,σH,pd,u1,u2,{rt,rtp,rtn,rfp,rfn}}],
{{m,r,"optimal measure"},{j-> "maximum Youden's index J",ed->"minimum Euclidean distance (ED)",cz->"maximum concordance probability (CZ)",r->"minimum risk (R)"},ControlType->PopupMenu,ControlPlacement->Top},
Style["prevalence of disease",Bold],
{{pd,0.067,"v"},0.00000001,.99,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
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"},
Delimiter,
Style["diseased population",Bold],
{{μD,2.99,"mean"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{σD,0.75,"standard deviation"},0.01,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["standard measurement uncertainty",Bold],
Delimiter,
{{u1,0.023,"first test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{u2,0.23,"second test"},0,6,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
OpenerView[{Style["expected loss",Bold],
Column[{Control[{{rt,1,"testing"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtp,0,"true positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rtn,0,"true negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfp,50,"false positive result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}],
Control[{{rfn,100,"false negative result"},0,1000,.01,ImageSize->Tiny,Appearance->"Labeled"}]},Alignment->Right]}],
Delimiter,
SaveDefinitions->True,ContinuousAction->False,TrackedSymbols->True,ControlPlacement->Left,Alignment->Top]},
 ImageSize->Automatic
]

Abbreviations
ROC: Receiver Operating Characteristic 
DAM: Diagnostic Accuracy Measure

Note
It is assumed that if a test measurement is above the diagnostic threshold, the patient is classified as test-positive, otherwise as test-negative.

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
Relation 
Version Number 1.0.4.4
Hellenic Complex Systems Laboratory 2024
The notebook is distributed under  an Attribution - NonCommercial - ShareAlike 4.0 International Creative Commons License.