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/>.
16 dnl AT_BANNER([T-TEST])
18 AT_SETUP([T-TEST /PAIRS])
19 AT_DATA([t-test.sps], [dnl
20 data list list /ID * A * B *.
29 t-test /PAIRS a with b (PAIRED).
32 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
33 Table: Reading free-form data from INLINE.
39 Table: Paired Sample Statistics
40 ,,Mean,N,Std. Deviation,S.E. Mean
41 Pair 1,A,2.00,5,.71,.32
44 Table: Paired Samples Correlations
46 Pair 1,A & B,5,.92,.028
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
58 AT_SETUP([T-TEST /PAIRS with per-analysis missing values])
60 AT_DATA([ref.sps], [dnl
61 data list list /id * a * b * c * d *.
70 t-test /PAIRS a c with b d (PAIRED).
73 AT_DATA([expout], [dnl
74 Table: Reading free-form data from INLINE.
82 Table: Paired Sample Statistics
83 ,,Mean,N,Std. Deviation,S.E. Mean
84 Pair 1,a,2.00,5,.71,.32
86 Pair 2,c,5.10,5,.69,.31
89 Table: Paired Samples Correlations
91 Pair 1,a & b,5,.92,.028
92 Pair 2,c & d,5,-.92,.028
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
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 *.
116 t-test /MISSING=analysis /PAIRS a c with b d (PAIRED) /CRITERIA=CI(0.95).
119 AT_CHECK([pspp -o missing.csv missing.sps])
120 AT_CHECK([cat missing.csv], [0], [expout])
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 *.
134 t-test /PAIRS a b with c d (PAIRED).
137 AT_DATA([expout], [dnl
138 Table: Reading free-form data from INLINE.
146 Table: Paired Sample Statistics
147 ,,Mean,N,Std. Deviation,S.E. Mean
148 Pair 1,a,2.00,5,.71,.32
150 Pair 2,b,4.00,5,1.54,.69
153 Table: Paired Samples Correlations
155 Pair 1,a & c,5,.41,.493
156 Pair 2,b & d,5,-.87,.054
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
166 AT_CHECK([pspp -o ref.csv ref.sps])
168 AT_CHECK([cat ref.csv], [0], [expout])
170 AT_DATA([missing.sps], [dnl
171 data list list /id * a * b * c * d *.
182 t-test /MISSING=listwise /PAIRS a b with c d (PAIRED).
184 AT_CHECK([pspp -o missing.csv missing.sps])
185 AT_CHECK([cat missing.csv], [0], [expout])
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 *.
206 PAIRS = y WITH x (PAIRED)
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
217 Table: Paired Samples Correlations
219 Pair 1,y & x,530.00,.11,.008
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
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
236 data list list /A * B *.
243 t-test pairs = a with b (paired).
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.
252 Table: Paired Sample Statistics
253 ,,Mean,N,Std. Deviation,S.E. Mean
254 Pair 1,A,4.333,3,5.774,3.333
257 Table: Paired Samples Correlations
259 Pair 1,A & B,3,1.000,.000
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
269 AT_SETUP([T-TEST /GROUPS])
270 AT_DATA([t-test.sps], [dnl
271 data list list /ID * INDEP * DEP1 * DEP2 *.
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.
289 t-test /GROUPS=indep(1.1,2.1) /var=dep1 dep2.
292 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
293 Table: Reading free-form data from INLINE.
300 Table: Group Statistics
301 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
302 DEP1,1.10,5,2.00,.71,.32
304 DEP2,1.10,5,4.00,.71,.32
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
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 *.
346 t-test /groups=indep(1.514) /var=dep.
349 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
350 Table: Reading free-form data from INLINE.
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
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
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 *.
380 t-test /group=indep /var=dep1, dep2.
382 AT_DATA([expout], [dnl
383 Table: Reading free-form data from INLINE.
390 Table: Group Statistics
391 ,indep,N,Mean,Std. Deviation,S.E. Mean
392 dep1,1.00,3,2.50,.87,.50
394 dep2,1.00,3,5.00,1.00,.58
395 ,2.00,2,2.00,1.41,1.00
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
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.
420 * Note that if the independent variable is missing, then it's implicitly
423 t-test /missing=analysis /group=indep /var=dep1 dep2.
425 AT_CHECK([pspp -o missing.csv missing.sps])
426 AT_CHECK([cat missing.csv], [0], [expout])
429 AT_SETUP([T-TEST /GROUPS with listwise missing values])
430 AT_DATA([ref.sps], [dnl
431 data list list /id * indep * dep1 * dep2.
441 t-test /group=indep /var=dep1 dep2.
444 AT_DATA([expout], [dnl
445 Table: Reading free-form data from INLINE.
452 Table: Group Statistics
453 ,indep,N,Mean,Std. Deviation,S.E. Mean
454 dep1,1.00,3,2.50,.87,.50
456 dep2,1.00,3,5.00,1.00,.58
457 ,2.00,3,2.00,1.00,.58
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
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 *.
483 t-test /missing=listwise,exclude /group=indep /var=dep1, dep2.
485 AT_CHECK([pspp -o missing.csv missing.sps])
486 AT_CHECK([cat missing.csv], [0], [expout])
489 AT_SETUP([T-TEST /TESTVAL])
490 AT_DATA([t-test.sps], [dnl
491 data list list /ID * ABC *.
501 t-test /testval=2.0 /var=abc.
503 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
504 Table: Reading free-form data from INLINE.
509 Table: One-Sample Statistics
510 ,N,Mean,Std. Deviation,S.E. Mean
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
521 AT_SETUP([T-TEST /TESTVAL with per-analysis missing values])
522 AT_DATA([ref.sps], [dnl
523 data list list /id * x1 * x2.
533 t-test /testval=3.0 /var=x1 x2.
535 AT_DATA([expout], [dnl
536 Table: Reading free-form data from INLINE.
542 Table: One-Sample Statistics
543 ,N,Mean,Std. Deviation,S.E. Mean
545 x2,6,32.67,33.40,13.64
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
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.
568 t-test /missing=analysis /testval=3.0 /var=x1 x2.
570 AT_CHECK([pspp -o missing.csv missing.sps])
571 AT_CHECK([cat missing.csv], [0], [expout])
574 AT_SETUP([T-TEST /TESTVAL with listwise missing values])
575 AT_DATA([ref.sps], [dnl
576 data list list /id * x1 * x2.
585 t-test /testval=3.0 /var=x1 x2.
587 AT_DATA([expout], [dnl
588 Table: Reading free-form data from INLINE.
594 Table: One-Sample Statistics
595 ,N,Mean,Std. Deviation,S.E. Mean
597 x2,5,37.60,34.82,15.57
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
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.
619 MISSING VALUES x2(99).
621 t-test /missing=listwise /testval=3.0 /var=x1 x2.
623 AT_CHECK([pspp -o missing.csv missing.sps])
624 AT_CHECK([cat missing.csv], [0], [expout])
627 AT_SETUP([T-TEST wih TEMPORARY transformation])
628 AT_DATA([ref.sps], [dnl
629 data list list /ind * x * .
639 t-test /groups=ind(1,2) /var x.
641 AT_DATA([expout], [dnl
642 Table: Reading free-form data from INLINE.
647 Table: Group Statistics
648 ,ind,N,Mean,Std. Deviation,S.E. Mean
649 x,1.00,3,2.50,.87,.50
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
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 * .
676 t-test /groups=ind(1 2) /var x.
678 AT_CHECK([pspp -o temporary.csv temporary.sps])
679 AT_CHECK([cat temporary.csv], [0], [expout])
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 * .
695 T-TEST /testval=2.0 .
696 T-TEST /groups=id(3) .
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.
701 t-test.sps:12: error: T-TEST: Required subcommand VARIABLES was not specified.
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 *.
724 t-test /GROUPS=indep('a','b') /var=dep1 dep2.
727 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
728 Table: Reading free-form data from INLINE.
735 Table: Group Statistics
736 ,INDEP,N,Mean,Std. Deviation,S.E. Mean
737 DEP1,a,5,2.00,.71,.32
739 DEP2,a,5,4.00,.71,.32
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
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 *.
771 t-test /GROUPS=indep('a') /var=dep1 dep2.
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."
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).
793 t-test group=gv('One', 'Two')
797 AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl
798 Table: Reading free-form data from INLINE.
803 Table: Group Statistics
804 ,gv,N,Mean,Std. Deviation,S.E. Mean
805 x,One ,5,2.60,.55,.24
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
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 *.
831 t-test /variables = x group=g(1,3).
834 AT_CHECK([pspp t-test-crs.sps], [0],[ignore], [ignore])
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 *.
849 T-TEST /VARIABLES=age weight height
850 /GROUPS=d_frage_1(1,0) /MISSING=ANALYSIS /CRITERIA=CIN(p.95).
853 AT_CHECK([pspp t.sps], [1],[ignore], [ignore])
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 *.
873 t-test /MISSING=listwise /PAIRS a"b with c d (PA RED).
876 AT_CHECK([pspp t.sps],[1],[ignore],[ignore])