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