Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / stats / t-test.at
index 14251c1b01c688209ad31c0ae2c8beaf8a1b0adc..46492319cf04ccb623fe95a0829ec0727c1f23b1 100644 (file)
@@ -1,3 +1,19 @@
+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 <http://www.gnu.org/licenses/>.
+dnl
 AT_BANNER([T-TEST])
 
 AT_SETUP([T-TEST /PAIRS])
@@ -98,7 +114,7 @@ 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])
@@ -170,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])
@@ -615,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])
@@ -776,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
+
+
+
+