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