X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fstats%2Ft-test.at;h=46492319cf04ccb623fe95a0829ec0727c1f23b1;hb=27b5076a4c5530ff843c596e527a305617c67ec9;hp=c8b2b6aed083b828f924652cb0de3aa518be8de6;hpb=65d33b1bd3636cf00567dfe98029980603280b12;p=pspp diff --git a/tests/language/stats/t-test.at b/tests/language/stats/t-test.at index c8b2b6aed0..46492319cf 100644 --- a/tests/language/stats/t-test.at +++ b/tests/language/stats/t-test.at @@ -1,4 +1,20 @@ -/AT_BANNER([T-TEST]) +dnl PSPP - a program for statistical analysis. +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl +AT_BANNER([T-TEST]) AT_SETUP([T-TEST /PAIRS]) AT_DATA([t-test.sps], [dnl @@ -13,8 +29,8 @@ end data. t-test /PAIRS a with b (PAIRED). ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -28,17 +44,20 @@ Pair 1,A,2.00,5,.71,.32 Table: Paired Samples Correlations ,,N,Correlation,Sig. -Pair 1,A & B,5,.92,.03 +Pair 1,A & B,5,.92,.028 Table: Paired Samples Test ,,Paired Differences,,,,,,, ,,,,,95% Confidence Interval of the Difference,,,, ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed) -Pair 1,A - B,-2.00,.94,.42,-3.16,-.84,-4.78,4,.01 +Pair 1,A - B,-2.00,.94,.42,-3.16,-.84,-4.78,4,.009 ]) + AT_CLEANUP + AT_SETUP([T-TEST /PAIRS with per-analysis missing values]) + AT_DATA([ref.sps], [dnl data list list /id * a * b * c * d *. begin data. @@ -51,6 +70,7 @@ end data. t-test /PAIRS a c with b d (PAIRED). ]) + AT_DATA([expout], [dnl Table: Reading free-form data from INLINE. Variable,Format @@ -69,16 +89,17 @@ Pair 2,c,5.10,5,.69,.31 Table: Paired Samples Correlations ,,N,Correlation,Sig. -Pair 1,a & b,5,.92,.03 -Pair 2,c & d,5,-.92,.03 +Pair 1,a & b,5,.92,.028 +Pair 2,c & d,5,-.92,.028 Table: Paired Samples Test ,,Paired Differences,,,,,,, ,,,,,95% Confidence Interval of the Difference,,,, ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed) -Pair 1,a - b,-2.00,.94,.42,-3.16,-.84,-4.78,4,.01 -Pair 2,c - d,1.30,.84,.37,.26,2.34,3.47,4,.03 +Pair 1,a - b,-2.00,.94,.42,-3.16,-.84,-4.78,4,.009 +Pair 2,c - d,1.30,.84,.37,.26,2.34,3.47,4,.025 ]) + AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) AT_DATA([missing.sps], [dnl @@ -93,8 +114,9 @@ begin data. end data. -t-test /MISSING=analysis /PAIRS a c with b d (PAIRED) /CRITERIA=CIN(0.95). +t-test /MISSING=analysis /PAIRS a c with b d (PAIRED) /CRITERIA=CI(0.95). ]) + AT_CHECK([pspp -o missing.csv missing.sps]) AT_CHECK([cat missing.csv], [0], [expout]) AT_CLEANUP @@ -112,6 +134,7 @@ end data. t-test /PAIRS a b with c d (PAIRED). ]) + AT_DATA([expout], [dnl Table: Reading free-form data from INLINE. Variable,Format @@ -130,18 +153,21 @@ Pair 2,b,4.00,5,1.54,.69 Table: Paired Samples Correlations ,,N,Correlation,Sig. -Pair 1,a & c,5,.41,.49 -Pair 2,b & d,5,-.87,.05 +Pair 1,a & c,5,.41,.493 +Pair 2,b & d,5,-.87,.054 Table: Paired Samples Test ,,Paired Differences,,,,,,, ,,,,,95% Confidence Interval of the Difference,,,, ,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed) -Pair 1,a - c,-3.10,.76,.34,-4.04,-2.16,-9.14,4,.00 -Pair 2,b - d,.20,1.68,.75,-1.89,2.29,.27,4,.80 +Pair 1,a - c,-3.10,.76,.34,-4.04,-2.16,-9.14,4,.001 +Pair 2,b - d,.20,1.68,.75,-1.89,2.29,.27,4,.803 ]) + AT_CHECK([pspp -o ref.csv ref.sps]) + AT_CHECK([cat ref.csv], [0], [expout]) + AT_DATA([missing.sps], [dnl data list list /id * a * b * c * d *. begin data. @@ -160,6 +186,49 @@ AT_CHECK([pspp -o missing.csv missing.sps]) AT_CHECK([cat missing.csv], [0], [expout]) AT_CLEANUP + +dnl Tests for a bug in the paired samples T test when weighted +dnl Thanks to Douglas Bonett for reporting this. +AT_SETUP([T-TEST weighted paired bug]) +AT_DATA([t-test.sps], [dnl +DATA LIST notable LIST /x y w *. +BEGIN DATA. +1 1 255 +1 2 43 +1 3 216 +2 1 3 +2 2 1 +2 3 12 +END DATA. + +WEIGHT BY w. + +T-TEST + PAIRS = y WITH x (PAIRED) + /MISSING=ANALYSIS + /CRITERIA=CI(0.95). +]) + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl +Table: Paired Sample Statistics +,,Mean,N,Std. Deviation,S.E. Mean +Pair 1,y,1.94,530.00,.96,.04 +,x,1.03,530.00,.17,.01 + +Table: Paired Samples Correlations +,,N,Correlation,Sig. +Pair 1,y & x,530.00,.11,.008 + +Table: Paired Samples Test +,,Paired Differences,,,,,,, +,,,,,95% Confidence Interval of the Difference,,,, +,,Mean,Std. Deviation,Std. Error Mean,Lower,Upper,t,df,Sig. (2-tailed) +Pair 1,y - x,.91,.95,.04,.83,.99,22.07,529.00,.000 +]) + +AT_CLEANUP + + dnl Tests for a bug in the paired samples T test. dnl Thanks to Mike Griffiths for reporting this problem. AT_SETUP([T-TEST /PAIRS bug]) @@ -220,8 +289,8 @@ end data. t-test /GROUPS=indep(1.1,2.1) /var=dep1 dep2. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -240,11 +309,12 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -DEP1,Equal variances assumed,.00,1.00,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -,Equal variances not assumed,,,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -DEP2,Equal variances assumed,.00,1.00,4.47,8.00,.00,2.00,.45,.97,3.03 -,Equal variances not assumed,,,4.47,8.00,.00,2.00,.45,.97,3.03 +DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03 +,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03 ]) + AT_CLEANUP AT_SETUP([T-TEST /GROUPS with one value for independent variable]) @@ -276,8 +346,8 @@ begin data. end data. t-test /groups=indep(1.514) /var=dep. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format INDEP,F8.0 @@ -292,8 +362,8 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -DEP,Equal variances assumed,.17,.68,.69,20.00,.50,1.00,1.44,-2.00,4.00 -,Equal variances not assumed,,,.69,18.54,.50,1.00,1.44,-2.02,4.02 +DEP,Equal variances assumed,.17,.683,.69,20.00,.495,1.00,1.44,-2.00,4.00 +,Equal variances not assumed,,,.69,18.54,.496,1.00,1.44,-2.02,4.02 ]) AT_CLEANUP @@ -329,10 +399,10 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -dep1,Equal variances assumed,3.75,.15,-1.12,3.00,.35,-.75,.56,-2.53,1.03 -,Equal variances not assumed,,,-1.34,2.78,.28,-.75,.56,-2.61,1.11 -dep2,Equal variances assumed,.60,.50,2.85,3.00,.07,3.00,1.15,-.67,6.67 -,Equal variances not assumed,,,2.60,1.68,.14,3.00,1.15,-2.98,8.98 +dep1,Equal variances assumed,3.75,.148,-1.12,3.00,.346,-.75,.67,-2.89,1.39 +,Equal variances not assumed,,,-1.34,2.78,.279,-.75,.56,-2.61,1.11 +dep2,Equal variances assumed,.60,.495,2.85,3.00,.065,3.00,1.05,-.35,6.35 +,Equal variances not assumed,,,2.60,1.68,.144,3.00,1.15,-2.98,8.98 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -371,6 +441,7 @@ end data. t-test /group=indep /var=dep1 dep2. ]) + AT_DATA([expout], [dnl Table: Reading free-form data from INLINE. Variable,Format @@ -390,11 +461,12 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -dep1,Equal variances assumed,2.00,.23,-1.73,4.00,.16,-1.00,.58,-2.60,.60 -,Equal variances not assumed,,,-1.73,3.20,.18,-1.00,.58,-2.77,.77 -dep2,Equal variances assumed,.00,1.00,3.67,4.00,.02,3.00,.82,.73,5.27 -,Equal variances not assumed,,,3.67,4.00,.02,3.00,.82,.73,5.27 +dep1,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60 +,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77 +dep2,Equal variances assumed,.00,1.000,3.67,4.00,.021,3.00,.82,.73,5.27 +,Equal variances not assumed,,,3.67,4.00,.021,3.00,.82,.73,5.27 ]) + AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) AT_DATA([missing.sps], [dnl @@ -429,8 +501,7 @@ end data. t-test /testval=2.0 /var=abc. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -444,7 +515,7 @@ Table: One-Sample Test ,Test Value = 2.000000,,,,, ,,,,,95% Confidence Interval of the Difference, ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper -ABC,2.93,5,.03,1.00,.12,1.88 +ABC,2.93,5,.033,1.00,.12,1.88 ]) AT_CLEANUP @@ -478,8 +549,8 @@ Table: One-Sample Test ,Test Value = 3.000000,,,,, ,,,,,95% Confidence Interval of the Difference, ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper -x1,.00,5,1.00,.00,-.88,.88 -x2,2.18,5,.08,29.67,-5.39,64.72 +x1,.00,5,1.000,.00,-.88,.88 +x2,2.18,5,.082,29.67,-5.39,64.72 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -530,8 +601,8 @@ Table: One-Sample Test ,Test Value = 3.000000,,,,, ,,,,,95% Confidence Interval of the Difference, ,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper -x1,-.59,4,.59,-.20,-1.14,.74 -x2,2.22,4,.09,34.60,-8.63,77.83 +x1,-.59,4,.587,-.20,-1.14,.74 +x2,2.22,4,.090,34.60,-8.63,77.83 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -583,8 +654,8 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -x,Equal variances assumed,2.00,.23,-1.73,4.00,.16,-1.00,.58,-2.60,.60 -,Equal variances not assumed,,,-1.73,3.20,.18,-1.00,.58,-2.77,.77 +x,Equal variances assumed,2.00,.230,-1.73,4.00,.158,-1.00,.58,-2.60,.60 +,Equal variances not assumed,,,-1.73,3.20,.176,-1.00,.58,-2.77,.77 ]) AT_CHECK([pspp -o ref.csv ref.sps]) AT_CHECK([cat ref.csv], [0], [expout]) @@ -603,7 +674,7 @@ end data. TEMPORARY. SELECT IF x < 7. -t-test /groups=ind(1,2) /var x. +t-test /groups=ind(1 2) /var x. ]) AT_CHECK([pspp -o temporary.csv temporary.sps]) AT_CHECK([cat temporary.csv], [0], [expout]) @@ -653,8 +724,8 @@ end data. t-test /GROUPS=indep('a','b') /var=dep1 dep2. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format ID,F8.0 @@ -673,10 +744,10 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -DEP1,Equal variances assumed,.00,1.00,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -,Equal variances not assumed,,,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 -DEP2,Equal variances assumed,.00,1.00,4.47,8.00,.00,2.00,.45,.97,3.03 -,Equal variances not assumed,,,4.47,8.00,.00,2.00,.45,.97,3.03 +DEP1,Equal variances assumed,.00,1.000,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +,Equal variances not assumed,,,-4.47,8.00,.002,-2.00,.45,-3.03,-.97 +DEP2,Equal variances assumed,.00,1.000,4.47,8.00,.002,2.00,.45,.97,3.03 +,Equal variances not assumed,,,4.47,8.00,.002,2.00,.45,.97,3.03 ]) AT_CLEANUP @@ -723,8 +794,8 @@ end data. t-test group=gv('One', 'Two') /variables = x. ]) -AT_CHECK([pspp -o pspp.csv t-test.sps]) -AT_CHECK([cat pspp.csv], [0], [dnl + +AT_CHECK([pspp -O format=csv t-test.sps], [0], [dnl Table: Reading free-form data from INLINE. Variable,Format x,F8.0 @@ -739,8 +810,8 @@ Table: Independent Samples Test ,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, ,,,,,,,,,95% Confidence Interval of the Difference, ,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -x,Equal variances assumed,1.13,.33,-2.32,6.00,.06,-.90,.38,-1.83,.03 -,Equal variances not assumed,,,-2.38,4.70,.07,-.90,.38,-1.89,.09 +x,Equal variances assumed,1.13,.329,-2.32,6.00,.060,-.90,.39,-1.85,.05 +,Equal variances not assumed,,,-2.38,4.70,.067,-.90,.38,-1.89,.09 ]) AT_CLEANUP @@ -764,3 +835,49 @@ t-test /variables = x group=g(1,3). AT_CHECK([pspp t-test-crs.sps], [0],[ignore], [ignore]) AT_CLEANUP + + + +dnl Tests for a bug assert failed when a non-number was passes as the p value +AT_SETUP([T-TEST non number p value]) +AT_DATA([t.sps], [dnl +data list list /age d_frage_1 weight height *. +begin data. +1 2 3 1 +4 5 6 2 +end data. + +T-TEST /VARIABLES=age weight height + /GROUPS=d_frage_1(1,0) /MISSING=ANALYSIS /CRITERIA=CIN(p.95). +]) + +AT_CHECK([pspp t.sps], [1],[ignore], [ignore]) + +AT_CLEANUP + + + +dnl Another crash on invalid input +AT_SETUP([T-TEST unterminated string - paired]) +AT_DATA([t.sps], [dnl +data list list /id * a * b * c * d *. +begin data. +5 2.0 3.0 4.0 4.0 +3 1.0 2.0 5.1 3.9 +3 2.0 4.5 5.2(3.8 +4 2.0 4.5 5n3 3.7 +5 3.0 6.0 5.9 3.6 +6 3.4 6.0 5.9 . +end data. + + +t-test /MISSING=listwise /PAIRS a"b with c d (PA RED). +]) + +AT_CHECK([pspp t.sps],[1],[ignore],[ignore]) + +AT_CLEANUP + + + +