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