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