Add copyright and licence notices to files which lack them.
[pspp] / tests / language / stats / roc.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl AT_BANNER([ROC])
17
18 AT_SETUP([ROC, free distribution])
19 AT_DATA([roc.sps], [dnl
20 set format F10.3.
21 data list notable list /x * y * w * a *.
22 begin data.
23 1 1 2  1
24 1 2 28 0
25 2 3 4  1
26 2 4 14 0
27 3 5 10 1
28 . . 1  0
29 3 1 5  0
30 4 2 14 1
31 4 3 2  0
32 5 4 20 1
33 5 4 20 .
34 5 5 1  0
35 end data.
36
37 weight by w.
38
39 roc x by a (1)
40         /plot = none
41         /print = se coordinates
42         /criteria = testpos(large) distribution(free) ci(99)
43         /missing = exclude .
44 ])
45 AT_CHECK([pspp -o pspp.csv roc.sps])
46 AT_CHECK([cat pspp.csv], [0], [dnl
47 Table: Case Summary
48 ,Valid N (listwise),
49 a,Unweighted,Weighted
50 Positive,5,50.000
51 Negative,5,50.000
52
53 Table: Area Under the Curve (x)
54 ,,,Asymp. 99% Confidence Interval,
55 Area,Std. Error,Asymptotic Sig.,Lower Bound,Upper Bound
56 .910,.030,.000,.839,.981
57
58 Table: Coordinates of the Curve (x)
59 Positive if greater than or equal to,Sensitivity,1 - Specificity
60 .000,1.000,1.000
61 1.500,.960,.440
62 2.500,.880,.160
63 3.500,.680,.060
64 4.500,.400,.020
65 6.000,.000,.000
66 ])
67 AT_CLEANUP
68
69 AT_SETUP([ROC, negative exponential distribution])
70 AT_DATA([roc.sps], [dnl
71 set format F10.3.
72 data list notable list /x * y * w * a *.
73 begin data.
74 1 1 2  1
75 1 2 28 0
76 2 3 4  1
77 2 4 14 0
78 3 5 10 1
79 . . 1  0
80 3 1 5  0
81 4 2 14 1
82 4 3 2  0
83 5 4 20 1
84 5 4 20 .
85 5 5 1  0
86 end data.
87
88 weight by w.
89
90 roc x y by a (1)
91         /plot = curve(reference)
92         /print = se coordinates
93         /criteria = testpos(large) distribution(negexpo) ci(95)
94         /missing = exclude .
95 ])
96 AT_CHECK([pspp -o pspp.csv roc.sps])
97 AT_CHECK([cat pspp.csv], [0], [dnl
98 Table: Case Summary
99 ,Valid N (listwise),
100 a,Unweighted,Weighted
101 Positive,5,50.000
102 Negative,5,50.000
103
104 Table: Area Under the Curve
105 ,,,,Asymp. 95% Confidence Interval,
106 Variable under test,Area,Std. Error,Asymptotic Sig.,Lower Bound,Upper Bound
107 x,.910,.030,.000,.860,.960
108 y,.697,.052,.001,.611,.783
109
110 Table: Coordinates of the Curve
111 Test variable,Positive if greater than or equal to,Sensitivity,1 - Specificity
112 x,.000,1.000,1.000
113 ,1.500,.960,.440
114 ,2.500,.880,.160
115 ,3.500,.680,.060
116 ,4.500,.400,.020
117 ,6.000,.000,.000
118 y,.000,1.000,1.000
119 ,1.500,.960,.900
120 ,2.500,.680,.340
121 ,3.000,.600,.340
122 ,3.500,.600,.300
123 ,4.500,.200,.020
124 ,6.000,.000,.000
125 ])
126 AT_CLEANUP
127
128 AT_SETUP([ROC, with anomaly])
129 AT_DATA([roc.sps], [dnl
130 set format F10.3.
131 data list notable list /x * a * comment (a20).
132 begin data.
133 0  1 ""
134 0  0 ""
135 1  1 ""
136 1  0 ""
137 2  1 ""
138 2  0 ""
139 5  1 ""
140 5  0 ""
141 10 1 ""
142 10 0 ""
143 15 1 ""
144 15 0 ""
145 20 1 ""
146 20 1 ""
147 22 0 "here and"
148 22 0 "here is the anomoly"
149 25 1 ""
150 25 0 ""
151 30 1 ""
152 30 0 ""
153 35 1 ""
154 35 0 ""
155 38 1 ""
156 38 0 ""
157 39 1 ""
158 39 0 ""
159 40 1 ""
160 40 0 ""
161 end data.
162
163 roc x by a (1)
164         /plot = none
165         print = se 
166         .
167 ])
168 AT_CHECK([pspp -o pspp.csv roc.sps])
169 AT_CHECK([cat pspp.csv], [0], [dnl
170 Table: Case Summary
171 ,Valid N (listwise),
172 a,Unweighted,Weighted
173 Positive,14,14.000
174 Negative,14,14.000
175
176 Table: Area Under the Curve (x)
177 ,,,Asymp. 95% Confidence Interval,
178 Area,Std. Error,Asymptotic Sig.,Lower Bound,Upper Bound
179 .490,.111,.927,.307,.673
180 ])
181 AT_CLEANUP
182
183
184
185
186 AT_SETUP([ROC crash on no state variable])
187 AT_DATA([roc.sps], [dnl
188 data list notable list /x * y * w * a *.
189 begin data.
190 5 5 1  0
191 end data.
192
193
194 roc x y By(a (1)
195  .
196 ])
197
198 AT_CHECK([pspp -o pspp.csv roc.sps], [1], [ignore])
199
200 AT_CLEANUP
201
202
203 AT_SETUP([ROC crash on invalid syntax])
204 AT_DATA([roc.sps], [dnl
205 data list notable list /x * y * a *.
206 bggin data.
207 1 1 2  
208 1 2 28
209 end data.
210
211
212 roc x y by a (1)
213         /criteria = ci(y5)
214 ])
215
216 AT_CHECK([pspp -O format=csv roc.sps], [1], [ignore])
217
218 AT_CLEANUP