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