ae0d39fcba50afedfa9c7f66db21af4310387d96
[pspp-builds.git] / tests / command / npar-wilcoxon.sh
1 #!/bin/sh
2
3 # This program tests the wilcoxon subcommand of npar tests
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR"
27         return ; 
28      fi
29      rm -rf $TEMPDIR
30 }
31
32
33 fail()
34 {
35     echo $activity
36     echo FAILED
37     cleanup;
38     exit 1;
39 }
40
41
42 no_result()
43 {
44     echo $activity
45     echo NO RESULT;
46     cleanup;
47     exit 2;
48 }
49
50 pass()
51 {
52     cleanup;
53     exit 0;
54 }
55
56 mkdir -p $TEMPDIR
57
58 cd $TEMPDIR
59
60 activity="create program 1"
61 cat > $TESTFILE <<  EOF
62 data list notable list /foo * bar * w (f8.0).
63 begin data.
64 1.00     1.00   1
65 1.00     2.00   1
66 2.00     1.00   1
67 1.00     4.00   1
68 2.00     5.00   1
69 1.00    19.00   1
70 2.00     7.00   1
71 4.00     5.00   1
72 1.00    12.00   1
73 2.00    13.00   1
74 2.00     2.00   1
75 12.00      .00  2
76 12.00     1.00  1
77 13.00     1.00  1
78 end data
79
80 variable labels foo "first" bar "second".
81
82 weight by w.
83
84 npar test
85  /wilcoxon=foo with bar (paired)
86  /missing analysis
87  /method=exact.
88
89 EOF
90 if [ $? -ne 0 ] ; then no_result ; fi
91
92
93 activity="run program 1"
94 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
95 if [ $? -ne 0 ] ; then no_result ; fi
96
97 activity="generate results"
98 cat > $TEMPDIR/results.txt <<EOF
99 1.1 NPAR TESTS.  Ranks
100 #============================#==#=========#============#
101 #                            # N|Mean Rank|Sum of Ranks#
102 #============================#==#=========#============#
103 #second - firstNegative Ranks# 5|     8.60|       43.00#
104 #              Positive Ranks# 8|     6.00|       48.00#
105 #              Ties          # 2|         |            #
106 #              Total         #15|         |            #
107 #============================#==#=========#============#
108
109 1.2 NPAR TESTS.  Test Statistics
110 #=====================#==============#
111 #                     #second - first#
112 #=====================#==============#
113 #Z                    #          -.18#
114 #Asymp. Sig (2-tailed)#           .86#
115 #Exact Sig (2-tailed) #           .89#
116 #Exact Sig (1-tailed) #           .45#
117 #=====================#==============#
118
119 EOF
120 if [ $? -ne 0 ] ; then no_result ; fi
121
122
123 activity="compare output 1"
124 diff pspp.list $TEMPDIR/results.txt
125 if [ $? -ne 0 ] ; then fail ; fi
126
127
128
129 # No weights this time. But some missing values
130 activity="create program 2"
131 cat > $TESTFILE <<  EOF
132 data list notable list /foo * bar * dummy *.
133 begin data.
134 1.00     1.00    1
135 1.00     2.00    1
136 2.00     1.00    1
137 1.00     4.00    .
138 2.00     5.00    .
139 1.00    19.00    .
140 2.00     7.00    1
141 4.00     5.00    1
142 1.00    12.00    1
143 2.00    13.00    1
144 2.00     2.00    1
145 12.00      .00   1
146 12.00      .00   1
147 34.2       .     1
148 12.00     1.00   1  
149 13.00     1.00   1
150 end data
151
152 variable labels foo "first" bar "second".
153
154 npar test
155  /wilcoxon=foo with bar (paired)
156  /missing analysis
157  /method=exact.
158
159 EOF
160 if [ $? -ne 0 ] ; then no_result ; fi
161
162
163 activity="run program 2"
164 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
165 if [ $? -ne 0 ] ; then no_result ; fi
166
167 activity="compare output 2"
168 diff pspp.list $TEMPDIR/results.txt
169 if [ $? -ne 0 ] ; then fail ; fi
170
171
172
173 pass;