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