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