54c74daa60aaf61c187c7dc878cffc437b35975d
[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     cd /
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 * .
58 BEGIN DATA
59 3 1
60 2 1
61 1 1
62 1 1
63 4 1
64 5 2
65 2 2
66 4 2
67 2 2
68 3 2
69 7  3
70 4  3
71 5  3
72 3  3
73 6  3
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 ONEWAY
82         quality BY brand
83         /STATISTICS descriptives homogeneity
84         /CONTRAST =  -2 1 1 
85         /CONTRAST = 0 -1 1
86         .
87 EOF
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90
91 activity="run program"
92 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
93 if [ $? -ne 0 ] ; then no_result ; fi
94
95 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
96 diff -b  $TEMPDIR/pspp.list - << EOF
97 1.1 DATA LIST.  Reading free-form data from INLINE.
98 +--------+------+
99 |Variable|Format|
100 #========#======#
101 |QUALITY |F8.0  |
102 |BRAND   |F8.0  |
103 +--------+------+
104 2.1 ONEWAY.  Descriptives
105 #===============#========#==#====#==============#==========#=======================#=======#=======#
106 #               |        #  |    |              |          |    95% Confidence     |       |       #
107 #               |        #  |    |              |          +-----------+-----------+       |       #
108 #               |        # N|Mean|Std. Deviation|Std. Error|Lower Bound|Upper Bound|Minimum|Maximum#
109 #===============#========#==#====#==============#==========#===========#===========#=======#=======#
110 #Breaking Strain|Aspeger # 5|2.20|          1.30|       .58|        .58|       3.82|   1.00|   4.00#
111 #               |Bloggs  # 5|3.20|          1.30|       .58|       1.58|       4.82|   2.00|   5.00#
112 #               |Charlies# 5|5.00|          1.58|       .71|       3.04|       6.96|   3.00|   7.00#
113 #               |Total   #15|3.47|          1.77|       .46|       2.49|       4.45|   1.00|   7.00#
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 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 2.4 ONEWAY.  Contrast Coefficients
130 #==========#=======================#
131 #          #      Manufacturer     #
132 #          #-------+------+--------#
133 #          #Aspeger|Bloggs|Charlies#
134 #========#=#=======#======#========#
135 #Contrast|1#     -2|     1|       1#
136 #        |2#      0|    -1|       1#
137 #========#=#=======#======#========#
138 2.5 ONEWAY.  Contrast Tests
139 #===============================================#=================#==========#=====#=====#===============#
140 #                                       Contrast#Value of Contrast|Std. Error|  t  |  df |Sig. (2-tailed)#
141 #===============#======================#========#=================#==========#=====#=====#===============#
142 #Breaking Strain|Assume equal variances|    1   #             3.80|     1.536|2.474|   12|           .029#
143 #               |                      |    2   #             1.80|      .887|2.029|   12|           .065#
144 #               |Does not assume equal |    1   #             3.80|     1.483|2.562|8.740|           .031#
145 #               |                      |    2   #             1.80|      .917|1.964|7.720|           .086#
146 #===============#======================#========#=================#==========#=====#=====#===============#
147 EOF
148 if [ $? -ne 0 ] ; then fail ; fi
149
150 pass