1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
* ROC curves & Youden's Index.

* The following code  - "Roc curve & Youden's Index"
  also computes Likelihood Ratios and Kullback-Leibler distances
  (see Wen-Chung Lee paper for details) for every cut-off point of the
  ROC curve. The code requires SPSS v 12 or above.

* Code posted to SPSSX-L list on 2004/03/09 by Marta Garcia-Granero.
********************************************************************

* BEGGINING OF SYNTAX *.

* ROC curves: Youden's index, LR+, LR- & Kullback-Leibler distances
  (all of them prevalence-free indexes) with SPSS 12.

* Based on: Wen-Chung Lee, Selecting diagnostic tests for ruling out
  or ruling in disease: the use of the Kullback-Leibler distance,
  Int J of Epidemiol 1999;28:521–5.

* Dataset from Hosmer&Lemeshow's Applied Logistic Regression *.
DATA LIST FREE/ age chd (2 F8.0).
BEGIN DATA
 20 0 23 0 24 0 25 0 25 1 26 0 26 0 28 0 28 0 29 0
 30 0 30 0 30 0 30 0 30 0 30 1 32 0 32 0 33 0 33 0
 34 0 34 0 34 1 34 0 34 0 35 0 35 0 36 0 36 1 36 0
 37 0 37 1 37 0 38 0 38 0 39 0 39 1 40 0 40 1 41 0
 41 0 42 0 42 0 42 0 42 1 43 0 43 0 43 1 44 0 44 0
 44 1 44 1 45 0 45 1 46 0 46 1 47 0 47 0 47 1 48 0
 48 1 48 1 49 0 49 0 49 1 50 0 50 1 51 0 52 0 52 1
 53 1 53 1 54 1 55 0 55 1 55 1 56 1 56 1 56 1 57 0
 57 0 57 1 57 1 57 1 57 1 58 0 58 1 58 1 59 1 59 1
 60 0 60 1 61 1 62 1 62 1 63 1 64 0 64 1 65 1 69 1
END DATA.
VAR LABELS age 'Age at follow-up start'
 /chd 'Coronary Heart Disease'.
VALUE LABELS chd 0 'Absent' 1 'Present'.

OMS SELECT TABLES
/IF SUBTYPES=['Coordinates of the Curve']
/DESTINATION FORMAT=SAV OUTFILE='c:\\temp\\coordinates.sav'
/COLUMNS SEQUENCE=[C1 C2 C3].

ROC age  BY chd (1)
  /PLOT = CURVE(REFERENCE)
  /PRINT = SE COORDINATES
  /CRITERIA = CUTOFF(INCLUDE) TESTPOS(LARGE) DISTRIBUTION(FREE) CI(95)
  /MISSING = EXCLUDE .

OMSEND.

GET FILE='C:\\Temp\\coordinates.sav'
 /DROP= Command_ TO Var1.

* Diagnostic indexes *.
COMPUTE youden = Sensitivity-@1Specificity .
DO IF NOT(ANY(Sensitivity,0,1)) AND NOT(ANY(@1Specificity,0,1)).
- COMPUTE lrp=Sensitivity/@1Specificity.
- COMPUTE lrn=(1-Sensitivity)/(1-@1Specificity).
- COMPUTE dgf=(1-@1Specificity)*LN(1/lrn)+@1Specificity*LN(1/lrp).
- COMPUTE dfg=(1-Sensitivity)*LN(lrn)+Sensitivity*LN(lrp).
END IF.
EXECUTE .

* Report *.
VARIABLE LABELS youden "Youden's Index"
 /lrp "Likelihood Ratio Pos. Test"
 /lrn "Likelihood Ratio Neg. Test"
 /dgf "Kullback-Leibler dist. Rule-out D(g/f)"
 /dfg "Kullback-Leibler dist. Rule-in  D(f/g)".

FORMAT youden to dfg (F8.3).

SUMMARIZE
  /TABLES=ALL
  /FORMAT=VALIDLIST NOCASENUM NOTOTAL
  /TITLE='Prevalence-free Diagnostic Indexes'
  /MISSING=VARIABLE
  /CELLS=NONE.