output: Introduce pivot tables.
[pspp] / tests / language / stats / t-test.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([T-TEST])
18
19 AT_SETUP([T-TEST /PAIRS])
20 AT_DATA([t-test.sps], [dnl
21 data list list /ID * A * B *.
22 begin data.
23 1 2.0 3.0
24 2 1.0 2.0
25 3 2.0 4.5
26 4 2.0 4.5
27 5 3.0 6.0
28 end data.
29
30 t-test /PAIRS a with b (PAIRED).
31 ])
32
33 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
34 AT_CHECK([cat pspp.csv], [0], [dnl
35 Table: Reading free-form data from INLINE.
36 Variable,Format
37 ID,F8.0
38 A,F8.0
39 B,F8.0
40
41 Table: Paired Sample Statistics
42 ,,N,Mean,Std. Deviation,S.E. Mean
43 Pair 1,A,5,2.00,.71,.32
44 ,B,5,4.00,1.54,.69
45
46 Table: Paired Samples Correlations
47 ,,N,Correlation,Sig.
48 Pair 1,A & B,5,.918,.028
49
50 Table: Paired Samples Test
51 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
52 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
53 ,,,,,Lower,Upper,,,
54 Pair 1,A - B,-2.00,.94,.42,-3.16,-.84,-4.78,4,.009
55 ])
56 AT_CLEANUP
57
58
59 AT_SETUP([T-TEST /PAIRS with per-analysis missing values])
60
61 AT_DATA([ref.sps], [dnl
62 data list list /id * a * b * c * d *.
63 begin data.
64 1 2.0 3.0 4.0 4.0
65 2 1.0 2.0 5.1 3.9
66 3 2.0 4.5 5.2 3.8
67 4 2.0 4.5 5.3 3.7
68 56 3.0 6.0 5.9 3.6
69 end data.
70
71 t-test /PAIRS a c with b d (PAIRED). 
72 ])
73
74 AT_DATA([expout], [dnl
75 Table: Reading free-form data from INLINE.
76 Variable,Format
77 id,F8.0
78 a,F8.0
79 b,F8.0
80 c,F8.0
81 d,F8.0
82
83 Table: Paired Sample Statistics
84 ,,N,Mean,Std. Deviation,S.E. Mean
85 Pair 1,a,5,2.00,.71,.32
86 ,b,5,4.00,1.54,.69
87 Pair 2,c,5,5.10,.69,.31
88 ,d,5,3.80,.16,.07
89
90 Table: Paired Samples Correlations
91 ,,N,Correlation,Sig.
92 Pair 1,a & b,5,.918,.028
93 Pair 2,c & d,5,-.918,.028
94
95 Table: Paired Samples Test
96 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
97 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
98 ,,,,,Lower,Upper,,,
99 Pair 1,a - b,-2.00,.94,.42,-3.16,-.84,-4.78,4,.009
100 Pair 2,c - d,1.30,.84,.37,.26,2.34,3.47,4,.025
101 ])
102
103 AT_CHECK([pspp -o ref.csv ref.sps])
104 AT_CHECK([cat ref.csv], [0], [expout])
105 AT_DATA([missing.sps], [dnl
106 data list list /id * a * b * c * d *.
107 begin data.
108 1 2.0 3.0 4.0 4.0 
109 2 1.0 2.0 5.1 3.9
110 3 2.0 4.5 5.2 3.8
111 4 2.0 4.5 5.3 3.7
112 5 3.0 6.0 5.9 .
113 6 3.0  .  5.9 3.6
114 end data.
115
116
117 t-test /MISSING=analysis /PAIRS a c with b d (PAIRED) /CRITERIA=CI(0.95).
118 ])
119
120 AT_CHECK([pspp -o missing.csv missing.sps])
121 AT_CHECK([cat missing.csv], [0], [expout])
122 AT_CLEANUP
123
124 AT_SETUP([T-TEST /PAIRS with listwise missing values])
125 AT_DATA([ref.sps], [dnl
126 data list list /id * a * b * c * d *.
127 begin data.
128 1 2.0 3.0 4.0 4.0
129 2 1.0 2.0 5.1 3.9
130 3 2.0 4.5 5.2 3.8
131 4 2.0 4.5 5.3 3.7
132 5 3.0 6.0 5.9 3.6
133 end data.
134
135 t-test /PAIRS a b with c d (PAIRED). 
136 ])
137
138 AT_DATA([expout], [dnl
139 Table: Reading free-form data from INLINE.
140 Variable,Format
141 id,F8.0
142 a,F8.0
143 b,F8.0
144 c,F8.0
145 d,F8.0
146
147 Table: Paired Sample Statistics
148 ,,N,Mean,Std. Deviation,S.E. Mean
149 Pair 1,a,5,2.00,.71,.32
150 ,c,5,5.10,.69,.31
151 Pair 2,b,5,4.00,1.54,.69
152 ,d,5,3.80,.16,.07
153
154 Table: Paired Samples Correlations
155 ,,N,Correlation,Sig.
156 Pair 1,a & c,5,.410,.493
157 Pair 2,b & d,5,-.872,.054
158
159 Table: Paired Samples Test
160 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
161 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
162 ,,,,,Lower,Upper,,,
163 Pair 1,a - c,-3.10,.76,.34,-4.04,-2.16,-9.14,4,.001
164 Pair 2,b - d,.20,1.68,.75,-1.89,2.29,.27,4,.803
165 ])
166
167 AT_CHECK([pspp -o ref.csv ref.sps])
168
169 AT_CHECK([cat ref.csv], [0], [expout])
170
171 AT_DATA([missing.sps], [dnl
172 data list list /id * a * b * c * d *.
173 begin data.
174 1 2.0 3.0 4.0 4.0 
175 2 1.0 2.0 5.1 3.9
176 3 2.0 4.5 5.2 3.8
177 4 2.0 4.5 5.3 3.7
178 5 3.0 6.0 5.9 3.6
179 6 3.0 6.0 5.9  .
180 end data.
181
182
183 t-test /MISSING=listwise /PAIRS a b with c d (PAIRED). 
184 ])
185 AT_CHECK([pspp -o missing.csv missing.sps])
186 AT_CHECK([cat missing.csv], [0], [expout])
187 AT_CLEANUP
188
189
190 dnl Tests for a bug in the paired samples T test when weighted
191 dnl Thanks to Douglas Bonett for reporting this.
192 AT_SETUP([T-TEST weighted paired bug])
193 AT_DATA([t-test.sps], [dnl
194 DATA LIST notable LIST /x y w *.
195 BEGIN DATA.
196 1 1 255
197 1 2 43
198 1 3 216
199 2 1 3
200 2 2 1
201 2 3 12
202 END DATA.
203
204 WEIGHT BY w.
205
206 T-TEST
207         PAIRS =  y WITH  x (PAIRED)
208         /MISSING=ANALYSIS
209         /CRITERIA=CI(0.95).
210 ])
211
212 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
213 AT_CHECK([cat pspp.csv], [0], [dnl
214 Table: Paired Sample Statistics
215 ,,N,Mean,Std. Deviation,S.E. Mean
216 Pair 1,y,530.00,1.94,.96,.04
217 ,x,530.00,1.03,.17,.01
218
219 Table: Paired Samples Correlations
220 ,,N,Correlation,Sig.
221 Pair 1,y & x,530.00,.114,.008
222
223 Table: Paired Samples Test
224 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
225 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
226 ,,,,,Lower,Upper,,,
227 Pair 1,y - x,.91,.95,.04,.83,.99,22.07,529.00,.000
228 ])
229 AT_CLEANUP
230
231
232 dnl Tests for a bug in the paired samples T test.
233 dnl Thanks to Mike Griffiths for reporting this problem.
234 AT_SETUP([T-TEST /PAIRS bug])
235 AT_DATA([t-test.sps], [dnl
236 set format f8.3.
237 data list list /A * B *.
238 begin data.
239 11 2
240 1  1
241 1  1
242 end data.
243
244 t-test pairs = a with b (paired).
245 ])
246 AT_CHECK([pspp -o pspp.csv t-test.sps])
247 AT_CHECK([cat pspp.csv], [0], [dnl
248 Table: Reading free-form data from INLINE.
249 Variable,Format
250 A,F8.0
251 B,F8.0
252
253 Table: Paired Sample Statistics
254 ,,N,Mean,Std. Deviation,S.E. Mean
255 Pair 1,A,3,4.333,5.774,3.333
256 ,B,3,1.333,.577,.333
257
258 Table: Paired Samples Correlations
259 ,,N,Correlation,Sig.
260 Pair 1,A & B,3,1.000,.000
261
262 Table: Paired Samples Test
263 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
264 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
265 ,,,,,Lower,Upper,,,
266 Pair 1,A - B,3.000,5.196,3.000,-9.908,15.908,1.000,2,.423
267 ])
268 AT_CLEANUP
269
270 AT_SETUP([T-TEST /GROUPS])
271 AT_DATA([t-test.sps], [dnl
272 data list list /ID * INDEP * DEP1 * DEP2 *.
273 begin data.
274 1  1.1 1 3
275 2  1.1 2 4
276 3  1.1 2 4 
277 4  1.1 2 4 
278 5  1.1 3 5
279 6  2.1 3 1
280 7  2.1 4 2
281 8  2.1 4 2
282 9  2.1 4 2
283 10 2.1 5 3
284 11 3.1 2 2
285 end data.
286
287 * Note that the last case should be IGNORED since it doesn't have a
288   dependent variable of either 1.1 or 2.1.
289
290 t-test /GROUPS=indep(1.1,2.1) /var=dep1 dep2.
291 ])
292
293 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
294 AT_CHECK([cat pspp.csv], [0], [dnl
295 Table: Reading free-form data from INLINE.
296 Variable,Format
297 ID,F8.0
298 INDEP,F8.0
299 DEP1,F8.0
300 DEP2,F8.0
301
302 Table: Group Statistics
303 ,Group,N,Mean,Std. Deviation,S.E. Mean
304 DEP1,1.10,5,2.00,.71,.32
305 ,2.10,5,4.00,.71,.32
306 DEP2,1.10,5,4.00,.71,.32
307 ,2.10,5,2.00,.71,.32
308
309 Table: Independent Samples Test
310 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
311 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
312 ,,,,,,,,,Lower,Upper
313 DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
314 ,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
315 DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03
316 ,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03
317 ])
318 AT_CLEANUP
319
320 AT_SETUP([T-TEST /GROUPS with one value for independent variable])
321 AT_DATA([t-test.sps], [dnl
322 data list list /INDEP * DEP *.
323 begin data.
324        1        6
325        1        6
326        1        7
327        1        6
328        1       13
329        1        4
330        1        7
331        1        9
332        1        7
333        1       12
334        1       11
335        2       11
336        2        9
337        2        8
338        2        4
339        2       16
340        2        9
341        2        9
342        2        5
343        2        4
344        2       10
345        2       14
346 end data.
347 t-test /groups=indep(1.514) /var=dep.
348 ])
349
350 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
351 AT_CHECK([cat pspp.csv], [0], [dnl
352 Table: Reading free-form data from INLINE.
353 Variable,Format
354 INDEP,F8.0
355 DEP,F8.0
356
357 Table: Group Statistics
358 ,Group,N,Mean,Std. Deviation,S.E. Mean
359 DEP,≥    1.51,11,9.00,3.82,1.15
360 ,<    1.51,11,8.00,2.86,.86
361
362 Table: Independent Samples Test
363 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
364 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
365 ,,,,,,,,,Lower,Upper
366 DEP,Equal variances assumed,.17,.683,.69,20.00,.495,1.00,1.44,-2.00,4.00
367 ,Equal variances not assumed,,,.69,18.54,.496,1.00,1.44,-2.02,4.02
368 ])
369 AT_CLEANUP
370
371 AT_SETUP([T-TEST /GROUPS with per-analysis missing values])
372 AT_DATA([ref.sps], [dnl
373 data list list /id * indep * dep1 * dep2 *.
374 begin data.
375 1  1.0 3.5 6
376 2  1.0 2.0 5
377 3  1.0 2.0 4
378 4  2.0 3.5 3
379 56 2.0 3.0 1
380 end data.
381
382 t-test /group=indep /var=dep1, dep2.
383 ])
384 AT_DATA([expout], [dnl
385 Table: Reading free-form data from INLINE.
386 Variable,Format
387 id,F8.0
388 indep,F8.0
389 dep1,F8.0
390 dep2,F8.0
391
392 Table: Group Statistics
393 ,Group,N,Mean,Std. Deviation,S.E. Mean
394 dep1,1.00,3,2.50,.87,.50
395 ,2.00,2,3.25,.35,.25
396 dep2,1.00,3,5.00,1.00,.58
397 ,2.00,2,2.00,1.41,1.00
398
399 Table: Independent Samples Test
400 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
401 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
402 ,,,,,,,,,Lower,Upper
403 dep1,Equal variances assumed,3.75,.148,-1.12,3.00,.346,-.75,.67,-2.89,1.39
404 ,Equal variances not assumed,,,-1.34,2.78,.279,-.75,.56,-2.61,1.11
405 dep2,Equal variances assumed,.60,.495,2.85,3.00,.065,3.00,1.05,-.35,6.35
406 ,Equal variances not assumed,,,2.60,1.68,.144,3.00,1.15,-2.98,8.98
407 ])
408 AT_CHECK([pspp -o ref.csv ref.sps])
409 AT_CHECK([cat ref.csv], [0], [expout])
410 AT_DATA([missing.sps], [dnl
411 data list list /id * indep * dep1 * dep2.
412 begin data.
413 1 1.0 3.5 6
414 2 1.0 2.0 5
415 3 1.0 2.0 4
416 4 2.0 3.5 3
417 5 2.0 3.0 .
418 6 2.0 .   1
419 7  .  3.1 5
420 end data.
421
422 * Note that if the independent variable is missing, then it's implicitly 
423 * listwise missing.
424
425 t-test /missing=analysis /group=indep /var=dep1 dep2.
426 ])
427 AT_CHECK([pspp -o missing.csv missing.sps])
428 AT_CHECK([cat missing.csv], [0], [expout])
429 AT_CLEANUP
430
431 AT_SETUP([T-TEST /GROUPS with listwise missing values])
432 AT_DATA([ref.sps], [dnl
433 data list list /id * indep * dep1 * dep2.
434 begin data.
435 1 1.0 3.5 6
436 2 1.0 2.0 5
437 3 1.0 2.0 4
438 4 2.0 3.5 3
439 5 2.0 3.0 2
440 6 2.0 4.0 1
441 end data.
442
443 t-test /group=indep /var=dep1 dep2.
444 ])
445
446 AT_DATA([expout], [dnl
447 Table: Reading free-form data from INLINE.
448 Variable,Format
449 id,F8.0
450 indep,F8.0
451 dep1,F8.0
452 dep2,F8.0
453
454 Table: Group Statistics
455 ,Group,N,Mean,Std. Deviation,S.E. Mean
456 dep1,1.00,3,2.50,.87,.50
457 ,2.00,3,3.50,.50,.29
458 dep2,1.00,3,5.00,1.00,.58
459 ,2.00,3,2.00,1.00,.58
460
461 Table: Independent Samples Test
462 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
463 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
464 ,,,,,,,,,Lower,Upper
465 dep1,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60
466 ,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77
467 dep2,Equal variances assumed,.00,1.000,3.67,4.00,.021,3.00,.82,.73,5.27
468 ,Equal variances not assumed,,,3.67,4.00,.021,3.00,.82,.73,5.27
469 ])
470
471 AT_CHECK([pspp -o ref.csv ref.sps])
472 AT_CHECK([cat ref.csv], [0], [expout])
473 AT_DATA([missing.sps], [dnl
474 data list list /id * indep * dep1 * dep2 *.
475 begin data.
476 1 1.0 3.5 6
477 2 1.0 2.0 5
478 3 1.0 2.0 4
479 4 2.0 3.5 3
480 5 2.0 3.0 2
481 6 2.0 4.0 1
482 7 2.0 .   0
483 end data.
484
485 t-test /missing=listwise,exclude /group=indep /var=dep1, dep2.
486 ])
487 AT_CHECK([pspp -o missing.csv missing.sps])
488 AT_CHECK([cat missing.csv], [0], [expout])
489 AT_CLEANUP
490
491 AT_SETUP([T-TEST /TESTVAL])
492 AT_DATA([t-test.sps], [dnl
493 data list list /ID * ABC *.
494 begin data.
495 1 3.5
496 2 2.0
497 3 2.0
498 4 3.5
499 5 3.0
500 6 4.0
501 end data.
502
503 t-test /testval=2.0 /var=abc.
504 ])
505 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
506 AT_CHECK([cat pspp.csv], [0], [dnl
507 Table: Reading free-form data from INLINE.
508 Variable,Format
509 ID,F8.0
510 ABC,F8.0
511
512 Table: One-Sample Statistics
513 ,N,Mean,Std. Deviation,S.E. Mean
514 ABC,6,3.00,.84,.34
515
516 Table: One-Sample Test
517 ,Test Value = 2,,,,,
518 ,t,df,Sig. (2-tailed),Mean Difference,95% Confidence Interval of the Difference,
519 ,,,,,Lower,Upper
520 ABC,2.93,5,.033,1.00,.12,1.88
521 ])
522 AT_CLEANUP
523
524 AT_SETUP([T-TEST /TESTVAL with per-analysis missing values])
525 AT_DATA([ref.sps], [dnl
526 data list list /id * x1 * x2.
527 begin data.
528 1 3.5 34
529 2 2.0 10
530 3 2.0 23
531 4 3.5 98
532 5 3.0 23
533 67 4.0 8
534 end data.
535
536 t-test /testval=3.0 /var=x1 x2.
537 ])
538 AT_DATA([expout], [dnl
539 Table: Reading free-form data from INLINE.
540 Variable,Format
541 id,F8.0
542 x1,F8.0
543 x2,F8.0
544
545 Table: One-Sample Statistics
546 ,N,Mean,Std. Deviation,S.E. Mean
547 x1,6,3.00,.84,.34
548 x2,6,32.67,33.40,13.64
549
550 Table: One-Sample Test
551 ,Test Value = 3,,,,,
552 ,t,df,Sig. (2-tailed),Mean Difference,95% Confidence Interval of the Difference,
553 ,,,,,Lower,Upper
554 x1,.00,5,1.000,.00,-.88,.88
555 x2,2.18,5,.082,29.67,-5.39,64.72
556 ])
557 AT_CHECK([pspp -o ref.csv ref.sps])
558 AT_CHECK([cat ref.csv], [0], [expout])
559 AT_DATA([missing.sps], [dnl
560 data list list /id * x1 * x2.
561 begin data.
562 1 3.5 34
563 2 2.0 10
564 3 2.0 23
565 4 3.5 98
566 5 3.0 23
567 6 4.0 .
568 7  .  8
569 end data.
570
571 t-test /missing=analysis /testval=3.0 /var=x1 x2.
572 ])
573 AT_CHECK([pspp -o missing.csv missing.sps])
574 AT_CHECK([cat missing.csv], [0], [expout])
575 AT_CLEANUP
576
577 AT_SETUP([T-TEST /TESTVAL with listwise missing values])
578 AT_DATA([ref.sps], [dnl
579 data list list /id * x1 * x2.
580 begin data.
581 1 3.5 34
582 2 2.0 10
583 3 2.0 23
584 4 3.5 98
585 5 3.0 23
586 end data.
587
588 t-test /testval=3.0 /var=x1 x2.
589 ])
590 AT_DATA([expout], [dnl
591 Table: Reading free-form data from INLINE.
592 Variable,Format
593 id,F8.0
594 x1,F8.0
595 x2,F8.0
596
597 Table: One-Sample Statistics
598 ,N,Mean,Std. Deviation,S.E. Mean
599 x1,5,2.80,.76,.34
600 x2,5,37.60,34.82,15.57
601
602 Table: One-Sample Test
603 ,Test Value = 3,,,,,
604 ,t,df,Sig. (2-tailed),Mean Difference,95% Confidence Interval of the Difference,
605 ,,,,,Lower,Upper
606 x1,-.59,4,.587,-.20,-1.14,.74
607 x2,2.22,4,.090,34.60,-8.63,77.83
608 ])
609 AT_CHECK([pspp -o ref.csv ref.sps])
610 AT_CHECK([cat ref.csv], [0], [expout])
611 AT_DATA([missing.sps], [dnl
612 data list list /id * x1 * x2.
613 begin data.
614 1 3.5 34
615 2 2.0 10
616 3 2.0 23
617 4 3.5 98
618 5 3.0 23
619 6 4.0 99
620 end data.
621
622 MISSING VALUES x2(99).
623
624 t-test /missing=listwise /testval=3.0 /var=x1 x2.
625 ])
626 AT_CHECK([pspp -o missing.csv missing.sps])
627 AT_CHECK([cat missing.csv], [0], [expout])
628 AT_CLEANUP
629
630 AT_SETUP([T-TEST wih TEMPORARY transformation])
631 AT_DATA([ref.sps], [dnl
632 data list list /ind * x * .
633 begin data.
634 1 3.5
635 1 2.0
636 1 2.0
637 2 3.5
638 2 3.0
639 2 4.0
640 end data.
641
642 t-test /groups=ind(1,2) /var x.
643 ])
644 AT_DATA([expout], [dnl
645 Table: Reading free-form data from INLINE.
646 Variable,Format
647 ind,F8.0
648 x,F8.0
649
650 Table: Group Statistics
651 ,Group,N,Mean,Std. Deviation,S.E. Mean
652 x,1.00,3,2.50,.87,.50
653 ,2.00,3,3.50,.50,.29
654
655 Table: Independent Samples Test
656 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
657 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
658 ,,,,,,,,,Lower,Upper
659 x,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60
660 ,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77
661 ])
662 AT_CHECK([pspp -o ref.csv ref.sps])
663 AT_CHECK([cat ref.csv], [0], [expout])
664 AT_DATA([temporary.sps], [dnl
665 data list list /ind * x * .
666 begin data.
667 1 3.5
668 1 2.0
669 1 2.0
670 2 3.5
671 2 3.0
672 2 4.0
673 2 9.0
674 end data.
675
676 TEMPORARY.
677 SELECT IF x < 7.
678
679 t-test /groups=ind(1 2) /var x.
680 ])
681 AT_CHECK([pspp -o temporary.csv temporary.sps])
682 AT_CHECK([cat temporary.csv], [0], [expout])
683 AT_CLEANUP
684
685 dnl This is an example from doc/tutorial.texi
686 dnl So if the results of this have to be changed in any way,
687 dnl make sure to update that file.
688 AT_SETUP([T-TEST tutorial example])
689 cp $top_srcdir/examples/physiology.sav .
690 AT_DATA([t-test.sps], [dnl
691 GET FILE='physiology.sav'.
692 RECODE height (179 = SYSMIS).
693 T-TEST GROUP=sex(0,1) /VARIABLES=height temperature.
694 ])
695 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
696 AT_CHECK([cat pspp.csv], [0], [dnl
697 Table: Group Statistics
698 ,Group,N,Mean,Std. Deviation,S.E. Mean
699 Height in millimeters   ,Male,22,1796.49,49.71,10.60
700 ,Female,17,1610.77,25.43,6.17
701 Internal body temperature in degrees Celcius,Male,22,36.68,1.95,.42
702 ,Female,18,37.43,1.61,.38
703
704 Table: Independent Samples Test
705 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
706 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
707 ,,,,,,,,,Lower,Upper
708 Height in millimeters   ,Equal variances assumed,.97,.331,14.02,37.00,.000,185.72,13.24,158.88,212.55
709 ,Equal variances not assumed,,,15.15,32.71,.000,185.72,12.26,160.76,210.67
710 Internal body temperature in degrees Celcius,Equal variances assumed,.31,.581,-1.31,38.00,.198,-.75,.57,-1.91,.41
711 ,Equal variances not assumed,,,-1.33,37.99,.190,-.75,.56,-1.89,.39
712 ])
713 AT_CLEANUP
714
715 dnl Tests for a bug which caused T-TEST to crash when given invalid syntax.
716 AT_SETUP([T-TEST invalid syntax])
717 AT_DATA([t-test.sps], [dnl
718 DATA LIST LIST NOTABLE /id * a * .
719 BEGIN DATA.
720 1 3.5
721 2 2.0
722 3 2.0
723 4 3.5
724 5 3.0
725 6 4.0
726 END DATA.
727
728 T-TEST /testval=2.0 .
729 T-TEST /groups=id(3) .
730 ])
731 AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl
732 t-test.sps:11: error: T-TEST: Required subcommand VARIABLES was not specified.
733
734 t-test.sps:12: error: T-TEST: Required subcommand VARIABLES was not specified.
735 ])
736 AT_CLEANUP
737
738 dnl Tests for bug #11227, exhibited when the independent variable is a string.
739 AT_SETUP([T-TEST string variable])
740 AT_DATA([t-test.sps], [dnl
741 data list list /ID * INDEP (a1) DEP1 * DEP2 *.
742 begin data.
743 1  'a' 1 3
744 2  'a' 2 4
745 3  'a' 2 4 
746 4  'a' 2 4 
747 5  'a' 3 5
748 6  'b' 3 1
749 7  'b' 4 2
750 8  'b' 4 2
751 9  'b' 4 2
752 10 'b' 5 3
753 11 'c' 2 2
754 end data.
755
756
757 t-test /GROUPS=indep('a','b') /var=dep1 dep2.
758 ])
759
760 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
761 AT_CHECK([cat pspp.csv], [0], [dnl
762 Table: Reading free-form data from INLINE.
763 Variable,Format
764 ID,F8.0
765 INDEP,A1
766 DEP1,F8.0
767 DEP2,F8.0
768
769 Table: Group Statistics
770 ,Group,N,Mean,Std. Deviation,S.E. Mean
771 DEP1,a,5,2.00,.71,.32
772 ,b,5,4.00,.71,.32
773 DEP2,a,5,4.00,.71,.32
774 ,b,5,2.00,.71,.32
775
776 Table: Independent Samples Test
777 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
778 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
779 ,,,,,,,,,Lower,Upper
780 DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
781 ,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
782 DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03
783 ,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03
784 ])
785 AT_CLEANUP
786
787 AT_SETUP([T-TEST string variable, only one value])
788 AT_DATA([t-test.sps], [dnl
789 data list list notable /id * indep (a1) dep1 * dep2 *.
790 begin data.
791 1  'a' 1 3
792 2  'a' 2 4
793 3  'a' 2 4 
794 4  'a' 2 4 
795 5  'a' 3 5
796 6  'b' 3 1
797 7  'b' 4 2
798 8  'b' 4 2
799 9  'b' 4 2
800 10 'b' 5 3
801 11 'c' 2 2
802 end data.
803
804
805 t-test /GROUPS=indep('a') /var=dep1 dep2.
806 ])
807 AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl
808 "t-test.sps:17: error: T-TEST: When applying GROUPS to a string variable, two values must be specified."
809 ])
810 AT_CLEANUP
811
812 dnl Tests for a bug which didn't properly compare string values.
813 AT_SETUP([T-TEST string variable comparison bug])
814 AT_DATA([t-test.sps], [dnl
815 data list list /x * gv (a8).
816 begin data.
817 3   One
818 2   One
819 3   One
820 2   One
821 3   One
822 4   Two
823 3.5 Two
824 3.0 Two
825 end data.
826
827 t-test group=gv('One', 'Two')
828         /variables = x.
829 ])
830
831 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
832 AT_CHECK([cat pspp.csv], [0], [dnl
833 Table: Reading free-form data from INLINE.
834 Variable,Format
835 x,F8.0
836 gv,A8
837
838 Table: Group Statistics
839 ,Group,N,Mean,Std. Deviation,S.E. Mean
840 x,One,5,2.60,.55,.24
841 ,Two,3,3.50,.50,.29
842
843 Table: Independent Samples Test
844 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
845 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
846 ,,,,,,,,,Lower,Upper
847 x,Equal variances assumed,1.13,.329,-2.32,6.00,.060,-.90,.39,-1.85,.05
848 ,Equal variances not assumed,,,-2.38,4.70,.067,-.90,.38,-1.89,.09
849 ])
850 AT_CLEANUP
851
852
853
854 dnl Tests for a bug assert failed when the group variables were not of either class
855 AT_SETUP([T-TEST wrong group])
856 AT_DATA([t-test-crs.sps], [dnl
857 data list list /x * g *.
858 begin data.
859 1 2
860 2 2
861 3 2
862 4 2
863 5 2 
864 end data.
865
866 t-test /variables = x group=g(1,3).
867 ])
868
869 AT_CHECK([pspp t-test-crs.sps], [0],[ignore], [ignore])
870
871 AT_CLEANUP
872
873
874
875 dnl Tests for a bug assert failed when a non-number was passes as the p value
876 AT_SETUP([T-TEST non number p value])
877 AT_DATA([t.sps], [dnl
878 data list list /age d_frage_1 weight height *.
879 begin data.
880 1 2 3 1
881 4 5 6 2
882 end data.
883
884 T-TEST /VARIABLES=age weight height
885  /GROUPS=d_frage_1(1,0) /MISSING=ANALYSIS /CRITERIA=CIN(p.95).
886 ])
887
888 AT_CHECK([pspp t.sps], [1],[ignore], [ignore])
889
890 AT_CLEANUP
891
892
893
894 dnl Another crash on invalid input
895 AT_SETUP([T-TEST unterminated string - paired])
896 AT_DATA([t.sps], [dnl
897 data list list /id * a * b * c * d *.
898 begin data.
899 5 2.0 3.0 4.0 4.0
900 3 1.0 2.0 5.1 3.9
901 3 2.0 4.5 5.2(3.8
902 4 2.0 4.5 5n3 3.7
903 5 3.0 6.0 5.9 3.6
904 6 3.4 6.0 5.9  .
905 end data.
906
907
908 t-test /MISSING=listwise /PAIRS a"b with c d (PA        RED).
909 ])
910
911 AT_CHECK([pspp t.sps],[1],[ignore],[ignore])
912
913 AT_CLEANUP