FAQ/rocplot - CBU statistics Wiki
location: FAQ / rocplot

# Using SPSS to compute the area under a ROC curve

Suppose we have observed the five pairs of sensitivites and specificites in the table below. This section explains how to use these, without the need for any other information from the raw data, to compute the area under the 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 considered to be good using the table of deciles.

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