d4db9ec8af3ca941b2f5e35886f072cdf0f62c05
[pspp] / tests / language / stats / means.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([MEANS procedure])
18
19 AT_SETUP([MEANS simple example])
20 AT_KEYWORDS([categorical categoricals])
21
22 AT_DATA([means-simple.sps], [dnl
23 SET FORMAT=F12.5.
24
25 data list notable list /score * factor *.
26 BEGIN DATA.
27 22 01
28 22 01
29 29 01
30 16 01
31 24 02
32 21 02
33 22 01
34 24 01
35 19 01
36 17 01
37 22 01
38 17 02
39 23 02
40 25 02
41 20 01
42 15 01
43 18 01
44 26 01
45 23 02
46 35 02
47 20 01
48 16 01
49 19 01
50 14 01
51 14 01
52 21 01
53 END DATA.
54
55 MEANS TABLES = score BY factor.
56 ])
57
58 AT_CHECK([pspp -O format=csv means-simple.sps], [0],
59   [dnl
60 Table: Case Processing Summary
61 ,Cases,,,,,
62 ,Included,,Excluded,,Total,
63 ,N,Percent,N,Percent,N,Percent
64 score: factor,26,100%,0,0%,26,100%
65 score: ,26,100%,0,0%,26,100%
66
67 Table: Report
68 ,factor,Mean,N,Std. Deviation
69 score,1.00000,19.78947,19.00000,4.03566
70 ,2.00000,24.00000,7.00000,5.50757
71
72 Table: Report
73 ,Mean,N,Std. Deviation
74 score,20.92308,26.00000,4.75750
75 ])
76
77 AT_CLEANUP
78
79
80
81 AT_SETUP([MEANS very simple example])
82 AT_KEYWORDS([categorical categoricals])
83
84 AT_DATA([means-vsimple.sps], [dnl
85 SET FORMAT=F12.5.
86
87 data list notable list /score.
88 begin data.
89 1
90 1
91 2
92 2
93 end data.
94
95 means tables = score.
96 ])
97
98 AT_CHECK([pspp -O format=csv means-vsimple.sps], [0],
99   [dnl
100 Table: Case Processing Summary
101 ,Cases,,,,,
102 ,Included,,Excluded,,Total,
103 ,N,Percent,N,Percent,N,Percent
104 score: ,4,100%,0,0%,4,100%
105
106 Table: Report
107 ,Mean,N,Std. Deviation
108 score,1.50000,4.00000,.57735
109 ])
110
111 AT_CLEANUP
112
113
114
115
116 AT_SETUP([MEANS default missing])
117 AT_KEYWORDS([categorical categoricals])
118
119 AT_DATA([means-dmiss.sps], [dnl
120 SET FORMAT=F12.2.
121 data list notable list /a * g1 * g2 *.
122 begin data.
123 3 1 . 
124 4 1 11
125 3 1 21
126 6 2 21
127 2 2 31
128 . 2 31
129 8 2 31
130 7 2 31
131 end data.
132
133 MEANS TABLES = 
134       a BY g1 g2
135       BY g2
136       /cells = MEAN COUNT
137       .
138 ])
139
140 AT_CHECK([pspp -O format=csv means-dmiss.sps], [0],
141   [dnl
142 Table: Case Processing Summary
143 ,Cases,,,,,
144 ,Included,,Excluded,,Total,
145 ,N,Percent,N,Percent,N,Percent
146 a: g1 * g2,6,75%,2,25%,8,100%
147 a: g2,6,75%,2,25%,8,100%
148 a: ,7,87.5%,1,12.5%,8,100%
149
150 Table: Report
151 ,g1,g2,Mean,N
152 a,1.00,11.00,4.00,1.00
153 ,1.00,21.00,3.00,1.00
154 ,2.00,21.00,6.00,1.00
155 ,2.00,31.00,5.67,3.00
156
157 Table: Report
158 ,g2,Mean,N
159 a,11.00,4.00,1.00
160 ,21.00,4.50,2.00
161 ,31.00,5.67,3.00
162
163 Table: Report
164 ,Mean,N
165 a,5.00,6.00
166 ])
167
168 AT_CLEANUP
169
170
171 AT_SETUP([MEANS linear stats])
172 AT_KEYWORDS([categorical categoricals])
173
174 dnl Slightly more involved example to test the linear statistics
175 AT_DATA([means-linear.sps], [dnl
176 set format F12.4.
177 data list notable list /id * group * test1 *
178 begin data.
179 1 1 85
180 2 1 90
181 3 1 82
182 4 1 75
183 5 1 99
184 6 2 70
185 7 2 66
186 8 2 52
187 9 2 71
188 10 2 50
189 end data.
190
191 add value labels /group 1 "experimental group" 2 "control group".
192
193 means test1 by group
194   /cells = mean count stddev sum min max range variance kurt skew
195   .
196 ])
197
198
199 AT_CHECK([pspp -O format=csv means-linear.sps], [0],
200   [dnl
201 Table: Case Processing Summary
202 ,Cases,,,,,
203 ,Included,,Excluded,,Total,
204 ,N,Percent,N,Percent,N,Percent
205 test1: group,10,100%,0,0%,10,100%
206 test1: ,10,100%,0,0%,10,100%
207
208 Table: Report
209 ,group,Mean,N,Std. Deviation,Sum,Min,Max,Range,Variance,Kurtosis,Skewness
210 test1,experimental group,86.2000,5.0000,8.9833,431.0000,75.0000,99.0000,24.0000,80.7000,.2727,.3858
211 ,control group,61.8000,5.0000,10.0598,309.0000,50.0000,71.0000,21.0000,101.2000,-3.0437,-.4830
212
213 Table: Report
214 ,Mean,N,Std. Deviation,Sum,Min,Max,Range,Variance,Kurtosis,Skewness
215 test1,74.0000,10.0000,15.6915,740.0000,50.0000,99.0000,49.0000,246.2222,-.5759,-.1262
216 ])
217
218 AT_CLEANUP
219
220
221 AT_SETUP([MEANS standard errors])
222 AT_KEYWORDS([categorical categoricals])
223
224 AT_DATA([means-stderr.sps], [dnl
225 set format F12.4.
226 data list notable list /id * group * test1 *
227 begin data.
228 1 1 85
229 2 1 90
230 3 1 82
231 4 1 75
232 5 1 99
233 6 1 70
234 7 2 66
235 8 2 52
236 9 2 71
237 10 2 50
238 end data.
239
240 means test1 by group 
241         /cells = mean count semean seskew sekurt.
242 ])
243
244
245 AT_CHECK([pspp -O format=csv means-stderr.sps], [0],
246   [dnl
247 Table: Case Processing Summary
248 ,Cases,,,,,
249 ,Included,,Excluded,,Total,
250 ,N,Percent,N,Percent,N,Percent
251 test1: group,10,100%,0,0%,10,100%
252 test1: ,10,100%,0,0%,10,100%
253
254 Table: Report
255 ,group,Mean,N,S.E. Mean,S.E. Skew,S.E. Kurt
256 test1,1.0000,83.5000,6.0000,4.2485,.8452,1.7408
257 ,2.0000,59.7500,4.0000,5.1700,1.0142,2.6186
258
259 Table: Report
260 ,Mean,N,S.E. Mean,S.E. Skew,S.E. Kurt
261 test1,74.0000,10.0000,4.9621,.6870,1.3342
262 ])
263
264 AT_CLEANUP
265
266
267
268 AT_SETUP([MEANS harmonic and geometric means])
269 AT_KEYWORDS([categorical categoricals])
270
271 AT_DATA([means-hg.sps], [dnl
272 set format F12.4.
273 data list notable list /x * y *.
274 begin data.
275 1 3
276 2 3
277 3 3
278 4 3
279 5 3
280 end data.
281
282
283 means x y
284         /cells = mean harmonic geometric
285 .
286 ])
287
288
289 AT_CHECK([pspp -O format=csv means-hg.sps], [0],
290   [dnl
291 Table: Case Processing Summary
292 ,Cases,,,,,
293 ,Included,,Excluded,,Total,
294 ,N,Percent,N,Percent,N,Percent
295 x: ,5,100%,0,0%,5,100%
296 y: ,5,100%,0,0%,5,100%
297
298 Table: Report
299 ,Mean,Harmonic Mean,Geom. Mean
300 x,3.0000,2.1898,2.6052
301 y,3.0000,3.0000,3.0000
302 ])
303
304 AT_CLEANUP
305
306
307
308
309
310
311 AT_SETUP([MEANS all/none/default])
312 AT_KEYWORDS([categorical categoricals])
313
314 dnl Make sure that /CELLS = {ALL,NONE,DEFAULT} work properly
315 AT_DATA([means-stat-keywords.sps], [dnl
316 SET FORMAT=F12.2.
317 SET DECIMAL=DOT.
318
319 DATA LIST NOTABLE LIST /score *.
320 BEGIN DATA.
321 22
322 22
323 29
324 16
325 23
326 END DATA.
327
328 MEANS score /CELLS = ALL.
329 MEANS score /CELLS = DEFAULT.
330 MEANS score /CELLS = NONE.
331 ])
332
333
334 AT_CHECK([pspp -O format=csv means-stat-keywords.sps], [0],
335   [dnl
336 Table: Case Processing Summary
337 ,Cases,,,,,
338 ,Included,,Excluded,,Total,
339 ,N,Percent,N,Percent,N,Percent
340 score: ,5,100%,0,0%,5,100%
341
342 Table: Report
343 ,Mean,N,Std. Deviation,S.E. Mean,Sum,Min,Max,Range,Variance,Kurtosis,S.E. Kurt,Skewness,S.E. Skew,First,Last,Harmonic Mean,Geom. Mean
344 score,22.40,5.00,4.62,2.06,112.00,16.00,29.00,13.00,21.30,1.85,2.00,.11,.91,22.00,23.00,21.61,22.01
345
346 Table: Case Processing Summary
347 ,Cases,,,,,
348 ,Included,,Excluded,,Total,
349 ,N,Percent,N,Percent,N,Percent
350 score: ,5,100%,0,0%,5,100%
351
352 Table: Report
353 ,Mean,N,Std. Deviation
354 score,22.40,5.00,4.62
355
356 Table: Case Processing Summary
357 ,Cases,,,,,
358 ,Included,,Excluded,,Total,
359 ,N,Percent,N,Percent,N,Percent
360 score: ,5,100%,0,0%,5,100%
361
362 Table: Report
363
364 score
365 ])
366
367 AT_CLEANUP
368
369
370
371
372 AT_SETUP([MEANS missing=table ])
373 AT_KEYWORDS([categorical categoricals])
374
375 AT_DATA([means-miss-table.sps], [dnl
376 data list notable list /a * b * g1.
377 begin data.
378 1 9 1  
379 2 9 1 
380 3 9 1 
381 4 9 2 
382 5 9 2 
383 6 9 2 
384 7 . 2 
385 end data.
386
387 MEANS a b BY g1
388       /a  BY g1
389       /cells =  COUNT
390       /missing = TABLE
391       .
392
393 MEANS a b BY g1
394       /a  BY g1
395       /cells =  COUNT
396       .
397 ])
398
399
400 AT_CHECK([pspp -O format=csv means-miss-table.sps], [0],
401   [dnl
402 Table: Case Processing Summary
403 ,Cases,,,,,
404 ,Included,,Excluded,,Total,
405 ,N,Percent,N,Percent,N,Percent
406 a: g1,7,100%,0,0%,7,100%
407 a: ,7,100%,0,0%,7,100%
408 b: g1,6,85.7143%,1,14.2857%,7,100%
409 b: ,6,85.7143%,1,14.2857%,7,100%
410
411 Table: Report
412 ,g1,N
413 a,1.00,3.00
414 ,2.00,3.00
415 b,1.00,3.00
416 ,2.00,3.00
417
418 Table: Report
419 ,N
420 a,6.00
421 b,6.00
422
423 Table: Case Processing Summary
424 ,Cases,,,,,
425 ,Included,,Excluded,,Total,
426 ,N,Percent,N,Percent,N,Percent
427 a: g1,7,100%,0,0%,7,100%
428 a: ,7,100%,0,0%,7,100%
429
430 Table: Report
431 ,g1,N
432 a,1.00,3.00
433 ,2.00,4.00
434
435 Table: Report
436 ,N
437 a,7.00
438
439 Table: Case Processing Summary
440 ,Cases,,,,,
441 ,Included,,Excluded,,Total,
442 ,N,Percent,N,Percent,N,Percent
443 a: g1,7,100%,0,0%,7,100%
444 a: ,7,100%,0,0%,7,100%
445 b: g1,6,85.7143%,1,14.2857%,7,100%
446 b: ,6,85.7143%,1,14.2857%,7,100%
447
448 Table: Report
449 ,g1,N
450 a,1.00,3.00
451 ,2.00,4.00
452 b,1.00,3.00
453 ,2.00,3.00
454
455 Table: Report
456 ,N
457 a,7.00
458 b,6.00
459
460 Table: Case Processing Summary
461 ,Cases,,,,,
462 ,Included,,Excluded,,Total,
463 ,N,Percent,N,Percent,N,Percent
464 a: g1,7,100%,0,0%,7,100%
465 a: ,7,100%,0,0%,7,100%
466
467 Table: Report
468 ,g1,N
469 a,1.00,3.00
470 ,2.00,4.00
471
472 Table: Report
473 ,N
474 a,7.00
475 ])
476
477 AT_CLEANUP
478
479
480
481
482
483 AT_SETUP([MEANS user missing values])
484 AT_KEYWORDS([categorical categoricals])
485
486 AT_DATA([means-missing.sps], [dnl
487 data list notable list /a * b * g1.
488 begin data.
489 1 2 9  
490 2 2 1 
491 3 2 1 
492 4 2 2 
493 5 2 2 
494 6 2 2 
495 7 9 2 
496 end data.
497
498 MISSING VALUES a b g1 (9).
499
500 MEANS a b BY g1 /cells =  COUNT .
501
502 MEANS a b BY g1 /cells =  COUNT /missing = include .
503
504 MEANS a b BY g1 /cells =  COUNT /missing = dependent .
505 ])
506
507
508 AT_CHECK([pspp -O format=csv means-missing.sps], [0],
509   [dnl
510 Table: Case Processing Summary
511 ,Cases,,,,,
512 ,Included,,Excluded,,Total,
513 ,N,Percent,N,Percent,N,Percent
514 a: g1,6,85.7143%,1,14.2857%,7,100%
515 a: ,7,100%,0,0%,7,100%
516 b: g1,5,71.4286%,2,28.5714%,7,100%
517 b: ,6,85.7143%,1,14.2857%,7,100%
518
519 Table: Report
520 ,g1,N
521 a,1.00,2.00
522 ,2.00,4.00
523 b,1.00,2.00
524 ,2.00,3.00
525
526 Table: Report
527 ,N
528 a,6.00
529 b,5.00
530
531 Table: Case Processing Summary
532 ,Cases,,,,,
533 ,Included,,Excluded,,Total,
534 ,N,Percent,N,Percent,N,Percent
535 a: g1,7,100%,0,0%,7,100%
536 a: ,7,100%,0,0%,7,100%
537 b: g1,7,100%,0,0%,7,100%
538 b: ,7,100%,0,0%,7,100%
539
540 Table: Report
541 ,g1,N
542 a,1.00,2.00
543 ,2.00,4.00
544 ,9.00,1.00
545 b,1.00,2.00
546 ,2.00,4.00
547 ,9.00,1.00
548
549 Table: Report
550 ,N
551 a,7.00
552 b,7.00
553
554 Table: Case Processing Summary
555 ,Cases,,,,,
556 ,Included,,Excluded,,Total,
557 ,N,Percent,N,Percent,N,Percent
558 a: g1,7,100%,0,0%,7,100%
559 a: ,7,100%,0,0%,7,100%
560 b: g1,6,85.7143%,1,14.2857%,7,100%
561 b: ,6,85.7143%,1,14.2857%,7,100%
562
563 Table: Report
564 ,g1,N
565 a,1.00,2.00
566 ,2.00,4.00
567 ,9.00,1.00
568 b,1.00,2.00
569 ,2.00,3.00
570 ,9.00,1.00
571
572 Table: Report
573 ,N
574 a,7.00
575 b,6.00
576 ])
577
578 AT_CLEANUP
579
580
581
582 AT_SETUP([MEANS empty factor spec])
583 AT_KEYWORDS([categorical categoricals])
584
585 AT_DATA([means-bad.sps], [dnl
586 data list list /outcome *.
587 begin data.
588 1
589 2
590 3
591 end data.
592
593 MEANS TABLES =  outcome 
594         BY.
595 ])
596
597 AT_CHECK([pspp -O format=csv means-bad.sps], [1], [ignore])
598
599 AT_CLEANUP
600
601
602
603 AT_SETUP([MEANS parser bug])
604 AT_KEYWORDS([categorical categoricals])
605
606 dnl This bug caused an infinite loop
607 AT_DATA([means-bad.sps], [dnl
608 DATA LIST notable LIST /a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 fylo *.
609 begin data.
610 1 2 3 4 5 6 7 8 9 0 11
611 end data.
612
613 MEANS TABLES = a1 a2 a3 a4 a5 a6 a7 a8 a9 a10a BY fylo.
614 ])
615
616 AT_CHECK([pspp -O format=csv means-bad.sps], [1], [ignore])
617
618 AT_CLEANUP
619
620
621
622