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 pspp.csv -o pspp.txt t-test.sps])
34 AT_CHECK([cat pspp.csv], [0], [dnl
35 Table: Reading free-form data from INLINE.
41 Table: Paired Sample Statistics
42 ,,N,Mean,Std. Deviation,S.E. Mean
43 Pair 1,A,5,2.00,.71,.32
46 Table: Paired Samples Correlations
48 Pair 1,A & B,5,.918,.028
50 Table: Paired Samples Test
51 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
52 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
54 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 ,,N,Mean,Std. Deviation,S.E. Mean
85 Pair 1,a,5,2.00,.71,.32
87 Pair 2,c,5,5.10,.69,.31
90 Table: Paired Samples Correlations
92 Pair 1,a & b,5,.918,.028
93 Pair 2,c & d,5,-.918,.028
95 Table: Paired Samples Test
96 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
97 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
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 ,,N,Mean,Std. Deviation,S.E. Mean
149 Pair 1,a,5,2.00,.71,.32
151 Pair 2,b,5,4.00,1.54,.69
154 Table: Paired Samples Correlations
156 Pair 1,a & c,5,.410,.493
157 Pair 2,b & d,5,-.872,.054
159 Table: Paired Samples Test
160 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
161 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
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 pspp.csv -o pspp.txt t-test.sps])
213 AT_CHECK([cat pspp.csv], [0], [dnl
214 Table: Paired Sample Statistics
215 ,,N,Mean,Std. Deviation,S.E. Mean
216 Pair 1,y,530.00,1.94,.96,.04
217 ,x,530.00,1.03,.17,.01
219 Table: Paired Samples Correlations
221 Pair 1,y & x,530.00,.114,.008
223 Table: Paired Samples Test
224 ,,Paired Differences,,,,,t,df,Sig. (2-tailed)
225 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
227 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 ,,N,Mean,Std. Deviation,S.E. Mean
255 Pair 1,A,3,4.333,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,,,,,t,df,Sig. (2-tailed)
264 ,,Mean,Std. Deviation,S.E. Mean,95% Confidence Interval of the Difference,,,,
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 pspp.csv -o pspp.txt t-test.sps])
294 AT_CHECK([cat pspp.csv], [0], [dnl
295 Table: Reading free-form data from INLINE.
302 Table: Group Statistics
303 ,Group,N,Mean,Std. Deviation,S.E. Mean
304 DEP1,1.10,5,2.00,.71,.32
306 DEP2,1.10,5,4.00,.71,.32
309 Table: Independent Samples Test
310 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
311 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
312 ,,,,,,,,,Lower,Upper
313 DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
314 ,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
315 DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03
316 ,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 pspp.csv -o pspp.txt t-test.sps])
351 AT_CHECK([cat pspp.csv], [0], [dnl
352 Table: Reading free-form data from INLINE.
357 Table: Group Statistics
358 ,Group,N,Mean,Std. Deviation,S.E. Mean
359 DEP,≥ 1.51,11,9.00,3.82,1.15
360 ,< 1.51,11,8.00,2.86,.86
362 Table: Independent Samples Test
363 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
364 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
365 ,,,,,,,,,Lower,Upper
366 DEP,Equal variances assumed,.17,.683,.69,20.00,.495,1.00,1.44,-2.00,4.00
367 ,Equal variances not assumed,,,.69,18.54,.496,1.00,1.44,-2.02,4.02
371 AT_SETUP([T-TEST /GROUPS with per-analysis missing values])
372 AT_DATA([ref.sps], [dnl
373 data list list /id * indep * dep1 * dep2 *.
382 t-test /group=indep /var=dep1, dep2.
384 AT_DATA([expout], [dnl
385 Table: Reading free-form data from INLINE.
392 Table: Group Statistics
393 ,Group,N,Mean,Std. Deviation,S.E. Mean
394 dep1,1.00,3,2.50,.87,.50
396 dep2,1.00,3,5.00,1.00,.58
397 ,2.00,2,2.00,1.41,1.00
399 Table: Independent Samples Test
400 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
401 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
402 ,,,,,,,,,Lower,Upper
403 dep1,Equal variances assumed,3.75,.148,-1.12,3.00,.346,-.75,.67,-2.89,1.39
404 ,Equal variances not assumed,,,-1.34,2.78,.279,-.75,.56,-2.61,1.11
405 dep2,Equal variances assumed,.60,.495,2.85,3.00,.065,3.00,1.05,-.35,6.35
406 ,Equal variances not assumed,,,2.60,1.68,.144,3.00,1.15,-2.98,8.98
408 AT_CHECK([pspp -o ref.csv ref.sps])
409 AT_CHECK([cat ref.csv], [0], [expout])
410 AT_DATA([missing.sps], [dnl
411 data list list /id * indep * dep1 * dep2.
422 * Note that if the independent variable is missing, then it's implicitly
425 t-test /missing=analysis /group=indep /var=dep1 dep2.
427 AT_CHECK([pspp -o missing.csv missing.sps])
428 AT_CHECK([cat missing.csv], [0], [expout])
431 AT_SETUP([T-TEST /GROUPS with listwise missing values])
432 AT_DATA([ref.sps], [dnl
433 data list list /id * indep * dep1 * dep2.
443 t-test /group=indep /var=dep1 dep2.
446 AT_DATA([expout], [dnl
447 Table: Reading free-form data from INLINE.
454 Table: Group Statistics
455 ,Group,N,Mean,Std. Deviation,S.E. Mean
456 dep1,1.00,3,2.50,.87,.50
458 dep2,1.00,3,5.00,1.00,.58
459 ,2.00,3,2.00,1.00,.58
461 Table: Independent Samples Test
462 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
463 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
464 ,,,,,,,,,Lower,Upper
465 dep1,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60
466 ,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77
467 dep2,Equal variances assumed,.00,1.000,3.67,4.00,.021,3.00,.82,.73,5.27
468 ,Equal variances not assumed,,,3.67,4.00,.021,3.00,.82,.73,5.27
471 AT_CHECK([pspp -o ref.csv ref.sps])
472 AT_CHECK([cat ref.csv], [0], [expout])
473 AT_DATA([missing.sps], [dnl
474 data list list /id * indep * dep1 * dep2 *.
485 t-test /missing=listwise,exclude /group=indep /var=dep1, dep2.
487 AT_CHECK([pspp -o missing.csv missing.sps])
488 AT_CHECK([cat missing.csv], [0], [expout])
491 AT_SETUP([T-TEST /TESTVAL])
492 AT_DATA([t-test.sps], [dnl
493 data list list /ID * ABC *.
503 t-test /testval=2.0 /var=abc.
505 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
506 AT_CHECK([cat pspp.csv], [0], [dnl
507 Table: Reading free-form data from INLINE.
512 Table: One-Sample Statistics
513 ,N,Mean,Std. Deviation,S.E. Mean
516 Table: One-Sample Test
518 ,t,df,Sig. (2-tailed),Mean Difference,95% Confidence Interval of the Difference,
520 ABC,2.93,5,.033,1.00,.12,1.88
524 AT_SETUP([T-TEST /TESTVAL with per-analysis missing values])
525 AT_DATA([ref.sps], [dnl
526 data list list /id * x1 * x2.
536 t-test /testval=3.0 /var=x1 x2.
538 AT_DATA([expout], [dnl
539 Table: Reading free-form data from INLINE.
545 Table: One-Sample Statistics
546 ,N,Mean,Std. Deviation,S.E. Mean
548 x2,6,32.67,33.40,13.64
550 Table: One-Sample Test
552 ,t,df,Sig. (2-tailed),Mean Difference,95% Confidence Interval of the Difference,
554 x1,.00,5,1.000,.00,-.88,.88
555 x2,2.18,5,.082,29.67,-5.39,64.72
557 AT_CHECK([pspp -o ref.csv ref.sps])
558 AT_CHECK([cat ref.csv], [0], [expout])
559 AT_DATA([missing.sps], [dnl
560 data list list /id * x1 * x2.
571 t-test /missing=analysis /testval=3.0 /var=x1 x2.
573 AT_CHECK([pspp -o missing.csv missing.sps])
574 AT_CHECK([cat missing.csv], [0], [expout])
577 AT_SETUP([T-TEST /TESTVAL with listwise missing values])
578 AT_DATA([ref.sps], [dnl
579 data list list /id * x1 * x2.
588 t-test /testval=3.0 /var=x1 x2.
590 AT_DATA([expout], [dnl
591 Table: Reading free-form data from INLINE.
597 Table: One-Sample Statistics
598 ,N,Mean,Std. Deviation,S.E. Mean
600 x2,5,37.60,34.82,15.57
602 Table: One-Sample Test
604 ,t,df,Sig. (2-tailed),Mean Difference,95% Confidence Interval of the Difference,
606 x1,-.59,4,.587,-.20,-1.14,.74
607 x2,2.22,4,.090,34.60,-8.63,77.83
609 AT_CHECK([pspp -o ref.csv ref.sps])
610 AT_CHECK([cat ref.csv], [0], [expout])
611 AT_DATA([missing.sps], [dnl
612 data list list /id * x1 * x2.
622 MISSING VALUES x2(99).
624 t-test /missing=listwise /testval=3.0 /var=x1 x2.
626 AT_CHECK([pspp -o missing.csv missing.sps])
627 AT_CHECK([cat missing.csv], [0], [expout])
630 AT_SETUP([T-TEST wih TEMPORARY transformation])
631 AT_DATA([ref.sps], [dnl
632 data list list /ind * x * .
642 t-test /groups=ind(1,2) /var x.
644 AT_DATA([expout], [dnl
645 Table: Reading free-form data from INLINE.
650 Table: Group Statistics
651 ,Group,N,Mean,Std. Deviation,S.E. Mean
652 x,1.00,3,2.50,.87,.50
655 Table: Independent Samples Test
656 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
657 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
658 ,,,,,,,,,Lower,Upper
659 x,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60
660 ,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77
662 AT_CHECK([pspp -o ref.csv ref.sps])
663 AT_CHECK([cat ref.csv], [0], [expout])
664 AT_DATA([temporary.sps], [dnl
665 data list list /ind * x * .
679 t-test /groups=ind(1 2) /var x.
681 AT_CHECK([pspp -o temporary.csv temporary.sps])
682 AT_CHECK([cat temporary.csv], [0], [expout])
685 dnl This is an example from doc/tutorial.texi
686 dnl So if the results of this have to be changed in any way,
687 dnl make sure to update that file.
688 AT_SETUP([T-TEST tutorial example])
689 cp $top_srcdir/examples/physiology.sav .
690 AT_DATA([t-test.sps], [dnl
691 GET FILE='physiology.sav'.
692 RECODE height (179 = SYSMIS).
693 T-TEST GROUP=sex(0,1) /VARIABLES=height temperature.
695 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
696 AT_CHECK([cat pspp.csv], [0], [dnl
697 Table: Group Statistics
698 ,Group,N,Mean,Std. Deviation,S.E. Mean
699 Height in millimeters ,Male,22,1796.49,49.71,10.60
700 ,Female,17,1610.77,25.43,6.17
701 Internal body temperature in degrees Celcius,Male,22,36.68,1.95,.42
702 ,Female,18,37.43,1.61,.38
704 Table: Independent Samples Test
705 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
706 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
707 ,,,,,,,,,Lower,Upper
708 Height in millimeters ,Equal variances assumed,.97,.331,14.02,37.00,.000,185.72,13.24,158.88,212.55
709 ,Equal variances not assumed,,,15.15,32.71,.000,185.72,12.26,160.76,210.67
710 Internal body temperature in degrees Celcius,Equal variances assumed,.31,.581,-1.31,38.00,.198,-.75,.57,-1.91,.41
711 ,Equal variances not assumed,,,-1.33,37.99,.190,-.75,.56,-1.89,.39
715 dnl Tests for a bug which caused T-TEST to crash when given invalid syntax.
716 AT_SETUP([T-TEST invalid syntax])
717 AT_DATA([t-test.sps], [dnl
718 DATA LIST LIST NOTABLE /id * a * .
728 T-TEST /testval=2.0 .
729 T-TEST /groups=id(3) .
731 AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl
732 t-test.sps:11: error: T-TEST: Required subcommand VARIABLES was not specified.
734 t-test.sps:12: error: T-TEST: Required subcommand VARIABLES was not specified.
738 dnl Tests for bug #11227, exhibited when the independent variable is a string.
739 AT_SETUP([T-TEST string variable])
740 AT_DATA([t-test.sps], [dnl
741 data list list /ID * INDEP (a1) DEP1 * DEP2 *.
757 t-test /GROUPS=indep('a','b') /var=dep1 dep2.
760 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
761 AT_CHECK([cat pspp.csv], [0], [dnl
762 Table: Reading free-form data from INLINE.
769 Table: Group Statistics
770 ,Group,N,Mean,Std. Deviation,S.E. Mean
771 DEP1,a,5,2.00,.71,.32
773 DEP2,a,5,4.00,.71,.32
776 Table: Independent Samples Test
777 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
778 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
779 ,,,,,,,,,Lower,Upper
780 DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
781 ,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97
782 DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03
783 ,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03
787 AT_SETUP([T-TEST string variable, only one value])
788 AT_DATA([t-test.sps], [dnl
789 data list list notable /id * indep (a1) dep1 * dep2 *.
805 t-test /GROUPS=indep('a') /var=dep1 dep2.
807 AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl
808 "t-test.sps:17: error: T-TEST: When applying GROUPS to a string variable, two values must be specified."
812 dnl Tests for a bug which didn't properly compare string values.
813 AT_SETUP([T-TEST string variable comparison bug])
814 AT_DATA([t-test.sps], [dnl
815 data list list /x * gv (a8).
827 t-test group=gv('One', 'Two')
831 AT_CHECK([pspp -o pspp.csv -o pspp.txt t-test.sps])
832 AT_CHECK([cat pspp.csv], [0], [dnl
833 Table: Reading free-form data from INLINE.
838 Table: Group Statistics
839 ,Group,N,Mean,Std. Deviation,S.E. Mean
843 Table: Independent Samples Test
844 ,,Levene's Test for Equality of Variances,,T-Test for Equality of Means,,,,,,
845 ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,95% Confidence Interval of the Difference,
846 ,,,,,,,,,Lower,Upper
847 x,Equal variances assumed,1.13,.329,-2.32,6.00,.060,-.90,.39,-1.85,.05
848 ,Equal variances not assumed,,,-2.38,4.70,.067,-.90,.38,-1.89,.09
854 dnl Tests for a bug assert failed when the group variables were not of either class
855 AT_SETUP([T-TEST wrong group])
856 AT_DATA([t-test-crs.sps], [dnl
857 data list list /x * g *.
866 t-test /variables = x group=g(1,3).
869 AT_CHECK([pspp t-test-crs.sps], [0],[ignore], [ignore])
875 dnl Tests for a bug assert failed when a non-number was passes as the p value
876 AT_SETUP([T-TEST non number p value])
877 AT_DATA([t.sps], [dnl
878 data list list /age d_frage_1 weight height *.
884 T-TEST /VARIABLES=age weight height
885 /GROUPS=d_frage_1(1,0) /MISSING=ANALYSIS /CRITERIA=CIN(p.95).
888 AT_CHECK([pspp t.sps], [1],[ignore], [ignore])
894 dnl Another crash on invalid input
895 AT_SETUP([T-TEST unterminated string - paired])
896 AT_DATA([t.sps], [dnl
897 data list list /id * a * b * c * d *.
908 t-test /MISSING=listwise /PAIRS a"b with c d (PA RED).
911 AT_CHECK([pspp t.sps],[1],[ignore],[ignore])