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