Fixed bug 12931
[pspp-builds.git] / tests / command / oneway-with-splits.sh
1 #!/bin/sh
2
3 # This program tests that the ONEWAY anova command works OK
4 # when SPLIT FILE is active
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 export STAT_CONFIG_PATH=$top_srcdir/config
15
16
17 cleanup()
18 {
19     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
20         echo Not cleaning $TEMPDIR;
21         return ; 
22     fi
23     rm -rf $TEMPDIR
24 }
25
26
27 fail()
28 {
29     echo $activity
30     echo FAILED
31     cleanup;
32     exit 1;
33 }
34
35
36 no_result()
37 {
38     echo $activity
39     echo NO RESULT;
40     cleanup;
41     exit 2;
42 }
43
44 pass()
45 {
46     cleanup;
47     exit 0;
48 }
49
50 mkdir -p $TEMPDIR
51
52 cd $TEMPDIR
53
54 activity="create program"
55 cat > $TESTFILE <<EOF
56 DATA LIST LIST /QUALITY * BRAND * S *.
57 BEGIN DATA
58 3 1 1
59 2 1 1
60 1 1 1
61 1 1 1
62 4 1 1
63 5 2 1
64 2 2 1
65 4 2 2
66 2 2 2
67 3 2 2
68 7  3 2
69 4  3 2
70 5  3 2
71 3  3 2
72 6  3 2
73 END DATA
74
75 VARIABLE LABELS brand 'Manufacturer'.
76 VARIABLE LABELS quality 'Breaking Strain'.
77
78 VALUE LABELS /brand 1 'Aspeger' 2 'Bloggs' 3 'Charlies'.
79
80 SPLIT FILE by s.
81
82 ONEWAY
83         quality BY brand
84         /STATISTICS descriptives homogeneity
85         /CONTRAST =  -2 2
86         /CONTRAST = -1 1
87         .
88 EOF
89 if [ $? -ne 0 ] ; then no_result ; fi
90
91
92 activity="run program"
93 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
94 if [ $? -ne 0 ] ; then no_result ; fi
95
96 diff -b -B $TEMPDIR/pspp.list - << EOF
97 1.1 DATA LIST.  Reading free-form data from the command file.
98 +--------+------+
99 |Variable|Format|
100 #========#======#
101 |QUALITY |F8.0  |
102 |BRAND   |F8.0  |
103 |S       |F8.0  |
104 +--------+------+
105
106 Variable Value    Label
107 S            1.00
108
109 2.1 ONEWAY.  Descriptives
110 #===============#=======#=#====#==============#==========#=======================#=======#=======#
111 #               |       # |    |              |          |    95% Confidence     |       |       #
112 #               |       # |    |              |          +-----------+-----------+       |       #
113 #               |       #N|Mean|Std. Deviation|Std. Error|Lower Bound|Upper Bound|Minimum|Maximum#
114 #===============#=======#=#====#==============#==========#===========#===========#=======#=======#
115 #Breaking Strain|Aspeger#5|2.20|          1.30|       .58|        .58|       3.82|   1.00|   4.00#
116 #               |Bloggs #2|3.50|          2.12|      1.50|     -15.56|      22.56|   2.00|   5.00#
117 #               |Total  #7|2.57|          1.51|       .57|       1.17|       3.97|   1.00|   5.00#
118 #===============#=======#=#====#==============#==========#===========#===========#=======#=======#
119
120 2.2 ONEWAY.  Test of Homogeneity of Variances
121 #===============#================#===#===#============#
122 #               #Levene Statistic|df1|df2|Significance#
123 #===============#================#===#===#============#
124 #Breaking Strain#           1.086|  1|  5|        .345#
125 #===============#================#===#===#============#
126
127 2.3 ONEWAY.  ANOVA
128 #==============================#==============#==#===========#=====#============#
129 #                              #Sum of Squares|df|Mean Square|  F  |Significance#
130 #===============#==============#==============#==#===========#=====#============#
131 #Breaking Strain|Between Groups#          2.41| 1|      2.414|1.068|        .349#
132 #               |Within Groups #         11.30| 5|      2.260|     |            #
133 #               |Total         #         13.71| 6|           |     |            #
134 #===============#==============#==============#==#===========#=====#============#
135
136 2.4 ONEWAY.  Contrast Coefficients
137 #==========#==============#
138 #          # Manufacturer #
139 #          #-------+------#
140 #          #Aspeger|Bloggs#
141 #========#=#=======#======#
142 #Contrast|1#     -2|     2#
143 #        |2#     -1|     1#
144 #========#=#=======#======#
145
146 2.5 ONEWAY.  Contrast Tests
147 #===============================================#=================#==========#=====#=====#===============#
148 #                                       Contrast#Value of Contrast|Std. Error|  t  |  df |Sig. (2-tailed)#
149 #===============#======================#========#=================#==========#=====#=====#===============#
150 #Breaking Strain|Assume equal variances|    1   #             2.60|     2.516|1.034|    5|           .349#
151 #               |                      |    2   #             1.30|     1.258|1.034|    5|           .349#
152 #               |Does not assume equal |    1   #             2.60|     3.219| .808|1.318|           .539#
153 #               |                      |    2   #             1.30|     1.609| .808|1.318|           .539#
154 #===============#======================#========#=================#==========#=====#=====#===============#
155
156 Variable Value    Label
157 S            2.00
158
159 2.6 ONEWAY.  Descriptives
160 #===============#========#=#====#==============#==========#=======================#=======#=======#
161 #               |        # |    |              |          |    95% Confidence     |       |       #
162 #               |        # |    |              |          +-----------+-----------+       |       #
163 #               |        #N|Mean|Std. Deviation|Std. Error|Lower Bound|Upper Bound|Minimum|Maximum#
164 #===============#========#=#====#==============#==========#===========#===========#=======#=======#
165 #Breaking Strain|Bloggs  #3|3.00|          1.00|       .58|        .52|       5.48|   2.00|   4.00#
166 #               |Charlies#5|5.00|          1.58|       .71|       3.04|       6.96|   3.00|   7.00#
167 #               |Total   #8|4.25|          1.67|       .59|       2.85|       5.65|   2.00|   7.00#
168 #===============#========#=#====#==============#==========#===========#===========#=======#=======#
169
170 2.7 ONEWAY.  Test of Homogeneity of Variances
171 #===============#================#===#===#============#
172 #               #Levene Statistic|df1|df2|Significance#
173 #===============#================#===#===#============#
174 #Breaking Strain#            .923|  1|  6|        .374#
175 #===============#================#===#===#============#
176
177 2.8 ONEWAY.  ANOVA
178 #==============================#==============#==#===========#=====#============#
179 #                              #Sum of Squares|df|Mean Square|  F  |Significance#
180 #===============#==============#==============#==#===========#=====#============#
181 #Breaking Strain|Between Groups#          7.50| 1|      7.500|3.750|        .101#
182 #               |Within Groups #         12.00| 6|      2.000|     |            #
183 #               |Total         #         19.50| 7|           |     |            #
184 #===============#==============#==============#==#===========#=====#============#
185
186 2.9 ONEWAY.  Contrast Coefficients
187 #==========#===============#
188 #          #  Manufacturer #
189 #          #------+--------#
190 #          #Bloggs|Charlies#
191 #========#=#======#========#
192 #Contrast|1#    -2|       2#
193 #        |2#    -1|       1#
194 #========#=#======#========#
195
196 2.10 ONEWAY.  Contrast Tests
197 #===============================================#=================#==========#=====#=====#===============#
198 #                                       Contrast#Value of Contrast|Std. Error|  t  |  df |Sig. (2-tailed)#
199 #===============#======================#========#=================#==========#=====#=====#===============#
200 #Breaking Strain|Assume equal variances|    1   #             4.00|     2.066|1.936|    6|           .101#
201 #               |                      |    2   #             2.00|     1.033|1.936|    6|           .101#
202 #               |Does not assume equal |    1   #             4.00|     1.826|2.191|5.882|           .072#
203 #               |                      |    2   #             2.00|      .913|2.191|5.882|           .072#
204 #===============#======================#========#=================#==========#=====#=====#===============#
205
206 EOF
207 if [ $? -ne 0 ] ; then fail ; fi
208
209 pass