3 # This program tests the chisquare subcommand of the NPAR command.
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
8 # ensure that top_srcdir and top_builddir are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
25 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
26 echo "NOT cleaning $TEMPDIR"
61 activity="create file 1"
63 DATA LIST NOTABLE LIST /x * y * w *.
91 if [ $? -ne 0 ] ; then no_result ; fi
94 activity="run program 1"
95 $SUPERVISOR $PSPP --testing-mode $TESTFILE
96 if [ $? -ne 0 ] ; then no_result ; fi
98 activity="compare output 1"
99 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
100 diff -b $TEMPDIR/pspp.list - << EOF
102 +--------#----------+----------+--------+
103 | #Observed N|Expected N|Residual|
104 +--------#----------+----------+--------+
105 | 1.00# 3.00| 2.33| .67|
106 | 2.00# 3.00| 2.33| .67|
107 | 3.10# 4.00| 2.33| 1.67|
108 | 3.20# 1.00| 2.33| -1.33|
109 | 4.00# 2.00| 2.33| -.33|
110 | 5.00# 1.00| 2.33| -1.33|
112 +--------#----------+----------+--------+
114 +--------#----------+----------+--------+
115 | #Observed N|Expected N|Residual|
116 +--------#----------+----------+--------+
117 | 1.00# 7.00| 3.50| 3.50|
118 | 2.00# 4.00| 3.50| .50|
119 | 3.00# 1.00| 3.50| -2.50|
120 | 4.00# 2.00| 3.50| -1.50|
122 +--------#----------+----------+--------+
123 1.3 NPAR TESTS. Test Statistics
124 +-----------#----+----+
126 +-----------#----+----+
127 |Chi-Square #3.14|6.00|
129 |Asymp. Sig.# .68| .11|
130 +-----------#----+----+
132 +--------#----------+----------+--------+
133 | #Observed N|Expected N|Residual|
134 +--------#----------+----------+--------+
135 | 1.00# 7.00| 2.63| 4.38|
136 | 2.00# 4.00| 3.50| .50|
137 | 3.00# 1.00| 4.38| -3.38|
138 | 4.00# 2.00| 3.50| -1.50|
140 +--------#----------+----------+--------+
141 2.2 NPAR TESTS. Test Statistics
149 3.1 NPAR TESTS. Frequencies
150 +-----#---------------------------------------#---------------------------------------+
152 | #--------+----------+----------+--------#--------+----------+----------+--------+
153 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
154 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
155 |1 # 2.00| 3.00| 3.16| -.16# 2.00| 4.00| 2.21| 1.79|
156 |2 # 3.00| 5.00| 5.26| -.26# 3.00| 1.00| 3.68| -2.68|
157 |3 # 4.00| 2.00| 1.58| .42# 4.00| 2.00| 1.11| .89|
158 |Total# | 10.00| | # | 7.00| | |
159 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
160 3.2 NPAR TESTS. Test Statistics
161 +-----------#---+----+
163 +-----------#---+----+
164 |Chi-Square #.13|4.13|
166 |Asymp. Sig.#.94| .13|
167 +-----------#---+----+
169 if [ $? -ne 0 ] ; then fail ; fi
172 activity="create file 2"
173 cat <<EOF > $TESTFILE
174 DATA LIST NOTABLE LIST /x * y * w *.
189 /EXPECTED = 3 4 5 4 3 1
192 if [ $? -ne 0 ] ; then no_result ; fi
195 activity="run program 2"
196 $SUPERVISOR $PSPP --testing-mode $TESTFILE > $TEMPDIR/output
197 if [ $? -eq 0 ] ; then no_result ; fi
199 activity="compare errors 2"
200 perl -pi -e 's/^\s*$//g' $TEMPDIR/output
201 diff -b $TEMPDIR/output - << EOF
202 error: CHISQUARE test specified 6 expected values, but 4 distinct values were encountered in variable y.
204 if [ $? -ne 0 ] ; then fail ; fi
207 activity="create file 3"
208 cat <<EOF > $TESTFILE
209 DATA LIST NOTABLE LIST /x * y * w * .
223 MISSING VALUES x (4).
228 /STATISTICS=DESCRIPTIVES
231 if [ $? -ne 0 ] ; then no_result ; fi
234 activity="run program 3"
235 $SUPERVISOR $PSPP --testing-mode $TESTFILE
236 if [ $? -ne 0 ] ; then no_result ; fi
239 activity="compare output 3"
240 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
241 diff -b $TEMPDIR/pspp.list - <<EOF
242 1.1 NPAR TESTS. Frequencies
243 +-----#---------------------------------------#---------------------------------------+
245 | #--------+----------+----------+--------#--------+----------+----------+--------+
246 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
247 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
248 |1 # -2.00| .00| 1.50| -1.50# -2.00| .00| 1.88| -1.88|
249 |2 # -1.00| .00| 1.50| -1.50# -1.00| .00| 1.88| -1.88|
250 |3 # .00| .00| 1.50| -1.50# .00| .00| 1.88| -1.88|
251 |4 # 1.00| 3.00| 1.50| 1.50# 1.00| 7.00| 1.88| 5.13|
252 |5 # 2.00| 3.00| 1.50| 1.50# 2.00| 4.00| 1.88| 2.13|
253 |6 # 3.00| 5.00| 1.50| 3.50# 3.00| 1.00| 1.88| -.88|
254 |7 # 4.00| .00| 1.50| -1.50# 4.00| 2.00| 1.88| .13|
255 |8 # 5.00| 1.00| 1.50| -.50# 5.00| 1.00| 1.88| -.88|
256 |Total# | 12.00| | # | 15.00| | |
257 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
258 1.2 NPAR TESTS. Test Statistics
259 +-----------#-----+-----+
261 +-----------#-----+-----+
262 |Chi-Square #17.33|22.87|
264 |Asymp. Sig.# .02| .00|
265 +-----------#-----+-----+
266 1.3 NPAR TESTS. Descriptive Statistics
267 +-#-----+----+----+----+----+
268 | # N |Mean|Std.|Mini|Maxi|
269 | # | |Devi| mum| mum|
270 #=#=====#====#====#====#====#
271 |x#12.00|2.47|1.19|1.00|5.00|
272 |y#15.00|2.07|1.33|1.00|5.00|
273 +-#-----+----+----+----+----+
275 if [ $? -ne 0 ] ; then fail ; fi
278 activity="create file 4"
279 cat <<EOF > $TESTFILE
280 DATA LIST NOTABLE LIST /x * y * w * .
294 * MISSING VALUES x (4).
299 /STATISTICS=DESCRIPTIVES
302 if [ $? -ne 0 ] ; then no_result ; fi
305 activity="run program 4"
306 $SUPERVISOR $PSPP --testing-mode $TESTFILE
307 if [ $? -ne 0 ] ; then no_result ; fi
310 activity="compare output 4"
311 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
312 diff -b $TEMPDIR/pspp.list - <<EOF
313 1.1 NPAR TESTS. Frequencies
314 +-----#---------------------------------------#---------------------------------------+
316 | #--------+----------+----------+--------#--------+----------+----------+--------+
317 | #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
318 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
319 |1 # -2.00| .00| 1.75| -1.75# -2.00| .00| 1.75| -1.75|
320 |2 # -1.00| .00| 1.75| -1.75# -1.00| .00| 1.75| -1.75|
321 |3 # .00| .00| 1.75| -1.75# .00| .00| 1.75| -1.75|
322 |4 # 1.00| 3.00| 1.75| 1.25# 1.00| 7.00| 1.75| 5.25|
323 |5 # 2.00| 3.00| 1.75| 1.25# 2.00| 4.00| 1.75| 2.25|
324 |6 # 3.00| 5.00| 1.75| 3.25# 3.00| 1.00| 1.75| -.75|
325 |7 # 4.00| 2.00| 1.75| .25# 4.00| 2.00| 1.75| .25|
326 |8 # 5.00| 1.00| 1.75| -.75# 5.00| .00| 1.75| -1.75|
327 |Total# | 14.00| | # | 14.00| | |
328 +-----#--------+----------+----------+--------#--------+----------+----------+--------+
329 1.2 NPAR TESTS. Test Statistics
330 +-----------#-----+-----+
332 +-----------#-----+-----+
333 |Chi-Square #13.43|26.00|
335 |Asymp. Sig.# .06| .00|
336 +-----------#-----+-----+
337 1.3 NPAR TESTS. Descriptive Statistics
338 +-#-----+----+----+----+----+
339 | # N |Mean|Std.|Mini|Maxi|
340 | # | |Devi| mum| mum|
341 #=#=====#====#====#====#====#
342 |x#14.00|2.69|1.23|1.00|5.00|
343 |y#14.00|1.86|1.10|1.00|4.00|
344 +-#-----+----+----+----+----+
346 if [ $? -ne 0 ] ; then fail ; fi