Diff for "FAQ/rocplot" - CBU statistics Wiki
location: Diff for "FAQ/rocplot"
Differences between revisions 1 and 4 (spanning 3 versions)
Revision 1 as of 2008-11-24 16:45:40
Size: 888
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 3: Line 3:
||||<33% style="TEXT-ALIGN: center"> Score || Specificity || 1- Sensitivity ||
||||<33% style="VERTICAL-ALIGN: top; TEXT-ALIGN: center"> 2000 || 0.48 || 0.02 ||
||||<33% style="VERTICAL-ALIGN: top; TEXT-ALIGN: center"> 1000 || 0.56 || 0.035 ||
||||<33% style="VERTICAL-ALIGN: top; TEXT-ALIGN: center"> 400 || 0.59 || 0.06 ||
||||<33% style="VERTICAL-ALIGN: top; TEXT-ALIGN: center"> 200 || 0.74 || 0.16 ||
||||<33% style="VERTICAL-ALIGN: top; TEXT-ALIGN: center"> 100 || 0.85 || 0.30 ||
Line 4: Line 10:
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.
Line 7: Line 14:
/time1 to time5 x1 to x5. /sense1 to sense7 omsp1 to omsp7.
Line 9: Line 16:
0 0.56 0.78 0.91 1 0 0.01 0.19 0.58 1 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
Line 11: Line 18:

define !trap( !pos !tokens(1)
             /!pos !tokens(1)
}}}
The macro can now be read in
{{{
define !auc( !pos !tokens(1)
Line 16: Line 24:
get m /variables=!3.
compute area=make(!1,1,0).
loop ib=1 to !1.
get m /variables=!2.
compute area=make(1,1,0).
loop ib=1 to 1.
Line 20: Line 28:
+ loop ic= 1 to !2-1.
+ compute id=ic+!2.
+ loop ic= 1 to !1-1.
+ compute id=ic+!1.
Line 35: Line 43:
save {m, area} /outfile=* /variables=!3, area. save {m, area} /outfile=* /variables=!2, area.
Line 39: Line 47:

!trap 1 5 time1 to time5 x1 to x5.
Line 42: Line 48:
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.

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)