Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / tests / bugs / t-test-paired.sh
1 #!/bin/sh
2
3 # This program tests for a bug in the paired samples T test.
4 # Thanks to Mike Griffiths for reporting this problem.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_srcdir and top_builddir  are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
14
15 PSPP=$top_builddir/src/ui/terminal/pspp
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR"
28         return ; 
29      fi
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 cat >> $TESTFILE <<EOF
62 set format f8.3.
63 data list list /A * B *.
64 begin data.
65 11 2
66 1  1
67 1  1
68 end data.
69
70 t-test pairs = a with b (paired).
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="run program"
76 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79
80 activity="compare output"
81 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
82 diff  -b  $TEMPDIR/pspp.list - << EOF
83 1.1 DATA LIST.  Reading free-form data from INLINE.
84 +--------+------+
85 |Variable|Format|
86 #========#======#
87 |A       |F8.0  |
88 |B       |F8.0  |
89 +--------+------+
90 2.1 T-TEST.  Paired Sample Statistics
91 #========#=====#=#==============#========#
92 #        # Mean|N|Std. Deviation|SE. Mean#
93 #========#=====#=#==============#========#
94 #Pair 0 A#4.333|3|         5.774|   3.333#
95 #       B#1.333|3|          .577|    .333#
96 #========#=====#=#==============#========#
97 2.2 T-TEST.  Paired Samples Correlations
98 #======#=====#=#===========#====#
99 #      |     #N|Correlation|Sig.#
100 #======#=====#=#===========#====#
101 #Pair 0|A & B#3|      1.000|.000#
102 #======#=====#=#===========#====#
103 2.3 T-TEST.  Paired Samples Test
104 #===========#==================================================#=====#==#===============#
105 #           #                Paired Differences                |     |  |               #
106 #           #-----+--------------+---------------+-------------+     |  |               #
107 #           #     |              |               |     95%     |     |  |               #
108 #           #     |              |               +------+------+     |  |               #
109 #           # Mean|Std. Deviation|Std. Error Mean| Lower| Upper|  t  |df|Sig. (2-tailed)#
110 #===========#=====#==============#===============#======#======#=====#==#===============#
111 #Pair 0A - B#3.000|         5.196|          3.000|-9.908|15.908|1.000| 2|           .423#
112 #===========#=====#==============#===============#======#======#=====#==#===============#
113 EOF
114 if [ $? -ne 0 ] ; then fail ; fi
115
116
117 pass;