close all
clear all 
disp('Ddimer: ROC')
lw = 2;  
set(0, 'DefaultAxesFontSize', 16);
fs = 14;
msize = 10;
%Rudimentary ROC in Hypothyroidism Example 
 
%Call for sesp is:  [se sp pre ppv npv lrp ag yi]   =  sesp(tp, fp, fn, tn)

[a b c d e f g h] = sesp( 35, 5, 24, 131);  %threshold = ?
%      Se        Sp        Pre       PPV       NPV       LRP        Ag         YI
%     0.5932    0.9632    0.3026    0.8750     0.8452   16.1356    0.8513    0.3935

% 
  [a b c d e f g h] = sesp( 39, 10, 20, 126);
%      Se        Sp        Pre       PPV       NPV       LRP        Ag         YI
%     0.6610    0.9265    0.3026    0.7959     0.8630    8.9898    0.8462    0.4154
  [a b c d e f g h] = sesp(46, 29, 13, 107);
%      Se        Sp        Pre       PPV       NPV       LRP        Ag         YI
%

%     0.7797    0.7868    0.3026    0.6133    0.8917    3.6563    0.7846     0.4005
  [a b c d e f g h] = sesp(51, 61, 8, 75);
%      Se        Sp        Pre       PPV       NPV       LRP        Ag         YI
%     0.8644    0.5515    0.3026    0.4554    0.9036    1.9272    0.6462    0.2941
  [a b c d e f g h] = sesp(57, 96, 2, 40);
%      Se        Sp        Pre       PPV       NPV       LRP        Ag         YI
%     0.9661    0.2941    0.3026    0.3725    0.9524    1.3686    0.4974    0.1840

close all force
se =  [0, 0.5932, 0.6610, 0.7797, 0.8644, 0.9661, 1];
csp = [0, 1 - 0.9632, 1 - 0.9265, 1 - 0.7868, 1-0.5515, 1-0.2941, 1];
   figure(1)
   plot(csp, se, 'k-','linewidth',lw)
   hold on
   fill([csp 1 0], [se 0 0],'y')
   plot(csp, se ,'o',  ...
       'MarkerSize',msize,'MarkerEdgeColor','k',...
       'MarkerFaceColor',[.49 1 .63])  
   plot(csp(3), se(3) ,'o',  ...
       'MarkerSize',msize,'MarkerEdgeColor','k',...
       'MarkerFaceColor',[1 0 0])  
   xlabel('1 - Specificity')
   ylabel('Sensitivity')
   plot([0, 1],[0,   1],'g--','LineWidth',2)             
  
     text('Interpreter','latex',...
	'String','$\fbox{Area = 0.8527}$',...
	'Position',[0.55 .45],...
	'FontSize',17) 

 
      text('Interpreter','latex',...
	'String','$(1-0.9265, 0.6610)$',...
	'Position',[0.1 .6],...
	'FontSize',17) 
  
    print -depsc 'C:\STAT1\ROC\ROCeps\hypo.eps'  

a = auc(csp, se)
% a =   0.8527  (Grade of B).
