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