Diff for "FAQ/rocplot" - CBU statistics Wiki
location: Diff for "FAQ/rocplot"
Differences between revisions 3 and 4
Revision 3 as of 2008-11-24 16:59:22
Size: 1793
Editor: PeterWatson
Comment:
Revision 4 as of 2008-11-24 17:00:16
Size: 1844
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 48: Line 48:
and run for the seven pairs of sensitivities and 1-specificities above (7 is therefore an argument in the macro call). and run for the seven pairs of sensitivities and 1-specificities above (7 is an argument in the macro call and will need to be changed depending on the number observed).

Using SPSS to compute the area under a ROC curve

Score

Specificity

1- Sensitivity

2000

0.48

0.02

1000

0.56

0.035

400

0.59

0.06

200

0.74

0.16

100

0.85

0.30

We can input the five pairs of sensitivities and 1-specificities into the macro below in ascending order and adding the pairs 0,0 and 1,1 via the begin data statement giving seven pairs.

DATA LIST free
/sense1 to sense7 omsp1 to omsp7. 
BEGIN DATA. 
0.0 0.48 0.56 0.59 0.74 0.85 1.00 0.0 0.02 0.036 0.06 0.10 0.30 1.00 
END DATA. 

The macro can now be read in

define !auc( !pos !tokens(1)
             /!pos !cmdend).
matrix.
get m /variables=!2.
compute area=make(1,1,0).
loop ib=1 to 1.
+ compute f=0.
+ loop ic= 1 to !1-1.
+ compute id=ic+!1.
+ compute g=make(1,1,m(ib,id)).
+ compute h=make(1,1,m(ib,id+1)).
+ compute i=g > h.
+ compute j=i*(g-h)+(1-i)*(h-g).
+ compute a=make(1,1,m(ib,ic)).
+ compute b=make(1,1,m(ib,ic+1)).
+ compute c=a > b.
+ compute d=c*b+(1-c)*a.
+ compute e=0.5*c*(a-b)+0.5*(1-c)*(b-a).
+ compute f=f+((d+e))*j.
+  end loop.
+ compute area(ib)=f.
end loop.
save {m, area} /outfile=* /variables=!2, area.
print area.
end matrix.
!end define.

and run for the seven pairs of sensitivities and 1-specificities above (7 is an argument in the macro call and will need to be changed depending on the number observed).

!auc 7 sense1 to sense7 omsp1 to omsp7.

This gives an area of 0.86 which is.

None: FAQ/rocplot (last edited 2013-03-08 10:17:30 by localhost)