dd2d14ae00546d89e986f47b896af1b5a0316d68
[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 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 * A * B *.
54 begin data.
55 1 2.0 3.0
56 2 1.0 2.0
57 3 2.0 4.5
58 4 2.0 4.5
59 5 3.0 6.0
60 end data.
61
62 t-test /PAIRS a with b (PAIRED).
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66
67 activity="run program"
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="compare output"
72 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
73 diff  -b $TEMPDIR/pspp.list - <<EOF
74 1.1 DATA LIST.  Reading free-form data from INLINE.
75 +--------+------+
76 |Variable|Format|
77 #========#======#
78 |ID      |F8.0  |
79 |A       |F8.0  |
80 |B       |F8.0  |
81 +--------+------+
82 2.1 T-TEST.  Paired Sample Statistics
83 #========#====#=#==============#========#
84 #        #Mean|N|Std. Deviation|SE. Mean#
85 #========#====#=#==============#========#
86 #Pair 0 A#2.00|5|          .707|    .316#
87 #       B#4.00|5|         1.541|    .689#
88 #========#====#=#==============#========#
89 2.2 T-TEST.  Paired Samples Correlations
90 #======#=====#=#===========#====#
91 #      |     #N|Correlation|Sig.#
92 #======#=====#=#===========#====#
93 #Pair 0|A & B#5|       .918|.028#
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