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