1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
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.
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.
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/>.
19 AT_SETUP([T-TEST /PAIRS])
20 AT_DATA([t-test.sps], [dnl
21 data list list /ID * A * B *.
30 t-test /PAIRS a with b (PAIRED).
33 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
34 Table: Reading free-form data from INLINE.
40 Table: Paired Sample Statistics
41 ,,Mean,N,Std. Deviation,S.E. Mean
42 Pair 1,A,2.00,5,.71,.32
45 Table: Paired Samples Correlations
47 Pair 1,A & B,5,.92,.028
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
59 AT_SETUP([T-TEST /PAIRS with per-analysis missing values])
61 AT_DATA([ref.sps], [dnl
62 data list list /id * a * b * c * d *.
71 t-test /PAIRS a c with b d (PAIRED).
74 AT_DATA([expout], [dnl
75 Table: Reading free-form data from INLINE.
83 Table: Paired Sample Statistics
84 ,,Mean,N,Std. Deviation,S.E. Mean
85 Pair 1,a,2.00,5,.71,.32
87 Pair 2,c,5.10,5,.69,.31
90 Table: Paired Samples Correlations
92 Pair 1,a & b,5,.92,.028
93 Pair 2,c & d,5,-.92,.028
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
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 *.
117 t-test /MISSING=analysis /PAIRS a c with b d (PAIRED) /CRITERIA=CI(0.95).
120 AT_CHECK([pspp -o missing.csv missing.sps])
121 AT_CHECK([cat missing.csv], [0], [expout])
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 *.
135 t-test /PAIRS a b with c d (PAIRED).
138 AT_DATA([expout], [dnl
139 Table: Reading free-form data from INLINE.
147 Table: Paired Sample Statistics
148 ,,Mean,N,Std. Deviation,S.E. Mean
149 Pair 1,a,2.00,5,.71,.32
151 Pair 2,b,4.00,5,1.54,.69
154 Table: Paired Samples Correlations
156 Pair 1,a & c,5,.41,.493
157 Pair 2,b & d,5,-.87,.054
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
167 AT_CHECK([pspp -o ref.csv ref.sps])
169 AT_CHECK([cat ref.csv], [0], [expout])
171 AT_DATA([missing.sps], [dnl
172 data list list /id * a * b * c * d *.
183 t-test /MISSING=listwise /PAIRS a b with c d (PAIRED).
185 AT_CHECK([pspp -o missing.csv missing.sps])
186 AT_CHECK([cat missing.csv], [0], [expout])
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 *.
207 PAIRS = y WITH x (PAIRED)
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
218 Table: Paired Samples Correlations
220 Pair 1,y & x,530.00,.11,.008
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
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
237 data list list /A * B *.
244 t-test pairs = a with b (paired).
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.
253 Table: Paired Sample Statistics
254 ,,Mean,N,Std. Deviation,S.E. Mean
255 Pair 1,A,4.333,3,5.774,3.333
258 Table: Paired Samples Correlations
260 Pair 1,A & B,3,1.000,.000
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
270 AT_SETUP([T-TEST /GROUPS])
271 AT_DATA([t-test.sps], [dnl
272 data list list /ID * INDEP * DEP1 * DEP2 *.
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.
290 t-test /GROUPS=indep(1.1,2.1) /var=dep1 dep2.
293 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
294 Table: Reading free-form data from INLINE.
301 Table: Group Statistics
302 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
303 DEP1,1.10,5,2.00,.71,.32
305 DEP2,1.10,5,4.00,.71,.32
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
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 *.
347 t-test /groups=indep(1.514) /var=dep.
350 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
351 Table: Reading free-form data from INLINE.
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
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
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 *.
381 t-test /group=indep /var=dep1, dep2.
383 AT_DATA([expout], [dnl
384 Table: Reading free-form data from INLINE.
391 Table: Group Statistics
392 ,indep,N,Mean,Std. Deviation,S.E. Mean
393 dep1,1.00,3,2.50,.87,.50
395 dep2,1.00,3,5.00,1.00,.58
396 ,2.00,2,2.00,1.41,1.00
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
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.
421 * Note that if the independent variable is missing, then it's implicitly
424 t-test /missing=analysis /group=indep /var=dep1 dep2.
426 AT_CHECK([pspp -o missing.csv missing.sps])
427 AT_CHECK([cat missing.csv], [0], [expout])
430 AT_SETUP([T-TEST /GROUPS with listwise missing values])
431 AT_DATA([ref.sps], [dnl
432 data list list /id * indep * dep1 * dep2.
442 t-test /group=indep /var=dep1 dep2.
445 AT_DATA([expout], [dnl
446 Table: Reading free-form data from INLINE.
453 Table: Group Statistics
454 ,indep,N,Mean,Std. Deviation,S.E. Mean
455 dep1,1.00,3,2.50,.87,.50
457 dep2,1.00,3,5.00,1.00,.58
458 ,2.00,3,2.00,1.00,.58
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
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 *.
484 t-test /missing=listwise,exclude /group=indep /var=dep1, dep2.
486 AT_CHECK([pspp -o missing.csv missing.sps])
487 AT_CHECK([cat missing.csv], [0], [expout])
490 AT_SETUP([T-TEST /TESTVAL])
491 AT_DATA([t-test.sps], [dnl
492 data list list /ID * ABC *.
502 t-test /testval=2.0 /var=abc.
504 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
505 Table: Reading free-form data from INLINE.
510 Table: One-Sample Statistics
511 ,N,Mean,Std. Deviation,S.E. Mean
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
522 AT_SETUP([T-TEST /TESTVAL with per-analysis missing values])
523 AT_DATA([ref.sps], [dnl
524 data list list /id * x1 * x2.
534 t-test /testval=3.0 /var=x1 x2.
536 AT_DATA([expout], [dnl
537 Table: Reading free-form data from INLINE.
543 Table: One-Sample Statistics
544 ,N,Mean,Std. Deviation,S.E. Mean
546 x2,6,32.67,33.40,13.64
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
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.
569 t-test /missing=analysis /testval=3.0 /var=x1 x2.
571 AT_CHECK([pspp -o missing.csv missing.sps])
572 AT_CHECK([cat missing.csv], [0], [expout])
575 AT_SETUP([T-TEST /TESTVAL with listwise missing values])
576 AT_DATA([ref.sps], [dnl
577 data list list /id * x1 * x2.
586 t-test /testval=3.0 /var=x1 x2.
588 AT_DATA([expout], [dnl
589 Table: Reading free-form data from INLINE.
595 Table: One-Sample Statistics
596 ,N,Mean,Std. Deviation,S.E. Mean
598 x2,5,37.60,34.82,15.57
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
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.
620 MISSING VALUES x2(99).
622 t-test /missing=listwise /testval=3.0 /var=x1 x2.
624 AT_CHECK([pspp -o missing.csv missing.sps])
625 AT_CHECK([cat missing.csv], [0], [expout])
628 AT_SETUP([T-TEST wih TEMPORARY transformation])
629 AT_DATA([ref.sps], [dnl
630 data list list /ind * x * .
640 t-test /groups=ind(1,2) /var x.
642 AT_DATA([expout], [dnl
643 Table: Reading free-form data from INLINE.
648 Table: Group Statistics
649 ,ind,N,Mean,Std. Deviation,S.E. Mean
650 x,1.00,3,2.50,.87,.50
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
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 * .
677 t-test /groups=ind(1 2) /var x.
679 AT_CHECK([pspp -o temporary.csv temporary.sps])
680 AT_CHECK([cat temporary.csv], [0], [expout])
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 * .
696 T-TEST /testval=2.0 .
697 T-TEST /groups=id(3) .
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.
702 t-test.sps:12: error: T-TEST: Required subcommand VARIABLES was not specified.
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 *.
725 t-test /GROUPS=indep('a','b') /var=dep1 dep2.
728 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
729 Table: Reading free-form data from INLINE.
736 Table: Group Statistics
737 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
738 DEP1,a,5,2.00,.71,.32
740 DEP2,a,5,4.00,.71,.32
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
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 *.
772 t-test /GROUPS=indep('a') /var=dep1 dep2.
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."
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).
794 t-test group=gv('One', 'Two')
798 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
799 Table: Reading free-form data from INLINE.
804 Table: Group Statistics
805 ,gv,N,Mean,Std. Deviation,S.E. Mean
806 x,One ,5,2.60,.55,.24
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
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 *.
832 t-test /variables = x group=g(1,3).
835 AT_CHECK([pspp t-test-crs.sps], [0],[ignore], [ignore])
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 *.
850 T-TEST /VARIABLES=age weight height
851 /GROUPS=d_frage_1(1,0) /MISSING=ANALYSIS /CRITERIA=CIN(p.95).
854 AT_CHECK([pspp t.sps], [1],[ignore], [ignore])
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 *.
874 t-test /MISSING=listwise /PAIRS a"b with c d (PA RED).
877 AT_CHECK([pspp t.sps],[1],[ignore],[ignore])