RENAME VARIABLES: Convert tests to Autotest framework.
[pspp] / tests / language / stats / examine.at
1 AT_BANNER([EXAMINE])
2
3 AT_SETUP([EXAMINE])
4 AT_DATA([examine.sps], [
5 DATA LIST LIST /QUALITY * W * BRAND * .
6 BEGIN DATA
7 3  1  1
8 2  2  1
9 1  2  1
10 1  1  1
11 4  1  1
12 4  1  1
13 5  1  2
14 2  1  2
15 4  4  2
16 2  1  2
17 3  1  2
18 7  1  3
19 4  2  3
20 5  3  3
21 3  1  3
22 6  1  3
23 END DATA
24
25 WEIGHT BY w.
26
27 VARIABLE LABELS brand   'Manufacturer'.
28 VARIABLE LABELS quality 'Breaking Strain'.
29
30 VALUE LABELS /brand 1 'Aspeger' 2 'Bloggs' 3 'Charlies'.
31
32 LIST /FORMAT=NUMBERED.
33
34 EXAMINE
35         quality BY brand
36         /STATISTICS descriptives extreme(3)
37         .
38 ])
39 AT_CHECK([pspp -o pspp.csv examine.sps])
40 dnl In the following data, only the extreme values have been checked.
41 dnl The descriptives have been blindly pasted.
42 AT_CHECK([cat pspp.csv], [0], [dnl
43 Table: Reading free-form data from INLINE.
44 Variable,Format
45 QUALITY,F8.0
46 W,F8.0
47 BRAND,F8.0
48
49 Table: Data List
50 Case Number,QUALITY,W,BRAND
51 1,3.00,1.00,1.00
52 2,2.00,2.00,1.00
53 3,1.00,2.00,1.00
54 4,1.00,1.00,1.00
55 5,4.00,1.00,1.00
56 6,4.00,1.00,1.00
57 7,5.00,1.00,2.00
58 8,2.00,1.00,2.00
59 9,4.00,4.00,2.00
60 10,2.00,1.00,2.00
61 11,3.00,1.00,2.00
62 12,7.00,1.00,3.00
63 13,4.00,2.00,3.00
64 14,5.00,3.00,3.00
65 15,3.00,1.00,3.00
66 16,6.00,1.00,3.00
67
68 Table: Case Processing Summary
69 ,Cases,,,,,
70 ,Valid,,Missing,,Total,
71 ,N,Percent,N,Percent,N,Percent
72 Breaking Strain,24.00,100%,.00,0%,24.00,100%
73
74 Table: Extreme Values
75 ,,,Case Number,Value
76 Breaking Strain,Highest,1,12,7.00
77 ,,2,16,6.00
78 ,,3,7,5.00
79 ,Lowest,1,3,1.00
80 ,,2,3,1.00
81 ,,3,4,1.00
82
83 Table: Descriptives
84 ,,,Statistic,Std. Error
85 Breaking Strain,Mean,,3.54,.32
86 ,95% Confidence Interval for Mean,Lower Bound,2.87,
87 ,,Upper Bound,4.21,
88 ,5% Trimmed Mean,,3.50,
89 ,Median,,4.00,
90 ,Variance,,2.52,
91 ,Std. Deviation,,1.59,
92 ,Minimum,,1.00,
93 ,Maximum,,7.00,
94 ,Range,,6.00,
95 ,Interquartile Range,,2.75,
96 ,Skewness,,.06,.47
97 ,Kurtosis,,-.36,.92
98
99 Table: Case Processing Summary
100 ,,Cases,,,,,
101 ,,Valid,,Missing,,Total,
102 ,Manufacturer,N,Percent,N,Percent,N,Percent
103 Breaking Strain,Aspeger,8.00,100%,.00,0%,8.00,100%
104 ,Bloggs,8.00,100%,.00,0%,8.00,100%
105 ,Charlies,8.00,100%,.00,0%,8.00,100%
106
107 Table: Extreme Values
108 ,Manufacturer,,,Case Number,Value
109 Breaking Strain,Aspeger,Highest,1,5,4.00
110 ,,,2,6,4.00
111 ,,,3,1,3.00
112 ,,Lowest,1,3,1.00
113 ,,,2,3,1.00
114 ,,,3,4,1.00
115 ,Bloggs,Highest,1,7,5.00
116 ,,,2,9,4.00
117 ,,,3,9,4.00
118 ,,Lowest,1,8,2.00
119 ,,,2,10,2.00
120 ,,,3,11,3.00
121 ,Charlies,Highest,1,12,7.00
122 ,,,2,16,6.00
123 ,,,3,14,5.00
124 ,,Lowest,1,15,3.00
125 ,,,2,13,4.00
126 ,,,3,13,4.00
127
128 Table: Descriptives
129 ,Manufacturer,,,Statistic,Std. Error
130 Breaking Strain,Aspeger,Mean,,2.25,.45
131 ,,95% Confidence Interval for Mean,Lower Bound,1.18,
132 ,,,Upper Bound,3.32,
133 ,,5% Trimmed Mean,,2.22,
134 ,,Median,,2.00,
135 ,,Variance,,1.64,
136 ,,Std. Deviation,,1.28,
137 ,,Minimum,,1.00,
138 ,,Maximum,,4.00,
139 ,,Range,,3.00,
140 ,,Interquartile Range,,2.75,
141 ,,Skewness,,.47,.75
142 ,,Kurtosis,,-1.55,1.48
143 ,Bloggs,Mean,,3.50,.38
144 ,,95% Confidence Interval for Mean,Lower Bound,2.61,
145 ,,,Upper Bound,4.39,
146 ,,5% Trimmed Mean,,3.50,
147 ,,Median,,4.00,
148 ,,Variance,,1.14,
149 ,,Std. Deviation,,1.07,
150 ,,Minimum,,2.00,
151 ,,Maximum,,5.00,
152 ,,Range,,3.00,
153 ,,Interquartile Range,,1.75,
154 ,,Skewness,,-.47,.75
155 ,,Kurtosis,,-.83,1.48
156 ,Charlies,Mean,,4.88,.44
157 ,,95% Confidence Interval for Mean,Lower Bound,3.83,
158 ,,,Upper Bound,5.92,
159 ,,5% Trimmed Mean,,4.86,
160 ,,Median,,5.00,
161 ,,Variance,,1.55,
162 ,,Std. Deviation,,1.25,
163 ,,Minimum,,3.00,
164 ,,Maximum,,7.00,
165 ,,Range,,4.00,
166 ,,Interquartile Range,,1.75,
167 ,,Skewness,,.30,.75
168 ,,Kurtosis,,.15,1.48
169 ])
170 AT_CLEANUP
171
172 AT_SETUP([EXAMINE -- extremes])
173 AT_DATA([examine.sps], [dnl
174 data list free /V1 W
175 begin data.
176 1  1
177 2  1
178 3  2
179 3  1
180 4  1
181 5  1
182 6  1
183 7  1
184 8  1
185 9  1
186 10 1
187 11 1
188 12 1
189 13 1
190 14 1
191 15 1
192 16 1
193 17 1
194 18 2
195 19 1
196 20 1
197 end data.
198
199 weight by w.
200
201 examine v1 
202  /statistics=extreme(6)
203  .
204 ])
205 AT_CHECK([pspp -o pspp.csv examine.sps])
206 AT_CHECK([cat pspp.csv], [0], [dnl
207 Table: Case Processing Summary
208 ,Cases,,,,,
209 ,Valid,,Missing,,Total,
210 ,N,Percent,N,Percent,N,Percent
211 V1,23.00,100%,.00,0%,23.00,100%
212
213 Table: Extreme Values
214 ,,,Case Number,Value
215 V1,Highest,1,21,20.00
216 ,,2,20,19.00
217 ,,3,19,18.00
218 ,,4,19,18.00
219 ,,5,18,17.00
220 ,,6,17,16.00
221 ,Lowest,1,1,1.00
222 ,,2,2,2.00
223 ,,3,3,3.00
224 ,,4,3,3.00
225 ,,5,4,3.00
226 ,,6,5,4.00
227 ])
228 AT_CLEANUP
229
230 dnl Test the PERCENTILES subcommand of the EXAMINE command.
231 dnl In particular test that it behaves properly when there are only 
232 dnl a few cases.
233 AT_SETUP([EXAMINE -- percentiles])
234 AT_DATA([examine.sps], [dnl
235 DATA LIST LIST /X *.
236 BEGIN DATA.
237 2.00 
238 8.00 
239 5.00 
240 END DATA.
241
242 EXAMINE /x
243         /PERCENTILES=HAVERAGE.
244
245 EXAMINE /x
246         /PERCENTILES=WAVERAGE.
247
248 EXAMINE /x
249         /PERCENTILES=ROUND.
250
251 EXAMINE /x
252         /PERCENTILES=EMPIRICAL.
253
254 EXAMINE /x
255         /PERCENTILES=AEMPIRICAL.
256 ])
257 AT_CHECK([pspp -o pspp.csv examine.sps])
258 AT_CHECK([cat pspp.csv], [0], [dnl
259 Table: Reading free-form data from INLINE.
260 Variable,Format
261 X,F8.0
262
263 Table: Case Processing Summary
264 ,Cases,,,,,
265 ,Valid,,Missing,,Total,
266 ,N,Percent,N,Percent,N,Percent
267 X,3,100%,0,0%,3,100%
268
269 Table: Percentiles
270 ,,Percentiles,,,,,,
271 ,,5,10,25,50,75,90,95
272 X,HAverage,.40,.80,2.00,5.00,8.00,8.00,8.00
273 ,Tukey's Hinges,,,3.50,5.00,6.50,,
274
275 Table: Case Processing Summary
276 ,Cases,,,,,
277 ,Valid,,Missing,,Total,
278 ,N,Percent,N,Percent,N,Percent
279 X,3,100%,0,0%,3,100%
280
281 Table: Percentiles
282 ,,Percentiles,,,,,,
283 ,,5,10,25,50,75,90,95
284 X,Weighted Average,.30,.60,1.50,3.50,5.75,7.10,7.55
285 ,Tukey's Hinges,,,3.50,5.00,6.50,,
286
287 Table: Case Processing Summary
288 ,Cases,,,,,
289 ,Valid,,Missing,,Total,
290 ,N,Percent,N,Percent,N,Percent
291 X,3,100%,0,0%,3,100%
292
293 Table: Percentiles
294 ,,Percentiles,,,,,,
295 ,,5,10,25,50,75,90,95
296 X,Rounded,.00,.00,2.00,5.00,5.00,8.00,8.00
297 ,Tukey's Hinges,,,3.50,5.00,6.50,,
298
299 Table: Case Processing Summary
300 ,Cases,,,,,
301 ,Valid,,Missing,,Total,
302 ,N,Percent,N,Percent,N,Percent
303 X,3,100%,0,0%,3,100%
304
305 Table: Percentiles
306 ,,Percentiles,,,,,,
307 ,,5,10,25,50,75,90,95
308 X,Empirical,2.00,2.00,2.00,5.00,8.00,8.00,8.00
309 ,Tukey's Hinges,,,3.50,5.00,6.50,,
310
311 Table: Case Processing Summary
312 ,Cases,,,,,
313 ,Valid,,Missing,,Total,
314 ,N,Percent,N,Percent,N,Percent
315 X,3,100%,0,0%,3,100%
316
317 Table: Percentiles
318 ,,Percentiles,,,,,,
319 ,,5,10,25,50,75,90,95
320 X,Empirical with averaging,2.00,2.00,2.00,5.00,8.00,8.00,8.00
321 ,Tukey's Hinges,,,3.50,5.00,6.50,,
322 ])
323 AT_CLEANUP
324
325 AT_SETUP([EXAMINE -- missing values])
326 AT_DATA([examine.sps], [dnl
327 DATA LIST LIST /x * y *.
328 BEGIN DATA.
329 1   1 
330 2   1
331 3   1
332 4   1
333 5   2
334 6   2
335 .   2
336 END DATA
337
338 EXAMINE /x by y.
339 ])
340 AT_CHECK([pspp -o pspp.csv examine.sps])
341 AT_CHECK([cat pspp.csv], [0], [dnl
342 Table: Reading free-form data from INLINE.
343 Variable,Format
344 x,F8.0
345 y,F8.0
346
347 Table: Case Processing Summary
348 ,Cases,,,,,
349 ,Valid,,Missing,,Total,
350 ,N,Percent,N,Percent,N,Percent
351 x,6,85.7143%,1,14.2857%,7,100%
352
353 Table: Case Processing Summary
354 ,,Cases,,,,,
355 ,,Valid,,Missing,,Total,
356 ,y,N,Percent,N,Percent,N,Percent
357 x,1.00,4,100%,0,0%,4,100%
358 ,2.00,2,66.6667%,1,33.3333%,3,100%
359 ])
360 AT_CLEANUP
361
362 AT_SETUP([EXAMINE -- missing values and percentiles])
363 AT_DATA([examine.sps], [dnl
364 DATA LIST LIST /X *.
365 BEGIN DATA.
366 99
367 99
368 5.00
369 END DATA.
370
371 MISSING VALUE X (99).
372
373 EXAMINE /x
374         /PERCENTILES=HAVERAGE.
375 ])
376 AT_CHECK([pspp -o pspp.csv examine.sps])
377 dnl Ignore output -- this is just a no-crash check.
378 AT_CLEANUP
379
380 AT_SETUP([EXAMINE -- crash bug])
381 AT_DATA([examine.sps], [dnl
382 data list list /a * x * y *.
383 begin data.
384 3 1 3
385 5 1 4
386 7 2 3
387 end data.
388
389 examine a by x by y
390         /statistics=DESCRIPTIVES
391         . 
392 ])
393 AT_CHECK([pspp -o pspp.csv examine.sps])
394 dnl Ignore output -- this is just a no-crash check.
395 AT_CLEANUP
396
397 dnl Test that two consecutive EXAMINE commands don't crash PSPP.
398 AT_SETUP([EXAMINE -- consecutive runs don't crash])
399 AT_DATA([examine.sps], [dnl
400 data list list /y * z *.
401 begin data.
402 6 4
403 5 3
404 7 6
405 end data.
406
407 EXAMINE /VARIABLES= z BY y.
408
409 EXAMINE /VARIABLES= z. 
410 ])
411 AT_CHECK([pspp -o pspp.csv examine.sps])
412 dnl Ignore output -- this is just a no-crash check.
413 AT_CLEANUP
414
415 dnl Test that /DESCRIPTIVES does not crash in presence of missing values.
416 AT_SETUP([EXAMINE -- missing values don't crash])
417 AT_DATA([examine.sps], [dnl
418 data list list /x * y *.
419 begin data.
420 1 0
421 2 0
422 . 0
423 3 1
424 4 1
425 end data.
426 examine x by y /statistics=descriptives. 
427 ])
428 AT_CHECK([pspp -o pspp.csv examine.sps])
429 dnl Ignore output -- this is just a no-crash check.
430 AT_CLEANUP
431
432 dnl Test that having only a single case doesn't crash.
433 AT_SETUP([EXAMINE -- single case doesn't crash])
434 AT_DATA([examine.sps], [dnl
435 DATA LIST LIST /quality * .
436 BEGIN DATA
437 3  
438 END DATA
439
440
441 EXAMINE
442         quality 
443         /STATISTICS descriptives 
444         .
445 ])
446 AT_CHECK([pspp -o pspp.csv examine.sps])
447 dnl Ignore output -- this is just a no-crash check.
448 AT_CLEANUP
449
450 dnl Test that all-missing data doesn't crash.
451 AT_SETUP([EXAMINE -- all-missing data doesn't crash])
452 AT_DATA([examine.sps], [dnl
453 DATA LIST LIST /x *.
454 BEGIN DATA.
455 .
456 .
457 .
458 .
459 END DATA.
460
461 EXAMINE /x PLOT=HISTOGRAM.
462 ])
463 AT_CHECK([pspp -o pspp.csv examine.sps], [0], [dnl
464 warning: Not creating plot because data set is empty.
465 ])
466 dnl Ignore output -- this is just a no-crash check.
467 AT_CLEANUP