Added tests for the one sample and paired T-TEST commands
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 17 Feb 2004 03:47:43 +0000 (03:47 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 17 Feb 2004 03:47:43 +0000 (03:47 +0000)
tests/Makefile.am
tests/command/t-test-1s.sh [new file with mode: 0755]
tests/command/t-test-pairs.sh [new file with mode: 0755]

index 702ccd279238678ee93c28ef4f2afcdf38109230..5d4e7cd704ac9e7611d59137f66e5f73bbed2d47 100644 (file)
@@ -21,6 +21,8 @@ TESTS = command/aggregate.sh \
        command/sort.sh \
        command/tabs.sh \
        command/split-file.sh \
+       command/t-test-1s.sh \
+       command/t-test-pairs.sh \
        command/weight.sh \
        bugs/alpha-freq.sh \
        bugs/double-frequency.sh \
diff --git a/tests/command/t-test-1s.sh b/tests/command/t-test-1s.sh
new file mode 100755 (executable)
index 0000000..cd1b4ad
--- /dev/null
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+# This program tests that the T-TEST /TESTVAL command works OK
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program"
+cat > $TEMPDIR/out.stat <<EOF
+data list list /id * abc *.
+begin data.
+1 3.5
+2 2.0
+3 2.0
+4 3.5
+5 3.0
+6 4.0
+end data.
+
+t-test /testval=2.0 /var=abc.
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare output"
+diff -B -b $TEMPDIR/pspp.list - <<EOF
+1.1 DATA LIST.  Reading free-form data from the command file.
++--------+------+
+|Variable|Format|
+#========#======#
+|ID      |F8.0  |
+|ABC     |F8.0  |
++--------+------+
+
+2.1 T-TEST.  One-Sample Statistics
+#===#=#====#==============#========#
+#   #N|Mean|Std. Deviation|SE. Mean#
+#===#=#====#==============#========#
+#ABC#6|3.00|           .84|    .342#
+#===#=#====#==============#========#
+
+2.2 T-TEST.  One-Sample Test
+#===#=====================================================#
+#   #                Test Value = 2.000000                #
+#   #-----+--+---------------+---------------+------------#
+#   #     |  |               |               |    95%     #
+#   #     |  |               |               +-----+------#
+#   #  t  |df|Sig. (2-tailed)|Mean Difference|Lower| Upper#
+#===#=====#==#===============#===============#=====#======#
+#ABC#2.928| 5|           .033|          1.000|.1220|1.8780#
+#===#=====#==#===============#===============#=====#======#
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass
diff --git a/tests/command/t-test-pairs.sh b/tests/command/t-test-pairs.sh
new file mode 100755 (executable)
index 0000000..6f2c42a
--- /dev/null
@@ -0,0 +1,108 @@
+#!/bin/sh
+
+# This program tests that the T-TEST /PAIRS command works OK
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program"
+cat > $TEMPDIR/out.stat <<EOF
+data list list /id * a * b *.
+begin data.
+1 2.0 3.0
+2 1.0 2.0
+3 2.0 4.5
+4 2.0 4.5
+5 3.0 6.0
+end data.
+
+t-test /PAIRS a with b (PAIRED).
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="compare output"
+diff -B -b $TEMPDIR/pspp.list - <<EOF
+1.1 DATA LIST.  Reading free-form data from the command file.
++--------+------+
+|Variable|Format|
+#========#======#
+|ID      |F8.0  |
+|A       |F8.0  |
+|B       |F8.0  |
++--------+------+
+
+2.1 T-TEST.  Paired Sample Statistics
+#========#====#=#==============#========#
+#        #Mean|N|Std. Deviation|SE. Mean#
+#========#====#=#==============#========#
+#Pair 0 A#2.00|5|          .707|    .316#
+#       B#4.00|5|         1.541|    .689#
+#========#====#=#==============#========#
+
+2.2 T-TEST.  Paired Samples Correlations
+#======#=====#=#===========#====#
+#      |     #N|Correlation|Sig.#
+#======#=====#=#===========#====#
+#Pair 0|A & B#5|       .918|.028#
+#======#=====#=#===========#====#
+
+2.3 T-TEST.  Paired Samples Test
+#===========#=====================================================#======#==#===============#
+#           #                  Paired Differences                 |      |  |               #
+#           #-------+--------------+---------------+--------------+      |  |               #
+#           #       |              |               |     95%      |      |  |               #
+#           #       |              |               +-------+------+      |  |               #
+#           #  Mean |Std. Deviation|Std. Error Mean| Lower | Upper|   t  |df|Sig. (2-tailed)#
+#===========#=======#==============#===============#=======#======#======#==#===============#
+#Pair 0A - B#-2.0000|        .93541|         .41833|-3.1615|-.8385|-4.781| 4|           .009#
+#===========#=======#==============#===============#=======#======#======#==#===============#
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass