Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / oneway.sh
1 #!/bin/sh
2
3 # This program tests that the ONEWAY anova command works OK
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
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 * .
57 BEGIN DATA
58 3 1
59 2 1
60 1 1
61 1 1
62 4 1
63 5 2
64 2 2
65 4 2
66 2 2
67 3 2
68 7  3
69 4  3
70 5  3
71 3  3
72 6  3
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 ONEWAY
81         quality BY brand
82         /STATISTICS descriptives homogeneity
83         /CONTRAST =  -2 1 1 
84         /CONTRAST = 0 -1 1
85         .
86 EOF
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89
90 activity="run program"
91 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
92 if [ $? -ne 0 ] ; then no_result ; fi
93
94 diff -b -B $TEMPDIR/pspp.list - << EOF
95 1.1 DATA LIST.  Reading free-form data from the command file.
96 +--------+------+
97 |Variable|Format|
98 #========#======#
99 |QUALITY |F8.0  |
100 |BRAND   |F8.0  |
101 +--------+------+
102
103 2.1 ONEWAY.  Descriptives
104 #===============#========#==#====#==============#==========#=======================#=======#=======#
105 #               |        #  |    |              |          |    95% Confidence     |       |       #
106 #               |        #  |    |              |          +-----------+-----------+       |       #
107 #               |        # N|Mean|Std. Deviation|Std. Error|Lower Bound|Upper Bound|Minimum|Maximum#
108 #===============#========#==#====#==============#==========#===========#===========#=======#=======#
109 #Breaking Strain|Aspeger # 5|2.20|          1.30|       .58|        .58|       3.82|   1.00|   4.00#
110 #               |Bloggs  # 5|3.20|          1.30|       .58|       1.58|       4.82|   2.00|   5.00#
111 #               |Charlies# 5|5.00|          1.58|       .71|       3.04|       6.96|   3.00|   7.00#
112 #               |Total   #15|3.47|          1.77|       .46|       2.49|       4.45|   1.00|   7.00#
113 #===============#========#==#====#==============#==========#===========#===========#=======#=======#
114
115 2.2 ONEWAY.  Test of Homogeneity of Variances
116 #===============#================#===#===#============#
117 #               #Levene Statistic|df1|df2|Significance#
118 #===============#================#===#===#============#
119 #Breaking Strain#            .092|  2| 12|        .913#
120 #===============#================#===#===#============#
121
122 2.3 ONEWAY.  ANOVA
123 #==============================#==============#==#===========#=====#============#
124 #                              #Sum of Squares|df|Mean Square|  F  |Significance#
125 #===============#==============#==============#==#===========#=====#============#
126 #Breaking Strain|Between Groups#         20.13| 2|     10.067|5.119|        .025#
127 #               |Within Groups #         23.60|12|      1.967|     |            #
128 #               |Total         #         43.73|14|           |     |            #
129 #===============#==============#==============#==#===========#=====#============#
130
131 2.4 ONEWAY.  Contrast Coefficients
132 #==========#=======================#
133 #          #      Manufacturer     #
134 #          #-------+------+--------#
135 #          #Aspeger|Bloggs|Charlies#
136 #========#=#=======#======#========#
137 #Contrast|1#     -2|     1|       1#
138 #        |2#      0|    -1|       1#
139 #========#=#=======#======#========#
140
141 2.5 ONEWAY.  Contrast Tests
142 #===============================================#=================#==========#=====#=====#===============#
143 #                                       Contrast#Value of Contrast|Std. Error|  t  |  df |Sig. (2-tailed)#
144 #===============#======================#========#=================#==========#=====#=====#===============#
145 #Breaking Strain|Assume equal variances|    1   #             3.80|     1.536|2.474|   12|           .029#
146 #               |                      |    2   #             1.80|      .887|2.029|   12|           .065#
147 #               |Does not assume equal |    1   #             3.80|     1.483|2.562|8.740|           .031#
148 #               |                      |    2   #             1.80|      .917|1.964|7.720|           .086#
149 #===============#======================#========#=================#==========#=====#=====#===============#
150
151 EOF
152 if [ $? -ne 0 ] ; then fail ; fi
153
154 pass