cedaedf876cd7bb0c931512df8f962d5bb6f5918
[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 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TESTFILE <<EOF
51 DATA LIST LIST /quality * brand * .
52 BEGIN DATA
53 3 1
54 2 1
55 1 1
56 1 1
57 4 1
58 5 2
59 2 2
60 4 2
61 2 2
62 3 2
63 7  3
64 4  3
65 5  3
66 3  3
67 6  3
68 END DATA
69
70 VARIABLE LABELS brand 'Manufacturer'.
71 VARIABLE LABELS quality 'Breaking Strain'.
72
73 VALUE LABELS /brand 1 'Aspeger' 2 'Bloggs' 3 'Charlies'.
74
75 ONEWAY
76         quality BY brand
77         /STATISTICS descriptives homogeneity
78         /CONTRASTS =  -2 1 1 
79         /CONTRASTS = 0 -1 1
80         .
81 EOF
82 if [ $? -ne 0 ] ; then no_result ; fi
83
84
85 activity="run program"
86 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89 diff -b -B $TEMPDIR/pspp.list - << EOF
90 1.1 DATA LIST.  Reading free-form data from the command file.
91 +--------+------+
92 |Variable|Format|
93 #========#======#
94 |QUALITY |F8.0  |
95 |BRAND   |F8.0  |
96 +--------+------+
97
98 2.1 ONEWAY.  Descriptives
99 #===============#========#==#====#==============#==========#=======================#=======#=======#
100 #               |        #  |    |              |          |    95% Confidence     |       |       #
101 #               |        #  |    |              |          +-----------+-----------+       |       #
102 #               |        # N|Mean|Std. Deviation|Std. Error|Lower Bound|Upper Bound|Minimum|Maximum#
103 #===============#========#==#====#==============#==========#===========#===========#=======#=======#
104 #Breaking Strain|Aspeger # 5|2.20|          1.30|       .58|        .58|       3.82|   1.00|   4.00#
105 #               |Bloggs  # 5|3.20|          1.30|       .58|       1.58|       4.82|   2.00|   5.00#
106 #               |Charlies# 5|5.00|          1.58|       .71|       3.04|       6.96|   3.00|   7.00#
107 #               |Total   #15|3.47|          1.77|       .46|       2.49|       4.45|   1.00|   7.00#
108 #===============#========#==#====#==============#==========#===========#===========#=======#=======#
109
110 2.2 ONEWAY.  Test of Homogeneity of Variances
111 #===============#================#===#===#============#
112 #               #Levene Statistic|df1|df2|Significance#
113 #===============#================#===#===#============#
114 #Breaking Strain#            .092|  2| 12|        .913#
115 #===============#================#===#===#============#
116
117 2.3 ONEWAY.  ANOVA
118 #==============================#==============#==#===========#=====#============#
119 #                              #Sum of Squares|df|Mean Square|  F  |Significance#
120 #===============#==============#==============#==#===========#=====#============#
121 #Breaking Strain|Between Groups#         20.13| 2|     10.067|5.119|        .025#
122 #               |Within Groups #         23.60|12|      1.967|     |            #
123 #               |Total         #         43.73|14|           |     |            #
124 #===============#==============#==============#==#===========#=====#============#
125
126 2.4 ONEWAY.  Contrast Coefficients
127 #==========#=======================#
128 #          #      Manufacturer     #
129 #          #-------+------+--------#
130 #          #Aspeger|Bloggs|Charlies#
131 #========#=#=======#======#========#
132 #Contrast|1#     -2|     1|       1#
133 #        |2#      0|    -1|       1#
134 #========#=#=======#======#========#
135
136 2.5 ONEWAY.  Contrast Tests
137 #===============================================#=================#==========#=====#=====#===============#
138 #                                       Contrast#Value of Contrast|Std. Error|  t  |  df |Sig. (2-tailed)#
139 #===============#======================#========#=================#==========#=====#=====#===============#
140 #Breaking Strain|Assume equal variances|    1   #             3.80|     1.536|2.474|   12|           .029#
141 #               |                      |    2   #             1.80|      .887|2.029|   12|           .065#
142 #               |Does not assume equal |    1   #             3.80|     1.483|2.562|8.740|           .031#
143 #               |                      |    2   #             1.80|      .917|1.964|7.720|           .086#
144 #===============#======================#========#=================#==========#=====#=====#===============#
145
146 EOF
147 if [ $? -ne 0 ] ; then fail ; fi
148
149 pass