46492319cf04ccb623fe95a0829ec0727c1f23b1
[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 format=csv t-test.sps], [0], [dnl
34 Table: Reading free-form data from INLINE.
35 Variable,Format
36 ID,F8.0
37 A,F8.0
38 B,F8.0
39
40 Table: Paired Sample Statistics
41 ,,Mean,N,Std. Deviation,S.E. Mean
42 Pair 1,A,2.00,5,.71,.32
43 ,B,4.00,5,1.54,.69
44
45 Table: Paired Samples Correlations
46 ,,N,Correlation,Sig.
47 Pair 1,A & B,5,.92,.028
48
49 Table: Paired Samples Test
50 ,,Paired Differences,,,,,,,
51 ,,,,,95% Confidence Interval of the Difference,,,,
52 ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed)
53 Pair 1,A - B,-2.00,.94,.42,-3.16,-.84,-4.78,4,.009
54 ])
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 ,,Mean,N,Std. Deviation,S.E. Mean
85 Pair 1,a,2.00,5,.71,.32
86 ,b,4.00,5,1.54,.69
87 Pair 2,c,5.10,5,.69,.31
88 ,d,3.80,5,.16,.07
89
90 Table: Paired Samples Correlations
91 ,,N,Correlation,Sig.
92 Pair 1,a & b,5,.92,.028
93 Pair 2,c & d,5,-.92,.028
94
95 Table: Paired Samples Test
96 ,,Paired Differences,,,,,,,
97 ,,,,,95% Confidence Interval of the Difference,,,,
98 ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed)
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 ,,Mean,N,Std. Deviation,S.E. Mean
149 Pair 1,a,2.00,5,.71,.32
150 ,c,5.10,5,.69,.31
151 Pair 2,b,4.00,5,1.54,.69
152 ,d,3.80,5,.16,.07
153
154 Table: Paired Samples Correlations
155 ,,N,Correlation,Sig.
156 Pair 1,a & c,5,.41,.493
157 Pair 2,b & d,5,-.87,.054
158
159 Table: Paired Samples Test
160 ,,Paired Differences,,,,,,,
161 ,,,,,95% Confidence Interval of the Difference,,,,
162 ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed)
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 format=csv t-test.sps], [0], [dnl
213 Table: Paired Sample Statistics
214 ,,Mean,N,Std. Deviation,S.E. Mean
215 Pair 1,y,1.94,530.00,.96,.04
216 ,x,1.03,530.00,.17,.01
217
218 Table: Paired Samples Correlations
219 ,,N,Correlation,Sig.
220 Pair 1,y & x,530.00,.11,.008
221
222 Table: Paired Samples Test
223 ,,Paired Differences,,,,,,,
224 ,,,,,95% Confidence Interval of the Difference,,,,
225 ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed)
226 Pair 1,y - x,.91,.95,.04,.83,.99,22.07,529.00,.000
227 ])
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 ,,Mean,N,Std. Deviation,S.E. Mean
255 Pair 1,A,4.333,3,5.774,3.333
256 ,B,1.333,3,.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,,,,,,,
264 ,,,,,95% Confidence Interval of the Difference,,,,
265 ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed)
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 format=csv t-test.sps], [0], [dnl
294 Table: Reading free-form data from INLINE.
295 Variable,Format
296 ID,F8.0
297 INDEP,F8.0
298 DEP1,F8.0
299 DEP2,F8.0
300
301 Table: Group Statistics
302 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
303 DEP1,1.10,5,2.00,.71,.32
304 ,2.10,5,4.00,.71,.32
305 DEP2,1.10,5,4.00,.71,.32
306 ,2.10,5,2.00,.71,.32
307
308 Table: Independent Samples Test
309 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
310 ,,,,,,,,,95% Confidence Interval of the Difference,
311 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
312 DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
313 ,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
314 DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03
315 ,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03
316 ])
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 format=csv t-test.sps], [0], [dnl
351 Table: Reading free-form data from INLINE.
352 Variable,Format
353 INDEP,F8.0
354 DEP,F8.0
355
356 Table: Group Statistics
357 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
358 DEP,≥    1.51,11,9.00,3.82,1.15
359 ,<    1.51,11,8.00,2.86,.86
360
361 Table: Independent Samples Test
362 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
363 ,,,,,,,,,95% Confidence Interval of the Difference,
364 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
365 DEP,Equal variances assumed,.17,.683,.69,20.00,.495,1.00,1.44,-2.00,4.00
366 ,Equal variances not assumed,,,.69,18.54,.496,1.00,1.44,-2.02,4.02
367 ])
368 AT_CLEANUP
369
370 AT_SETUP([T-TEST /GROUPS with per-analysis missing values])
371 AT_DATA([ref.sps], [dnl
372 data list list /id * indep * dep1 * dep2 *.
373 begin data.
374 1  1.0 3.5 6
375 2  1.0 2.0 5
376 3  1.0 2.0 4
377 4  2.0 3.5 3
378 56 2.0 3.0 1
379 end data.
380
381 t-test /group=indep /var=dep1, dep2.
382 ])
383 AT_DATA([expout], [dnl
384 Table: Reading free-form data from INLINE.
385 Variable,Format
386 id,F8.0
387 indep,F8.0
388 dep1,F8.0
389 dep2,F8.0
390
391 Table: Group Statistics
392 ,indep,N,Mean,Std. Deviation,S.E. Mean
393 dep1,1.00,3,2.50,.87,.50
394 ,2.00,2,3.25,.35,.25
395 dep2,1.00,3,5.00,1.00,.58
396 ,2.00,2,2.00,1.41,1.00
397
398 Table: Independent Samples Test
399 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
400 ,,,,,,,,,95% Confidence Interval of the Difference,
401 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
402 dep1,Equal variances assumed,3.75,.148,-1.12,3.00,.346,-.75,.67,-2.89,1.39
403 ,Equal variances not assumed,,,-1.34,2.78,.279,-.75,.56,-2.61,1.11
404 dep2,Equal variances assumed,.60,.495,2.85,3.00,.065,3.00,1.05,-.35,6.35
405 ,Equal variances not assumed,,,2.60,1.68,.144,3.00,1.15,-2.98,8.98
406 ])
407 AT_CHECK([pspp -o ref.csv ref.sps])
408 AT_CHECK([cat ref.csv], [0], [expout])
409 AT_DATA([missing.sps], [dnl
410 data list list /id * indep * dep1 * dep2.
411 begin data.
412 1 1.0 3.5 6
413 2 1.0 2.0 5
414 3 1.0 2.0 4
415 4 2.0 3.5 3
416 5 2.0 3.0 .
417 6 2.0 .   1
418 7  .  3.1 5
419 end data.
420
421 * Note that if the independent variable is missing, then it's implicitly 
422 * listwise missing.
423
424 t-test /missing=analysis /group=indep /var=dep1 dep2.
425 ])
426 AT_CHECK([pspp -o missing.csv missing.sps])
427 AT_CHECK([cat missing.csv], [0], [expout])
428 AT_CLEANUP
429
430 AT_SETUP([T-TEST /GROUPS with listwise missing values])
431 AT_DATA([ref.sps], [dnl
432 data list list /id * indep * dep1 * dep2.
433 begin data.
434 1 1.0 3.5 6
435 2 1.0 2.0 5
436 3 1.0 2.0 4
437 4 2.0 3.5 3
438 5 2.0 3.0 2
439 6 2.0 4.0 1
440 end data.
441
442 t-test /group=indep /var=dep1 dep2.
443 ])
444
445 AT_DATA([expout], [dnl
446 Table: Reading free-form data from INLINE.
447 Variable,Format
448 id,F8.0
449 indep,F8.0
450 dep1,F8.0
451 dep2,F8.0
452
453 Table: Group Statistics
454 ,indep,N,Mean,Std. Deviation,S.E. Mean
455 dep1,1.00,3,2.50,.87,.50
456 ,2.00,3,3.50,.50,.29
457 dep2,1.00,3,5.00,1.00,.58
458 ,2.00,3,2.00,1.00,.58
459
460 Table: Independent Samples Test
461 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
462 ,,,,,,,,,95% Confidence Interval of the Difference,
463 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
464 dep1,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60
465 ,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77
466 dep2,Equal variances assumed,.00,1.000,3.67,4.00,.021,3.00,.82,.73,5.27
467 ,Equal variances not assumed,,,3.67,4.00,.021,3.00,.82,.73,5.27
468 ])
469
470 AT_CHECK([pspp -o ref.csv ref.sps])
471 AT_CHECK([cat ref.csv], [0], [expout])
472 AT_DATA([missing.sps], [dnl
473 data list list /id * indep * dep1 * dep2 *.
474 begin data.
475 1 1.0 3.5 6
476 2 1.0 2.0 5
477 3 1.0 2.0 4
478 4 2.0 3.5 3
479 5 2.0 3.0 2
480 6 2.0 4.0 1
481 7 2.0 .   0
482 end data.
483
484 t-test /missing=listwise,exclude /group=indep /var=dep1, dep2.
485 ])
486 AT_CHECK([pspp -o missing.csv missing.sps])
487 AT_CHECK([cat missing.csv], [0], [expout])
488 AT_CLEANUP
489
490 AT_SETUP([T-TEST /TESTVAL])
491 AT_DATA([t-test.sps], [dnl
492 data list list /ID * ABC *.
493 begin data.
494 1 3.5
495 2 2.0
496 3 2.0
497 4 3.5
498 5 3.0
499 6 4.0
500 end data.
501
502 t-test /testval=2.0 /var=abc.
503 ])
504 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
505 Table: Reading free-form data from INLINE.
506 Variable,Format
507 ID,F8.0
508 ABC,F8.0
509
510 Table: One-Sample Statistics
511 ,N,Mean,Std. Deviation,S.E. Mean
512 ABC,6,3.00,.84,.34
513
514 Table: One-Sample Test
515 ,Test Value = 2.000000,,,,,
516 ,,,,,95% Confidence Interval of the Difference,
517 ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper
518 ABC,2.93,5,.033,1.00,.12,1.88
519 ])
520 AT_CLEANUP
521
522 AT_SETUP([T-TEST /TESTVAL with per-analysis missing values])
523 AT_DATA([ref.sps], [dnl
524 data list list /id * x1 * x2.
525 begin data.
526 1 3.5 34
527 2 2.0 10
528 3 2.0 23
529 4 3.5 98
530 5 3.0 23
531 67 4.0 8
532 end data.
533
534 t-test /testval=3.0 /var=x1 x2.
535 ])
536 AT_DATA([expout], [dnl
537 Table: Reading free-form data from INLINE.
538 Variable,Format
539 id,F8.0
540 x1,F8.0
541 x2,F8.0
542
543 Table: One-Sample Statistics
544 ,N,Mean,Std. Deviation,S.E. Mean
545 x1,6,3.00,.84,.34
546 x2,6,32.67,33.40,13.64
547
548 Table: One-Sample Test
549 ,Test Value = 3.000000,,,,,
550 ,,,,,95% Confidence Interval of the Difference,
551 ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper
552 x1,.00,5,1.000,.00,-.88,.88
553 x2,2.18,5,.082,29.67,-5.39,64.72
554 ])
555 AT_CHECK([pspp -o ref.csv ref.sps])
556 AT_CHECK([cat ref.csv], [0], [expout])
557 AT_DATA([missing.sps], [dnl
558 data list list /id * x1 * x2.
559 begin data.
560 1 3.5 34
561 2 2.0 10
562 3 2.0 23
563 4 3.5 98
564 5 3.0 23
565 6 4.0 .
566 7  .  8
567 end data.
568
569 t-test /missing=analysis /testval=3.0 /var=x1 x2.
570 ])
571 AT_CHECK([pspp -o missing.csv missing.sps])
572 AT_CHECK([cat missing.csv], [0], [expout])
573 AT_CLEANUP
574
575 AT_SETUP([T-TEST /TESTVAL with listwise missing values])
576 AT_DATA([ref.sps], [dnl
577 data list list /id * x1 * x2.
578 begin data.
579 1 3.5 34
580 2 2.0 10
581 3 2.0 23
582 4 3.5 98
583 5 3.0 23
584 end data.
585
586 t-test /testval=3.0 /var=x1 x2.
587 ])
588 AT_DATA([expout], [dnl
589 Table: Reading free-form data from INLINE.
590 Variable,Format
591 id,F8.0
592 x1,F8.0
593 x2,F8.0
594
595 Table: One-Sample Statistics
596 ,N,Mean,Std. Deviation,S.E. Mean
597 x1,5,2.80,.76,.34
598 x2,5,37.60,34.82,15.57
599
600 Table: One-Sample Test
601 ,Test Value = 3.000000,,,,,
602 ,,,,,95% Confidence Interval of the Difference,
603 ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper
604 x1,-.59,4,.587,-.20,-1.14,.74
605 x2,2.22,4,.090,34.60,-8.63,77.83
606 ])
607 AT_CHECK([pspp -o ref.csv ref.sps])
608 AT_CHECK([cat ref.csv], [0], [expout])
609 AT_DATA([missing.sps], [dnl
610 data list list /id * x1 * x2.
611 begin data.
612 1 3.5 34
613 2 2.0 10
614 3 2.0 23
615 4 3.5 98
616 5 3.0 23
617 6 4.0 99
618 end data.
619
620 MISSING VALUES x2(99).
621
622 t-test /missing=listwise /testval=3.0 /var=x1 x2.
623 ])
624 AT_CHECK([pspp -o missing.csv missing.sps])
625 AT_CHECK([cat missing.csv], [0], [expout])
626 AT_CLEANUP
627
628 AT_SETUP([T-TEST wih TEMPORARY transformation])
629 AT_DATA([ref.sps], [dnl
630 data list list /ind * x * .
631 begin data.
632 1 3.5
633 1 2.0
634 1 2.0
635 2 3.5
636 2 3.0
637 2 4.0
638 end data.
639
640 t-test /groups=ind(1,2) /var x.
641 ])
642 AT_DATA([expout], [dnl
643 Table: Reading free-form data from INLINE.
644 Variable,Format
645 ind,F8.0
646 x,F8.0
647
648 Table: Group Statistics
649 ,ind,N,Mean,Std. Deviation,S.E. Mean
650 x,1.00,3,2.50,.87,.50
651 ,2.00,3,3.50,.50,.29
652
653 Table: Independent Samples Test
654 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
655 ,,,,,,,,,95% Confidence Interval of the Difference,
656 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
657 x,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60
658 ,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77
659 ])
660 AT_CHECK([pspp -o ref.csv ref.sps])
661 AT_CHECK([cat ref.csv], [0], [expout])
662 AT_DATA([temporary.sps], [dnl
663 data list list /ind * x * .
664 begin data.
665 1 3.5
666 1 2.0
667 1 2.0
668 2 3.5
669 2 3.0
670 2 4.0
671 2 9.0
672 end data.
673
674 TEMPORARY.
675 SELECT IF x < 7.
676
677 t-test /groups=ind(1 2) /var x.
678 ])
679 AT_CHECK([pspp -o temporary.csv temporary.sps])
680 AT_CHECK([cat temporary.csv], [0], [expout])
681 AT_CLEANUP
682
683 dnl Tests for a bug which caused T-TEST to crash when given invalid syntax.
684 AT_SETUP([T-TEST invalid syntax])
685 AT_DATA([t-test.sps], [dnl
686 DATA LIST LIST NOTABLE /id * a * .
687 BEGIN DATA.
688 1 3.5
689 2 2.0
690 3 2.0
691 4 3.5
692 5 3.0
693 6 4.0
694 END DATA.
695
696 T-TEST /testval=2.0 .
697 T-TEST /groups=id(3) .
698 ])
699 AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl
700 t-test.sps:11: error: T-TEST: Required subcommand VARIABLES was not specified.
701
702 t-test.sps:12: error: T-TEST: Required subcommand VARIABLES was not specified.
703 ])
704 AT_CLEANUP
705
706 dnl Tests for bug #11227, exhibited when the independent variable is a string.
707 AT_SETUP([T-TEST string variable])
708 AT_DATA([t-test.sps], [dnl
709 data list list /ID * INDEP (a1) DEP1 * DEP2 *.
710 begin data.
711 1  'a' 1 3
712 2  'a' 2 4
713 3  'a' 2 4 
714 4  'a' 2 4 
715 5  'a' 3 5
716 6  'b' 3 1
717 7  'b' 4 2
718 8  'b' 4 2
719 9  'b' 4 2
720 10 'b' 5 3
721 11 'c' 2 2
722 end data.
723
724
725 t-test /GROUPS=indep('a','b') /var=dep1 dep2.
726 ])
727
728 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
729 Table: Reading free-form data from INLINE.
730 Variable,Format
731 ID,F8.0
732 INDEP,A1
733 DEP1,F8.0
734 DEP2,F8.0
735
736 Table: Group Statistics
737 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
738 DEP1,a,5,2.00,.71,.32
739 ,b,5,4.00,.71,.32
740 DEP2,a,5,4.00,.71,.32
741 ,b,5,2.00,.71,.32
742
743 Table: Independent Samples Test
744 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
745 ,,,,,,,,,95% Confidence Interval of the Difference,
746 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
747 DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
748 ,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
749 DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03
750 ,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03
751 ])
752 AT_CLEANUP
753
754 AT_SETUP([T-TEST string variable, only one value])
755 AT_DATA([t-test.sps], [dnl
756 data list list notable /id * indep (a1) dep1 * dep2 *.
757 begin data.
758 1  'a' 1 3
759 2  'a' 2 4
760 3  'a' 2 4 
761 4  'a' 2 4 
762 5  'a' 3 5
763 6  'b' 3 1
764 7  'b' 4 2
765 8  'b' 4 2
766 9  'b' 4 2
767 10 'b' 5 3
768 11 'c' 2 2
769 end data.
770
771
772 t-test /GROUPS=indep('a') /var=dep1 dep2.
773 ])
774 AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl
775 "t-test.sps:17: error: T-TEST: When applying GROUPS to a string variable, two values must be specified."
776 ])
777 AT_CLEANUP
778
779 dnl Tests for a bug which didn't properly compare string values.
780 AT_SETUP([T-TEST string variable comparison bug])
781 AT_DATA([t-test.sps], [dnl
782 data list list /x * gv (a8).
783 begin data.
784 3   One
785 2   One
786 3   One
787 2   One
788 3   One
789 4   Two
790 3.5 Two
791 3.0 Two
792 end data.
793
794 t-test group=gv('One', 'Two')
795         /variables = x.
796 ])
797
798 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
799 Table: Reading free-form data from INLINE.
800 Variable,Format
801 x,F8.0
802 gv,A8
803
804 Table: Group Statistics
805 ,gv,N,Mean,Std. Deviation,S.E. Mean
806 x,One     ,5,2.60,.55,.24
807 ,Two     ,3,3.50,.50,.29
808
809 Table: Independent Samples Test
810 ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,,
811 ,,,,,,,,,95% Confidence Interval of the Difference,
812 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper
813 x,Equal variances assumed,1.13,.329,-2.32,6.00,.060,-.90,.39,-1.85,.05
814 ,Equal variances not assumed,,,-2.38,4.70,.067,-.90,.38,-1.89,.09
815 ])
816 AT_CLEANUP
817
818
819
820 dnl Tests for a bug assert failed when the group variables were not of either class
821 AT_SETUP([T-TEST wrong group])
822 AT_DATA([t-test-crs.sps], [dnl
823 data list list /x * g *.
824 begin data.
825 1 2
826 2 2
827 3 2
828 4 2
829 5 2 
830 end data.
831
832 t-test /variables = x group=g(1,3).
833 ])
834
835 AT_CHECK([pspp t-test-crs.sps], [0],[ignore], [ignore])
836
837 AT_CLEANUP
838
839
840
841 dnl Tests for a bug assert failed when a non-number was passes as the p value
842 AT_SETUP([T-TEST non number p value])
843 AT_DATA([t.sps], [dnl
844 data list list /age d_frage_1 weight height *.
845 begin data.
846 1 2 3 1
847 4 5 6 2
848 end data.
849
850 T-TEST /VARIABLES=age weight height
851  /GROUPS=d_frage_1(1,0) /MISSING=ANALYSIS /CRITERIA=CIN(p.95).
852 ])
853
854 AT_CHECK([pspp t.sps], [1],[ignore], [ignore])
855
856 AT_CLEANUP
857
858
859
860 dnl Another crash on invalid input
861 AT_SETUP([T-TEST unterminated string - paired])
862 AT_DATA([t.sps], [dnl
863 data list list /id * a * b * c * d *.
864 begin data.
865 5 2.0 3.0 4.0 4.0
866 3 1.0 2.0 5.1 3.9
867 3 2.0 4.5 5.2(3.8
868 4 2.0 4.5 5n3 3.7
869 5 3.0 6.0 5.9 3.6
870 6 3.4 6.0 5.9  .
871 end data.
872
873
874 t-test /MISSING=listwise /PAIRS a"b with c d (PA        RED).
875 ])
876
877 AT_CHECK([pspp t.sps],[1],[ignore],[ignore])
878
879 AT_CLEANUP
880
881
882
883