4efedd8c737566fd0d75e87c7c04fab5cbb79b6c
[pspp-builds.git] / tests / command / t-test-pairs.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /PAIRS command works OK
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 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TESTFILE <<EOF
51 data list list /ID * A * B *.
52 begin data.
53 1 2.0 3.0
54 2 1.0 2.0
55 3 2.0 4.5
56 4 2.0 4.5
57 5 3.0 6.0
58 end data.
59
60 t-test /PAIRS a with b (PAIRED).
61 EOF
62 if [ $? -ne 0 ] ; then no_result ; fi
63
64
65 activity="run program"
66 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69 activity="compare output"
70 diff -B -b $TEMPDIR/pspp.list - <<EOF
71 1.1 DATA LIST.  Reading free-form data from the command file.
72 +--------+------+
73 |Variable|Format|
74 #========#======#
75 |ID      |F8.0  |
76 |A       |F8.0  |
77 |B       |F8.0  |
78 +--------+------+
79
80 2.1 T-TEST.  Paired Sample Statistics
81 #========#====#=#==============#========#
82 #        #Mean|N|Std. Deviation|SE. Mean#
83 #========#====#=#==============#========#
84 #Pair 0 A#2.00|5|          .707|    .316#
85 #       B#4.00|5|         1.541|    .689#
86 #========#====#=#==============#========#
87
88 2.2 T-TEST.  Paired Samples Correlations
89 #======#=====#=#===========#====#
90 #      |     #N|Correlation|Sig.#
91 #======#=====#=#===========#====#
92 #Pair 0|A & B#5|       .918|.028#
93 #======#=====#=#===========#====#
94
95 2.3 T-TEST.  Paired Samples Test
96 #===========#=====================================================#======#==#===============#
97 #           #                  Paired Differences                 |      |  |               #
98 #           #-------+--------------+---------------+--------------+      |  |               #
99 #           #       |              |               |     95%      |      |  |               #
100 #           #       |              |               +-------+------+      |  |               #
101 #           #  Mean |Std. Deviation|Std. Error Mean| Lower | Upper|   t  |df|Sig. (2-tailed)#
102 #===========#=======#==============#===============#=======#======#======#==#===============#
103 #Pair 0A - B#-2.0000|        .93541|         .41833|-3.1615|-.8385|-4.781| 4|           .009#
104 #===========#=======#==============#===============#=======#======#======#==#===============#
105 EOF
106 if [ $? -ne 0 ] ; then fail ; fi
107
108
109 pass