82288989d3bd946902a07dcb526f4adcfb55e27b
[pspp-builds.git] / tests / command / t-test-groups.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /GROUPS command works
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      cd /
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create program"
52 cat > $TESTFILE <<EOF
53 data list list /ID * INDEP * DEP1 * DEP2 *.
54 begin data.
55 1  1.1 1 3
56 2  1.1 2 4
57 3  1.1 2 4 
58 4  1.1 2 4 
59 5  1.1 3 5
60 6  2.1 3 1
61 7  2.1 4 2
62 8  2.1 4 2
63 9  2.1 4 2
64 10 2.1 5 3
65 11 3.1 2 2
66 end data.
67
68 * Note that this last case should be IGNORED since it doesn't have a dependent variable of either 1 or 2
69
70 t-test /GROUPS=indep(1.1,2.1) /var=dep1 dep2.
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="run program"
76 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="compare output"
80 perl -pi -e s/^\s*\$//g $TEMPDIR/pspp.list
81 diff  -b $TEMPDIR/pspp.list - <<EOF | perl -e 's/^\s*$//g'
82 1.1 DATA LIST.  Reading free-form data from INLINE.
83 +--------+------+
84 |Variable|Format|
85 #========#======#
86 |ID      |F8.0  |
87 |INDEP   |F8.0  |
88 |DEP1    |F8.0  |
89 |DEP2    |F8.0  |
90 +--------+------+
91
92 2.1 T-TEST.  Group Statistics
93 #==========#=#====#==============#========#
94 #     INDEP|N|Mean|Std. Deviation|SE. Mean#
95 #==========#=#====#==============#========#
96 #DEP1 1.1  |5|2.00|          .707|    .316#
97 #     2.1  |5|4.00|          .707|    .316#
98 #DEP2 1.1  |5|4.00|          .707|    .316#
99 #     2.1  |5|2.00|          .707|    .316#
100 #==========#=#====#==============#========#
101
102 2.2 T-TEST.  Independent Samples Test
103 #===============================#==========#===============================================================================#
104 #                               # Levene's |                          t-test for Equality of Means                         #
105 #                               #----+-----+------+-----+---------------+---------------+---------------------+------------#
106 #                               #    |     |      |     |               |               |                     |    95%     #
107 #                               #    |     |      |     |               |               |                     +------+-----#
108 #                               # F  | Sig.|   t  |  df |Sig. (2-tailed)|Mean Difference|Std. Error Difference| Lower|Upper#
109 #===============================#====#=====#======#=====#===============#===============#=====================#======#=====#
110 #DEP1Equal variances assumed    #.000|1.000|-4.472|    8|           .002|         -2.000|                 .447|-3.031|-.969#
111 #    Equal variances not assumed#    |     |-4.472|8.000|           .002|         -2.000|                 .447|-3.031|-.969#
112 #DEP2Equal variances assumed    #.000|1.000| 4.472|    8|           .002|          2.000|                 .447|  .969|3.031#
113 #    Equal variances not assumed#    |     | 4.472|8.000|           .002|          2.000|                 .447|  .969|3.031#
114 #===============================#====#=====#======#=====#===============#===============#=====================#======#=====#
115 EOF
116 if [ $? -ne 0 ] ; then fail ; fi
117
118
119 pass