ROC: Improve error messages and coding style.
[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
17 AT_BANNER([ROC])
18
19 AT_SETUP([ROC free distribution])
20 AT_DATA([roc.sps], [dnl
21 set format F10.3.
22 data list notable list /x * y * w * a *.
23 begin data.
24 1 1 2  1
25 1 2 28 0
26 2 3 4  1
27 2 4 14 0
28 3 5 10 1
29 . . 1  0
30 3 1 5  0
31 4 2 14 1
32 4 3 2  0
33 5 4 20 1
34 5 4 20 .
35 5 5 1  0
36 end data.
37
38 weight by w.
39
40 roc x by a (1)
41         /plot = none
42         /print = se coordinates
43         /criteria = testpos(large) distribution(free) ci(99)
44         /missing = exclude .
45 ])
46 AT_CHECK([pspp -o pspp.csv roc.sps])
47 AT_CHECK([cat pspp.csv], [0], [dnl
48 Table: Case Summary
49 a,Valid N (listwise),
50 ,Unweighted,Weighted
51 Positive,5,50.000
52 Negative,5,50.000
53
54 Table: Area Under the Curve
55 Variable under test,Area,Std. Error,Asymptotic Sig.,Asymp. 99% Confidence Interval,
56 ,,,,Lower Bound,Upper Bound
57 x,.910,.030,.000,.839,.981
58
59 Table: Coordinates of the Curve
60 Test variable,Positive if greater than or equal to,Sensitivity,1 - Specificity
61 x,.000,1.000,1.000
62 ,1.500,.960,.440
63 ,2.500,.880,.160
64 ,3.500,.680,.060
65 ,4.500,.400,.020
66 ,6.000,.000,.000
67 ])
68 AT_CLEANUP
69
70 AT_SETUP([ROC negative exponential distribution])
71 AT_DATA([roc.sps], [dnl
72 set format F10.3.
73 data list notable list /x * y * w * a *.
74 begin data.
75 1 1 2  1
76 1 2 28 0
77 2 3 4  1
78 2 4 14 0
79 3 5 10 1
80 . . 1  0
81 3 1 5  0
82 4 2 14 1
83 4 3 2  0
84 5 4 20 1
85 5 4 20 .
86 5 5 1  0
87 end data.
88
89 weight by w.
90
91 roc x y by a (1)
92         /plot = curve(reference)
93         /print = se coordinates
94         /criteria = testpos(large) distribution(negexpo) ci(95)
95         /missing = exclude .
96 ])
97 AT_CHECK([pspp -o pspp.csv roc.sps])
98 AT_CHECK([cat pspp.csv], [0], [dnl
99 Table: Case Summary
100 a,Valid N (listwise),
101 ,Unweighted,Weighted
102 Positive,5,50.000
103 Negative,5,50.000
104
105 Table: Area Under the Curve
106 Variable under test,Area,Std. Error,Asymptotic Sig.,Asymp. 95% Confidence Interval,
107 ,,,,Lower Bound,Upper Bound
108 x,.910,.030,.000,.860,.960
109 y,.697,.052,.001,.611,.783
110
111 Table: Coordinates of the Curve
112 Test variable,Positive if greater than or equal to,Sensitivity,1 - Specificity
113 x,.000,1.000,1.000
114 ,1.500,.960,.440
115 ,2.500,.880,.160
116 ,3.500,.680,.060
117 ,4.500,.400,.020
118 ,6.000,.000,.000
119 y,.000,1.000,1.000
120 ,1.500,.960,.900
121 ,2.500,.680,.340
122 ,3.000,.600,.340
123 ,3.500,.600,.300
124 ,4.500,.200,.020
125 ,6.000,.000,.000
126 ])
127 AT_CLEANUP
128
129 AT_SETUP([ROC with anomaly])
130 AT_DATA([roc.sps], [dnl
131 set format F10.3.
132 data list notable list /x * a * comment (a20).
133 begin data.
134 0  1 ""
135 0  0 ""
136 1  1 ""
137 1  0 ""
138 2  1 ""
139 2  0 ""
140 5  1 ""
141 5  0 ""
142 10 1 ""
143 10 0 ""
144 15 1 ""
145 15 0 ""
146 20 1 ""
147 20 1 ""
148 22 0 "here and"
149 22 0 "here is the anomaly"
150 25 1 ""
151 25 0 ""
152 30 1 ""
153 30 0 ""
154 35 1 ""
155 35 0 ""
156 38 1 ""
157 38 0 ""
158 39 1 ""
159 39 0 ""
160 40 1 ""
161 40 0 ""
162 end data.
163
164 roc x by a (1)
165         /plot = none
166         print = se
167         .
168 ])
169 AT_CHECK([pspp -o pspp.csv -o pspp.txt roc.sps])
170 AT_CHECK([cat pspp.csv], [0], [dnl
171 Table: Case Summary
172 a,Valid N (listwise),
173 ,Unweighted,Weighted
174 Positive,14,14.000
175 Negative,14,14.000
176
177 Table: Area Under the Curve
178 Variable under test,Area,Std. Error,Asymptotic Sig.,Asymp. 95% Confidence Interval,
179 ,,,,Lower Bound,Upper Bound
180 x,.490,.111,.927,.307,.673
181 ])
182 AT_CLEANUP
183
184
185
186
187 AT_SETUP([ROC crash on no state variable])
188 AT_DATA([roc.sps], [dnl
189 data list notable list /x * y * w * a *.
190 begin data.
191 5 5 1  0
192 end data.
193
194
195 roc x y By(a (1)
196  .
197 ])
198
199 AT_CHECK([pspp -o pspp.csv roc.sps], [1], [ignore])
200
201 AT_CLEANUP
202
203
204 AT_SETUP([ROC crash on invalid syntax])
205 AT_DATA([roc.sps], [dnl
206 data list notable list /x * y * a *.
207 bggin data.
208 1 1 2
209 1 2 28
210 end data.
211
212
213 roc x y by a (1)
214         /criteria = ci(y5)
215 ])
216
217 AT_CHECK([pspp -O format=csv roc.sps], [1], [ignore])
218
219 AT_CLEANUP
220
221 AT_SETUP([ROC syntax errors])
222 AT_DATA([roc.sps], [dnl
223 DATA LIST LIST NOTABLE/x y z.
224 ROC **.
225 ROC x **.
226 ROC x BY **.
227 ROC x BY y **.
228 ROC x BY y(**).
229 ROC x BY y(5 **).
230 ROC x BY y(5)/MISSING=**.
231 ROC x BY y(5)/PLOT=CURVE(**).
232 ROC x BY y(5)/PLOT=CURVE(REFERENCE **).
233 ROC x BY y(5)/PLOT=**.
234 ROC x BY y(5)/PRINT=**.
235 ROC x BY y(5)/CRITERIA=CUTOFF **.
236 ROC x BY y(5)/CRITERIA=CUTOFF(**).
237 ROC x BY y(5)/CRITERIA=CUTOFF(INCLUDE **).
238 ROC x BY y(5)/CRITERIA=TESTPOS **.
239 ROC x BY y(5)/CRITERIA=TESTPOS(**).
240 ROC x BY y(5)/CRITERIA=TESTPOS(LARGE **).
241 ROC x BY y(5)/CRITERIA=CI **.
242 ROC x BY y(5)/CRITERIA=CI(**).
243 ROC x BY y(5)/CRITERIA=CI(5 **).
244 ROC x BY y(5)/CRITERIA=DISTRIBUTION **.
245 ROC x BY y(5)/CRITERIA=DISTRIBUTION(**).
246 ROC x BY y(5)/CRITERIA=DISTRIBUTION(FREE **).
247 ROC x BY y(5)/CRITERIA=**.
248 ROC x BY y(5)/ **.
249 ])
250 AT_CHECK([pspp -O format=csv roc.sps], [1], [dnl
251 "roc.sps:2.5-2.6: error: ROC: Syntax error expecting variable name.
252     2 | ROC **.
253       |     ^~"
254
255 "roc.sps:3.7-3.8: error: ROC: Syntax error expecting `BY'.
256     3 | ROC x **.
257       |       ^~"
258
259 "roc.sps:4.10-4.11: error: ROC: Syntax error expecting variable name.
260     4 | ROC x BY **.
261       |          ^~"
262
263 "roc.sps:5.12-5.13: error: ROC: Syntax error expecting `('.
264     5 | ROC x BY y **.
265       |            ^~"
266
267 "roc.sps:6.12-6.13: error: ROC: Syntax error expecting number.
268     6 | ROC x BY y(**).
269       |            ^~"
270
271 "roc.sps:7.14-7.15: error: ROC: Syntax error expecting `)'.
272     7 | ROC x BY y(5 **).
273       |              ^~"
274
275 "roc.sps:8.23-8.24: error: ROC: Syntax error expecting INCLUDE or EXCLUDE.
276     8 | ROC x BY y(5)/MISSING=**.
277       |                       ^~"
278
279 "roc.sps:9.26-9.27: error: ROC: Syntax error expecting REFERENCE.
280     9 | ROC x BY y(5)/PLOT=CURVE(**).
281       |                          ^~"
282
283 "roc.sps:10.36-10.37: error: ROC: Syntax error expecting `@:}@'.
284    10 | ROC x BY y(5)/PLOT=CURVE(REFERENCE **).
285       |                                    ^~"
286
287 "roc.sps:11.20-11.21: error: ROC: Syntax error expecting CURVE or NONE.
288    11 | ROC x BY y(5)/PLOT=**.
289       |                    ^~"
290
291 "roc.sps:12.21-12.22: error: ROC: Syntax error expecting SE or COORDINATES.
292    12 | ROC x BY y(5)/PRINT=**.
293       |                     ^~"
294
295 "roc.sps:13.31-13.32: error: ROC: Syntax error expecting `('.
296    13 | ROC x BY y(5)/CRITERIA=CUTOFF **.
297       |                               ^~"
298
299 "roc.sps:14.31-14.32: error: ROC: Syntax error expecting INCLUDE or EXCLUDE.
300    14 | ROC x BY y(5)/CRITERIA=CUTOFF(**).
301       |                               ^~"
302
303 "roc.sps:15.39-15.40: error: ROC: Syntax error expecting `)'.
304    15 | ROC x BY y(5)/CRITERIA=CUTOFF(INCLUDE **).
305       |                                       ^~"
306
307 "roc.sps:16.32-16.33: error: ROC: Syntax error expecting `('.
308    16 | ROC x BY y(5)/CRITERIA=TESTPOS **.
309       |                                ^~"
310
311 "roc.sps:17.32-17.33: error: ROC: Syntax error expecting LARGE or SMALL.
312    17 | ROC x BY y(5)/CRITERIA=TESTPOS(**).
313       |                                ^~"
314
315 "roc.sps:18.38-18.39: error: ROC: Syntax error expecting `)'.
316    18 | ROC x BY y(5)/CRITERIA=TESTPOS(LARGE **).
317       |                                      ^~"
318
319 "roc.sps:19.27-19.28: error: ROC: Syntax error expecting `('.
320    19 | ROC x BY y(5)/CRITERIA=CI **.
321       |                           ^~"
322
323 "roc.sps:20.27-20.28: error: ROC: Syntax error expecting number.
324    20 | ROC x BY y(5)/CRITERIA=CI(**).
325       |                           ^~"
326
327 "roc.sps:21.29-21.30: error: ROC: Syntax error expecting `)'.
328    21 | ROC x BY y(5)/CRITERIA=CI(5 **).
329       |                             ^~"
330
331 "roc.sps:22.37-22.38: error: ROC: Syntax error expecting `('.
332    22 | ROC x BY y(5)/CRITERIA=DISTRIBUTION **.
333       |                                     ^~"
334
335 "roc.sps:23.37-23.38: error: ROC: Syntax error expecting FREE or NEGEXPO.
336    23 | ROC x BY y(5)/CRITERIA=DISTRIBUTION(**).
337       |                                     ^~"
338
339 "roc.sps:24.42-24.43: error: ROC: Syntax error expecting `)'.
340    24 | ROC x BY y(5)/CRITERIA=DISTRIBUTION(FREE **).
341       |                                          ^~"
342
343 "roc.sps:25.24-25.25: error: ROC: Syntax error expecting CUTOFF, TESTPOS, CI, or DISTRIBUTION.
344    25 | ROC x BY y(5)/CRITERIA=**.
345       |                        ^~"
346
347 "roc.sps:26.16-26.17: error: ROC: Syntax error expecting MISSING, PLOT, PRINT, or CRITERIA.
348    26 | ROC x BY y(5)/ **.
349       |                ^~"
350 ])
351 AT_CLEANUP