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